-->
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.  [ 2 posts ] 
Author Message
 Post subject: org.hibernate.HibernateException: null index column for coll
PostPosted: Mon Mar 01, 2010 9:16 am 
Regular
Regular

Joined: Fri May 22, 2009 4:50 am
Posts: 59
Hi,

I have a very complex object in java to be mapped in hibernate.
I am getting the 'org.hibernate.HibernateException: null index column for collection' error while trying to save it.

My object in java is ExecutionPolicy ..
Code:
public class ExecutionPolicy {
       private Map<String, ExecutorConfiguration> executors = new HashMap<String, ExecutorConfiguration>();
}

public class ExecutorConfiguration  {
       private String id;   
       private InstrumentConfigurationMap instrumentMap = new InstrumentConfigurationMap();
}

public class InstrumentConfigurationMap {   
   private Integer id;
   private Map<Instrument, InstrumentConfiguration> instruments = new HashMap<Instrument, InstrumentConfiguration>();
}

public class InstrumentConfiguration {
        private MonetaryArray amountList;
}

public class MonetaryArray {   
   private Integer id;
   private Monetary[] amounts;
}


and the mapping for above object is ..
Code:

<class name="ExecutionPolicy" table="EXECUTION_POLICY">
      <id name="accountId" column="ACCOUNT_ID">
         <generator class="assigned"/>
      </id>
      <map name="executors" table="EXECUTOR" cascade="all">
         <key column="ACCOUNT_ID"/>
         <index column="ID" type="string"/>               
         <composite-element class="ExecutorConfiguration">
            <many-to-one name="instrumentMap"
               column="INSTRUMENT_MAP_ID"
               class="InstrumentConfigurationMap"
               unique="true"
               cascade="all"/>                              
          </composite-element>         
       </map>      
   </class>
   
   <class name="InstrumentConfigurationMap" table="INSTRUMENT_MAP">
      <id name="id" column="ID">
         <generator class="sequence">
            <param name="sequence">policy_sequence</param>
         </generator>
      </id>
      <map name="instruments" table="INSTRUMENTS" cascade="all">
           <key column="ID"/>
           <index column="INSTRUMENT" type="InstrumentUserTypes"/>         
         <composite-element class="InstrumentConfiguration">            
            <property name="amount" column="DEFAULT_AMOUNT" type="MonetaryUserTypes"/>                        
            <many-to-one name="amountList"
               column="AMOUNT_LIST_ID"
               class="MonetaryArray"
               unique="true"
               cascade="save-update"/>   
         </composite-element>   
        </map>   
   </class>
   
   <class name="MonetaryArray" table="AMOUNT_LIST">
      <id name="id" column="ID">
           <generator class="sequence">
            <param name="sequence">policy_sequence</param>
         </generator>
        </id>       
      <array name="amounts" table="AMOUNT" cascade="all">
         <key column="ID"/>
         <list-index column="AMOUNT_INDEX"/>
         <element column="AMOUNT" type="MonetaryUserTypes"/>
      </array>   
   </class>


but the exception i get when i try to save the above object is..

Exception in thread "Main" org.springframework.orm.hibernate3.HibernateSystemException: null index column for collection: InstrumentConfigurationMap.instruments; nested exception is org.hibernate.HibernateException: null index column for collection: InstrumentConfigurationMap.instruments
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:917)
at com.tsdevelopment.blackjack.server.dao.impl.hibernate.AccountDaoImpl.getAccountById(AccountDaoImpl.java:31)
at com.miriamlaurel.blackjack.server.services.DataManager.getAccountById(DataManager.java:61)
at com.miriamlaurel.blackjack.server.services.DbAccountManager.getAccount(DbAccountManager.java:58)
at com.miriamlaurel.blackjack.server.services.DbAccountManager.loadFromDatabase(DbAccountManager.java:143)
at com.miriamlaurel.blackjack.server.services.DbAccountManager.start(DbAccountManager.java:113)
at com.miriamlaurel.fi.managed.services.Services.start(Services.java:84)
at com.miriamlaurel.fi.managed.ManagedApplication.start(ManagedApplication.java:57)
at com.miriamlaurel.blackjack.server.Main.main(Main.java:13)
Caused by: org.hibernate.HibernateException: null index column for collection: InstrumentConfigurationMap.instruments
at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:732)
at org.hibernate.collection.PersistentMap.readFrom(PersistentMap.java:281)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:1031)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:669)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:614)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2015)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:59)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:587)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1743)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:476)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:867)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:264)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:926)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)

if i remove the mapping for amount_list then object gets persisted without any problem.
Any idea what can be the problem?

ANY ANY help is appreciated!!

thanks
rooney


Top
 Profile  
 
 Post subject: Re: org.hibernate.HibernateException: null index column for coll
PostPosted: Fri Mar 05, 2010 6:40 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
sorry, wrong forum: please post this kind of questions to https://forum.hibernate.org/viewforum.php?f=1

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.