-->
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.  [ 4 posts ] 
Author Message
 Post subject: Index column ignored when saving java.util.List property
PostPosted: Sat Mar 27, 2004 7:10 am 
Newbie

Joined: Mon Oct 27, 2003 10:03 am
Posts: 15
I have a bidirectional parent<->child relationship from DocumentClass (parent) to Document (child) where DocumentClass holds an indexed list of Documents. The db table for Document has an index column "doc_position", and the relevant excerpts from my mappings are

[DocumentClass.hbm.xml]
<list name="documents" lazy="true" inverse="true" cascade="all-delete-orphan">

<key column="documentclass_id"/>

<index column="doc_position"/>

<one-to-many class="manplan.j2ee.model.Document"/>
</list>

[Document.hbm.xml]
<many-to-one
name="documentClass"
class="manplan.j2ee.model.DocumentClass"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
column="documentclass_id"
not-null="false"
/>

Upon saving a newly created DocumentClass and its associated child Documents via
Code:
session.saveOrUpdate(documentClass);
session.saveOrUpdate(document);
Hibernate ignores the index column "doc_position" and leaves it at <null> whereas all other columns are treated correctly. I have some other associations with list semantics which exhibit the exact same behaviour. I am running Hibernate 2.1.2 against a Firebird database. What am I doing wrong here?

Thanks,
Olaf


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 4:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Indexed colelction cannot be well managed in a bidir manner.
You should map the idnex column in your child and maintain it manually.
Hibernate set it to null because you set inverse="true" in the one side.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 6:14 am 
Newbie

Joined: Mon Oct 27, 2003 10:03 am
Posts: 15
Emmanuel, thanks for the info. Meanwhile, I have found the relevant FAQ entry. Anyway, I switched to typed arrays instead of lists since my domain objects are exposed via webservices. But now ist seems as if Hibernate doesn't support cascade="all-delete-orphan" when using arrays? The docs didn't say anything to this effect, so I might be wrong.

Cheers,
Olaf


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 7:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You must keep the underlying collection instance to benefit all-delete-orphan capability.
This is usually not possible in such cases as Webservices

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.