-->
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: null index column for collection
PostPosted: Sat Jul 15, 2006 3:36 am 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
I have two tables in a master/detail configuration pm_project_revision and pm_task. In my classes ProjectRevisionTo has an array list of tasks. I want to use an order list for the tasks. When I save the revision the index column in the pm_task table is not saved. So when I try to obtain the revision I get null index column for collection.

Hibernate version: 3.1.3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="ve.com.tcs.pm.to.ProjectRevisionTo" table="pm_project_revision" lazy="false">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">pm_sequence</param>
</generator>
</id>
<property name="revision" column="revision" type="long"/>
<property name="author" column="author" type="string"/>
<property name="startDate" column="start_date" type="timestamp"/>
<property name="endDate" column="end_date" type="timestamp"/>
<property name="duration" column="duration" type="double"/>
<property name="actualStartDate" column="actual_start_date" type="timestamp"/>
<property name="actualEndDate" column="actual_end_date" type="timestamp"/>
<property name="actualDuration" column="actual_duration" type="double"/>
<property name="latest" column="latest" type="yes_no"/>
<many-to-one name="project" column="project_id" class="ve.com.tcs.pm.to.ProjectTo" cascade="save-update"/>
<list name="tasks" table="pm_task" lazy="true" cascade="all-delete-orphan" inverse="true">
<key column="project_revision_id"/>
<index column="order_seq"/>
<one-to-many class="ve.com.tcs.pm.to.TaskTo"/>
</list>
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="ve.com.tcs.pm.to.TaskTo" table="pm_task" lazy="false">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">pm_sequence</param>
</generator>
</id>
<property name="name" column="name" type="string"/>
<property name="startDate" column="start_date" type="timestamp"/>
<property name="endDate" column="end_date" type="timestamp"/>
<property name="duration" column="duration" type="double"/>
<property name="actualStartDate" column="actual_start_date" type="timestamp"/>
<property name="actualEndDate" column="actual_end_date" type="timestamp"/>
<property name="actualDuration" column="actual_duration" type="double"/>
<property name="actualCost" column="actual_cost" type="double"/>
<property name="plannedValue" column="planned_value" type="double"/>
<property name="earnedValue" column="earned_value" type="double"/>
<many-to-one name="revision" column="project_revision_id" class="ve.com.tcs.pm.to.ProjectRevisionTo"/>
<many-to-one name="parent" column="parent_id" class="ve.com.tcs.pm.to.TaskTo"/>
<bag name="children" table="pm_task" lazy="true" cascade="all-delete-orphan" inverse="true">
<key column="parent_id"/>
<!-- index column="order_seq"/ -->
<one-to-many class="ve.com.tcs.pm.to.TaskTo"/>
</bag>
<list name="predecessors" table="pm_task_dependency" lazy="true" cascade="all-delete-orphan">
<key column="successor_task_id"/>
<index column="order_seq"/>
<many-to-many class="ve.com.tcs.pm.to.TaskTo" column="predecessor_task_id"/>
</list>
<list name="successors" table="pm_task_dependency" lazy="true" cascade="none">
<key column="predecessor_task_id"/>
<index column="order_seq"/>
<many-to-many class="ve.com.tcs.pm.to.TaskTo" column="successor_task_id"/>
</list>
</class>
</hibernate-mapping>

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

revision = (ProjectRevisionTo) session.createQuery ("from ProjectRevisionTo where id = ?").setLong (0, id).uniqueResult ();
if (revision != null)
{
Hibernate.initialize (revision.getTasks ());

iterator = revision.getTasks ().iterator ();
while (iterator.hasNext ())
{
task = (TaskTo) iterator.next ();

Hibernate.initialize (task.getChildren ());
}
}

Full stack trace of any exception that occurs:

rg.hibernate.HibernateException: null index column for collection: ve.com.tcs.pm.to.ProjectRevisionTo.tasks

at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:652)

at org.hibernate.collection.PersistentList.readFrom(PersistentList.java:358)

at org.hibernate.loader.Loader.readCollectionElement(Loader.java:994)

at org.hibernate.loader.Loader.readCollectionElements(Loader.java:635)

at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)

at org.hibernate.loader.Loader.doQuery(Loader.java:689)

at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)

at org.hibernate.loader.Loader.loadCollection(Loader.java:1919)

at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)

at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:521)

at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)

at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1676)

at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)

at org.hibernate.Hibernate.initialize(Hibernate.java:295)

at ve.com.tcs.pm.bf.ProjectManagementBf.getProjectRevision(ProjectManagementBf.java:926)

Name and version of the database you are using:

Oracle10g Release 2

The generated SQL (show_sql=true):

Hibernate: select tasks0_.project_revision_id as project12_2_, tasks0_.id as id2_, tasks0_.order_seq as order14_2_, tasks0_.id as id11_1_, tasks0_.name as name11_1_, tasks0_.start_date as start3_11_1_, tasks0_.end_date as end4_11_1_, tasks0_.duration as duration11_1_, tasks0_.actual_start_date as actual6_11_1_, tasks0_.actual_end_date as actual7_11_1_, tasks0_.actual_duration as actual8_11_1_, tasks0_.actual_cost as actual9_11_1_, tasks0_.planned_value as planned10_11_1_, tasks0_.earned_value as earned11_11_1_, tasks0_.project_revision_id as project12_11_1_, tasks0_.parent_id as parent13_11_1_, taskto1_.id as id11_0_, taskto1_.name as name11_0_, taskto1_.start_date as start3_11_0_, taskto1_.end_date as end4_11_0_, taskto1_.duration as duration11_0_, taskto1_.actual_start_date as actual6_11_0_, taskto1_.actual_end_date as actual7_11_0_, taskto1_.actual_duration as actual8_11_0_, taskto1_.actual_cost as actual9_11_0_, taskto1_.planned_value as planned10_11_0_, taskto1_.earned_value as earned11_11_0_, taskto1_.project_revision_id as project12_11_0_, taskto1_.parent_id as parent13_11_0_ from pm_task tasks0_, pm_task taskto1_ where tasks0_.parent_id=taskto1_.id(+) and tasks0_.project_revision_id=?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 15, 2006 4:52 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Hibernate 2 did not support bidirectional (inverse="true") one-to-many associations with an indexed collection (list, map or array) as the "many" end.


http://www.hibernate.org/193.html


Try with inverse="false" for " tasks" list or set the indexes manually


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.