Hibernate: How do I link a subclass to its superclass?
Posted
by Markus
on Stack Overflow
See other posts from Stack Overflow
or by Markus
Published on 2010-04-29T00:34:03Z
Indexed on
2010/04/29
0:37 UTC
Read the original article
Hit count: 389
Hey there!
I'm having a little problem setting up my webshop project. Thing is, I have a User() superclass and two subclasses, PrivateUser and BusinessUser.
Now, I'm not quite sure how to get my head around storing this relationship via hibernate.
For the purpose of this question, the User() class contains only one field:
String address;
the PrivateUser contains:
String firstName;
and the BusinessUser contains:
String CompanyName;
Each field has its getter and setter. As is right now, I would only store and be able to get firstName and companyName. When I fetch a user from my DB using Hibernate I would get a PrivateUser/BusinessUser with a null address.
Bottom line is, could someone point me towards a useful tutorial or better yet show a similar example code?
Thanks!
© Stack Overflow or respective owner