-->
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: Lifecycle objects being sent to an early grave
PostPosted: Mon Mar 22, 2004 4:01 pm 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
When I have a SQL failure (value to large for column) during a save (or saveOrUpdate), the lifecycle objects are discarded from the Set on the containing object.

Briefly, something like this:

public class Wart extends Synchonzied {
public Wart(Frog frog) {
this.host = frog;
}
Long id = null;
String color = null;
Frog host = null;
...
}

public class Frog extends Syncrhonized {
public Long id = null;
public Set warts = null; // collection of Warts
...
}

...
Frog larry = new Frog();
larry.addWart(new Wart(larry));
...
session.beginTransaction();
session.save(larry);
...
...println(larry.getWarts().size());

Output: 0


Top
 Profile  
 
 Post subject: ...more...xml
PostPosted: Mon Mar 22, 2004 4:27 pm 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
This might help:
<hibernate-mapping>
<class
name="Frog"
table="FROG">

<id
name="id"
type="java.lang.Long"
column="FROG_ID">

<generator class="sequence">
<param name="sequence">FROG_SEQ</param>
</generator>
</id>

<set
name="warts"
cascade="save-update"
inverse="true"
lazy="false">

<key column="FROG_ID" />
<one-to-many class="Wart"/>
</set>

</class>
</hibernate-mapping>



<hibernate-mapping>
<class
name="Wart"
table="WART">

<id
name="id"
type="java.lang.Long"
column="WART_ID">

<generator class="sequence">
<param name="sequence">WART_SEQ</param>
</generator>
</id>

<many-to-one
name="host"
class="Frog"
column="FROG_ID"
not-null="true">
</many-to-one>
</class>
</hibernate-mapping>


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.