Hi there. Thanks in advance for looking at this problem.
I was perusing some old posts and found a similar topic (
http://forum.hibernate.org/old/912574.html) that is related to my problem,.
I have a Java class (Application) that has a one-to-many with ActivityHistory (Application has an Array of ActivityHistory).
Here are the mapping files:
Application:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="dataobjectschemaconfig.Application">
<id name="appId" type="long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<property name="priority"/>
<array name="activityHistory" inverse="true" cascade="all">
<key column="appId"/>
<index/>
<one-to-many class="dataobjectschemaconfig.ActivityHistory"/>
</array>
<many-to-one name="currActivity" class="dataobjectschemaconfig.ActivityHistory" />
<component name="acordData" class="dataobjectschemaconfig.AcordData" >
<property name="requestXML" type="string">
<column name="requestXML" sql-type="CLOB"/>
</property>
</component>
</class>
</hibernate-mapping>
And here is the child class:
<hibernate-mapping>
<class name="dataobjectschemaconfig.ActivityHistory">
<id name="activityHistoryId" type="long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<property name="activityName"/>
<property name="idx"/>
<many-to-one name="application" column="appId"/>
<array name="ruleHistory" inverse="true" cascade="all">
<key column="activityHistoryId"/>
<index/>
<one-to-many class="dataobjectschemaconfig.RuleHistory"/>
</array>
</class>
</hibernate-mapping>
On the database inserts (we are using DB2), I noticed that, like in the original post, we are seeing null for the index column of the ActivityHistory and when we retrieve the Application, we get an error that the index column is null. The workaround is that we have to add set/getIndex() on the child class (ActivityHistory), as the workaround says, or use Bags but we cannot use bags since it seems we get a ClassCastException as we have Arrays.
So the question is, in the original post, it said:
Author: oneovthafew (Gavin King) Date: 2003-08-04 08:00
inverse="true" lists don't work so well, unless you have a getIndex() property on the Child class.
Use a <bag> instead.
Does this mean it is a bug? If so, will it be fixed? I have quite a few classes I have to modify where I have to add the index property and add the accessor methods, so if I can avoid having to do this with the rest of my classes, it will be great.
Any help or insight will be appreciated.
--Anna