All,
I am using Hibernate and the Google Web Toolkit together using a package called Hibernate4GWT.
I have it working, to an extent, and I like it VERY MUCH. :)
My problem is that I am trying to populate a List field with a many-to-many association, but I am failing to understand from the documentation how to do this. According to a post
here what I am trying to do was not supported in the past, and it seems maybe it still is not.
What I am attempting to do is use the ID column (which seems to be the natural, no-brainer index?) as a List (or Map would be better) index. In my mapping document below, I have <list-index column="memberId" />. I guess my real problem is that according to the error I am getting, this is not allowed, but I don't even know what to change it to in order to correct it?
Do I have to actually add a field to the table other than the ID field just to assign integer indexes? I am confused.....
Any help to clarify would be greatly appreciated. :)
Peace,
Tom :)
Mapping documents:
<hibernate-mapping>
<class name="com.cpoints.model.Group" table="obj_group" lazy="false">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="name"/>
<property name="description"/>
*** THIS ONE WON'T WORK FOR ME :'((( hehe ***
<list name="members" table="rel_membership" lazy="false">
<key column="groupId"/>
<list-index column="memberId" />
<many-to-many column="memberId" class="com.cpoints.model.Member"/>
</list>
*** THIS ONE WORKS FINE ***
<map name="memberships" table="rel_membership" lazy="false">
<key column="groupId" not-null="true"/>
<map-key column="memberId" type="long"/>
<one-to-many class="com.cpoints.model.Membership"/>
</map>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
Caused by: org.hibernate.MappingException: Repeated column in mapping for collection: com.cpoints.model.Group.members column: memberId
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:304)
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:327)
at org.hibernate.mapping.Collection.validate(Collection.java:284)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:67)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at com.cpoints.server.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
at com.cpoints.server.rpc.RPCServiceImpl.<init>(RPCServiceImpl.java:28)
at com.google.gwt.dev.shell.GWTShellServlet.tryGetOrLoadServlet(GWTShellServlet.java:876)
at com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)