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

texan do-not-reply at jboss.com
Tue May 8 14:27:11 EDT 2007


The problem I have is that, in the table, the combination of user_id and preference_id are not unique.  I haven't found any way to have distinct(user_id,preference_id) as the primary key while also rolling up the multiple rows into a collection based on the value column.

Frankly, I don't think Hibernate can support this, unless there's some sort of custom PK mechanism that could be provided.

The simple (but ugly) solution is to create a User_Preference table with just (user_id,preference_id) columns.  Then I can map the UserPreference object to that and do the collection mapping for the values.

I was just trying to avoid having to create an extra table that adds no value.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044019#4044019

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044019



More information about the jboss-user mailing list