[jboss-dev-forums] [JBoss AS7 Development] - Re: Services with missing/unavailable dependencies EntityManager

Steve Ebersole do-not-reply at jboss.com
Mon Aug 8 14:09:58 EDT 2011


Steve Ebersole [http://community.jboss.org/people/sebersole] created the discussion

"Re: Services with missing/unavailable dependencies EntityManager"

To view the discussion, visit: http://community.jboss.org/message/619960#619960

--------------------------------------------------------------
Hibernate adheres *strictly* to the java contracts for collections.  List is defined as a collection with a defined order.  The problem with mapping a list in the manner done here is that Hibernate cannot rebuild that order when reading the rows from the database.  So it makes a specific distinction here between a list and what it calls a bag (think java.util.Collection).  In order to have Hibernbate treat this as a list you must tell it about the column in the database that is used to store the index/position information.  Prior to version 2,  JPA provided no means to accomplish that.  So prior to JPA 2 you had to use the Hibernater specific annotation org.hibernate.annotations.IndexColumn.  JPA 2 added the annotation javax.persistence.OrderColumn which serves the same purpose.  

Or as pointed out, if you want to continue to map these collections as bags you will have to make one or the other (or both!) non-eager.  Or you can map them as Sets which have a different semantic altogether.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/619960#619960]

Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20110808/22c851a9/attachment.html 


More information about the jboss-dev-forums mailing list