-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Index column for LIST mapping is always NULL
PostPosted: Mon Mar 01, 2004 8:45 am 
Newbie

Joined: Mon Jan 05, 2004 10:46 am
Posts: 13
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


Top
 Profile  
 
 Post subject: Index column for LIST mapping is always NULL
PostPosted: Mon Mar 01, 2004 11:08 am 
Newbie

Joined: Mon Jan 05, 2004 10:46 am
Posts: 13
Hi,

solved the problem myself. Switching to <bag>. Found several threads in the old forum dealing with the same problem.

I am not using inverse="true" on my list, so as far as I understand I only have to manage the index property myself if I use inverse="true". Unfortunatly it did not work, the index property was not updated by Hibernate resulting in an ugly Exception.

After switching to bag everything works fine.

Regards,

juergen


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 12:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This should work but wo code, I can't tell what's wrong

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.