-->
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: Index column for list didn't populat when inverse is true
PostPosted: Thu Feb 24, 2005 2:00 pm 
Newbie

Joined: Thu Feb 24, 2005 1:30 pm
Posts: 4
Location: Los Angeles
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

When inverse is false then line_pos column has value 0 and system works fine.
But when I change inverse to true, line_pos is empty and throws
Quote:
null index column for collection
exception when calling session.load method.
and
Hibernate version:
Both Hibernate 3b4 and Hibernate 2.1.8

Mapping documents:

Product class
private List lineItems;

/**
* @hibernate.list cascade="all" inverse = "true"
* @hibernate.collection-key column="line_id"
* @hibernate.collection-index column="line_pos"
* @hibernate.collection-one-to-many class="LineItem"
* @return java.util.List

*/
public List getLineItems() {
return lineItems;
}



public void addLineItem(LineItem lineItem) {
if (lineItem!= null) {
if (this.lineItems== null) {
lineItems= new ArrayList();
}
this.lineItems.add(contract);
lineItem.setProduct(this);
}
}



LineItem class;
private Product product;
/**
* @hibernate.many-to-one
* outer-join="true"
* cascade="none"
* column="line_id"
* not-null="true"
* sql-type="BIGINT"
*/
public Product getProduct() {
return product;
}


Code between sessionFactory.openSession() and session.close():

session = HibernateSessionFactory.currentSession();
Product product= (Product)session.load(Product.class,id );
session.delete(product);
tx.commit();

Full stack trace of any exception that occurs:
org.hibernate.HibernateException: null index column for collection: Product.lineItems


at org.hibernate.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:589)
at org.hibernate.collection.PersistentList.readFrom(PersistentList.java:291)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:557)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:338)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:293)
at org.hibernate.loader.Loader.doQuery(Loader.java:378)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:199)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1279)
at org.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:104)
at org.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:475)
at org.hibernate.event.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:57)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1366)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:268)
at org.hibernate.engine.PersistenceContext.initializeNonLazyCollections(PersistenceContext.java:738)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:204)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1221)
at org.hibernate.loader.EntityLoader.load(EntityLoader.java:137)
at org.hibernate.loader.EntityLoader.load(EntityLoader.java:123)
at org.hibernate.persister.BasicEntityPersister.load(BasicEntityPersister.java:2397)
at org.hibernate.event.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:376)
at org.hibernate.event.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:357)
at org.hibernate.event.DefaultLoadEventListener.load(DefaultLoadEventListener.java:160)
at org.hibernate.event.DefaultLoadEventListener.load(DefaultLoadEventListener.java:134)
at org.hibernate.event.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:113)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:621)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.engine.PersistenceContext.unproxyAndReassociate(PersistenceContext.java:523)
at org.hibernate.event.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:50)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:577)
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
[code][/code]

_________________
--
Reza


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 24, 2005 3:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
http://www.hibernate.org/193.html


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.