[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Map multiple rows to one object?
texan
do-not-reply at jboss.com
Fri May 4 15:48:57 EDT 2007
I'm using EJB3 persistence under JBoss 5.0.5. (But I think this is a hibernate question)
With the table structure below, I want to create a UserPreference class with a relationship to User and Preference, and a collection of String values. Note that (user_id,preference_id) is not unique in the value table, as users can have multiple values for some preferences.
I want the User to have a collection of UserPreference objects, one for each preference_id, rather than one for each unique record in the user_pref_value table.
That is, I'd like to map the UserPreference class to the user_pref_value table where user_id and preference_id are unique and it contains a String collection of values.
Any ideas?
Tables:
user
id (pk)
preference
id (pk)
user_pref_value
user_id (pk)
preference_id (pk)
value (pk)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043335#4043335
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043335
More information about the jboss-user
mailing list