This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I am new to hibernate and not very clear about how mapping works.
I have a 'User' table and a 'Role' table.
User table has fields USERID, USERNAME, ROLEID.
Role table has ROLEID, ROLENAME.
User table has a foreign key reference to the 'ROLE' table (ROLEID).
I am not sure how would the mapping files and the POJO classes would go for both the USER and the ROLE table. Will they have <many-to-one> or <one-to-many> references in the mapping files (which mapping USER or ROLE).
Also, when I do session.load(User.class,userId); how do i get the ROLE NAME associated with that user. Just to remind USER table has a ROLE ID and not a ROLE NAME.
Please help with some code snippet for mapping files and the POJO class for the above example