Hibernate -using Table per subclass - how to link an existing superclass object to a sibclass object

Posted by Chandni on Stack Overflow See other posts from Stack Overflow or by Chandni
Published on 2010-02-04T23:18:41Z Indexed on 2010/05/01 0:47 UTC
Read the original article Hit count: 309

Filed under:
|
|
|
|

Hi,

I have a User hibernate class, Clerk class and Consumer class. All these maps to their own tables in database. The User PK also acts as Clerk's and Consumer's PK.

So now my problem is that if a user is initially a Clerk, he has a record in Users table and Clerks table. If that user wants to become a consumer, I want to link that User's record to the new Consumer's record. So even if I pass the userId to the consumer's record, it treats it as a new User to be persisted and gives a duplicate_key exception. How do I tell Hiernate to link the same user object with this new Consumer object.

Thanks in advance,

-Chandni

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about table