Hibernate -using Table per subclass - how to link an existing superclass object to a sibclass object
- by Chandni
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