Sorry for the vague subject, I really don't know quite what I'm asking yet so I need some help figuring out what this relationship is and how to do it.
Summary:
I have 3 entities (User, UserStatus and UserType). The User is assigned a Status and Type (e.g. "Active User" and "Administrator"). My DB is highly normalized in that my User table contains a FK reference to the UserStatus table and the UserType table. I want to figure out a way to add a getter on my User hibernate object that will actually return me the correct record from the UserType or UserStatus table,
Detail:
User Hibernate Object (DB table is a mirror of this)
Code:
int id;
int statusID; (FK to UserStatus table)
int typeID; (FK to UserType table)
String firstName;
String lastName;
<all getter/setters>
UserStatus Hibernate Object (DB table is a mirror of this)
Code:
int id;
String name;
String description;
<all getter/setters>
UserType Hibernate Object (DB table is a mirror of this)
Code:
int id;
String name;
String description;
<all getter/setters>
So what I want to do is change my User Hibernate Object to look like this:
Code:
int id;
int statusID; (FK to UserStatus table)
int typeID; (FK to UserType table)
String firstName;
String lastName;
<all getter/setters>
+ UserStatus getUserStatus();
+ UserType getUserType();
and have the 2 methods that I added at the end there, key off of the statusID and typeID values to actually have Hibernate load and return the respective UserStatus and UserType instances from the DB.
Is this possible? What kind of relationship is this called? I thought it might be a component, but then in the manual it mentions that component's fields need to be in the same table as the parent class, and in this case they aren't and I don't want to make them.
Any help or direction on this would be great, I don't mind getting my hands dirty and whacky away at code, I just need to know what I"m dealing with or if this isn't possible.