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]