Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [Persistence, JBoss/CMP, Hibernate,
 Database] - Map multiple rows to one object?

scott.stark@jboss.org

2007-05-04


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
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.