-->
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: sorted collection index is not saved
PostPosted: Mon Apr 26, 2004 6:16 am 
Newbie

Joined: Mon Apr 26, 2004 5:54 am
Posts: 8
Hey,
I am trying to save a populated java.util.List. The list contains UserTransaction objects. I cannot use a Set because i want the objects order maintained.

An UserSession has a one-to-many relationship with UserTransaction (the list with UserTransaction objects).

Everything is saved ok except the collection's index : <index column="posn"/>
The "posn" column is created but no data is inserted in it.

Can you give me a hint ? Do I have to have the posn property defined inside the UserTransaction bean ? I don't think that's the case, because i should receive an exception when UserTransaction.hbm.xml is parsed, but i don't.

I can provide some more information if needed but I suspect this is a simple problem, i am sure that i missed something. That's why I would really appreciate if you can also point me to a document describing how to save/restore a List object. I can find everywhere examples with Sets but no Lists, at least not a full example.

I am using:
Hibernate version 2.1.2
PostgreSQL 7.4.2
I don't have any exceptions on save().

Thank you very much,
Mihai

UserSession.hbm.xml :

<?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="ro.code.webpath.UserSession" table="user_sessions">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="native"/>
</id>
<property name="ip" />
<property name="key" />
<property name="browser" />
<property name="startTime" />
<property name="endTime" />
<property name="siteId" />
<list name="transactions" cascade="all" inverse="true">
<key column="sessionId"/>
<index column="posn"/>
<one-to-many class="ro.code.webpath.UserTransaction"/>
</list>
</class>
</hibernate-mapping>


UserTransaction.hbm.xml:

<?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="ro.code.webpath.UserTransaction" table="transactions">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="native"/>
</id>

<property name="startTime" />
<property name="endTime"/>

<many-to-one name="session" class="ro.code.webpath.UserSession" column="sessionId" not-null="true"/>

<list name="requests" cascade="all" inverse="true">
<key column="transactionId"/>
<index column="posn"/>
<one-to-many class="ro.code.webpath.Request"/>
</list>
</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 6:47 am 
Newbie

Joined: Mon Apr 26, 2004 5:54 am
Posts: 8
my fault, the title is wrong, it should be Ordered collection index....


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 6:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
http://www.hibernate.org/193.html


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2004 6:53 pm 
Newbie

Joined: Mon Apr 26, 2004 5:54 am
Posts: 8
michael wrote:


thanks a lot! everything is working fine now...


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.