-->
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: Why collection isn't initialized after save detached parent
PostPosted: Mon May 24, 2004 5:49 am 
Newbie

Joined: Mon May 24, 2004 3:51 am
Posts: 9
Hi

After I save an detached object I try to access a collection on it. The collection is defined as


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 5:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please read the read text before posting.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 7:32 am 
Newbie

Joined: Mon May 24, 2004 3:51 am
Posts: 9
I was thinking before posting some code to get an answer if the comportament that I've got from Hibernate is an usual one or it is an error.

Here is my configuration:

I use Hibernate 2.1.2, Oracle 8.1.7

the parent object is of type Societe :
<class
name="Societe"
table="SOCIETE"
>
<id
name="id"
type="long"
column="ID"
unsaved-value="0"
>
<generator class="seqhilo">
<param name="sequence">SOCIETE_SEQ</param>
<param name="max_lo">100</param>
</generator>
</id>

<property
name="nom"
type="java.lang.String"
column="NOM"
not-null="true"
unique="true"
length="60"
/>
<!-- bi-directional one-to-many association to AdresseSociete -->
<set
name="adresseSocietes"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="SOC_ID" />
</key>
<one-to-many
class="AdresseSociete"
/>
</set>
</class>

and the collection is of type AdresseSociete:

<class
name="AdresseSociete"
table="ADRESSE_SOCIETE"
>
<id
name="id"
type="long"
column="ID"
unsaved-value="0"
>
<generator class="seqhilo">
<param name="sequence">ADRESSE_SOCIETE_SEQ</param>
<param name="max_lo">100</param>
</generator>
</id>

<property
name="adresse"
type="java.lang.String"
column="ADRESSE"
length="255"
/>

</class>

The execution order is:

I charge in the Hibernate session an Societe object
Hibernate session is closed
I send the Societe object to a different tier. Here I don't copy the AdresseSociete collection because I dont't need it.
I change in the UI tier the name of the Societe.
Then in a newly created session, in the persistence tier I save and commit the Societe object.
I charge the Societe object with Session.load(id, class)
If I try to acced to the adresseSocetes collection it returns me a null collection. Is this normal?

How ever if I make an session.clear() before loading and after the save of the Societe object the adresseSocetes collection is well initialized


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 2:13 am 
Newbie

Joined: Mon May 24, 2004 3:51 am
Posts: 9
I would really apreciate an answer, plzzzz
Please ask me some more details if my question and my explanations are not very clear.


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.