Hi,
I have the problem, that when mapping a one-to-many association using
a list the index column I specified is always null.
Actually when I watch the SQL statement getting executed the insert statement does not contain the index column.
My mapping looks like this:
Code:
<class name="test.domain.Group" table="user_group">
<id name="id" column="id" type="long" unsaved-value="-1">
<generator class="sequence">
<param name="sequence">SEQ_KEY</param>
</generator>
</id>
<property name="name"/>
<list name="accounts" table="user_account" cascade="save-update">
<key column="GROUP_ID"/>
<index column="GROUP_INDEX"/>
<one-to-many class="test.domain.Account"/>
</list>
</class>
When I create an Account object I assign the Group to the Account and add the Account to the Group before saving the object.
As soon as I try to load the Account object from the database I get the following error:
Code:
org.springframework.orm.hibernate.HibernateSystemException: null index column for collection: com.openshop.pizzashop.shop.domain.Group.accounts; nested exception is net.sf.hibernate.HibernateException: null index column for collection: com.openshop.pizzashop.shop.domain.Group.accounts
org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:175)
org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:203)
org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:154)
org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:473)
org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:488)
What can be the reason for this?
Any help greatly appreciated.
Best regards,
juergen