-->
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: inverse="true" , index, and arrays
PostPosted: Tue Dec 23, 2003 3:05 pm 
Newbie

Joined: Tue Dec 23, 2003 2:02 pm
Posts: 3
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 6:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, it is not a bug. It is something that is virtually impossible to implement properly for detached objects.


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.