-->
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: how can a change order of insertions
PostPosted: Tue Nov 25, 2003 12:12 pm 
Beginner
Beginner

Joined: Tue Nov 25, 2003 11:55 am
Posts: 23
i have an object A depending to an object B. A is mapped with a many-to-one-relationship in mapping file of B. the ID of B is an not-null-field in table of A. my problem is that A will be saved earlier than B and because of B is not saved yet I get a NOtNullViolationException from database.

Mapping B:
<hibernate-mapping>
<class name="com.carano.cbf.kalkulation.po.NachlassPO" table ="NACHLASS">
<jcs-cache usage="read-write"/>
<id name="ID">
<column name="NACHLASS_ID" sql-type="int"/>
<generator class="fleet.kalkulation.persistence.AppIdGenerator"/>
</id>
....
<!-- DepBO -->
<many-to-one
name="fahrzeuggeltungsbereich"
column="NACHLASS_ID" class="com.carano.automotive.fahrzeug.po.FahrzeuggeltungsbereichPO"
cascade="all"
outer-join="auto"
update="false"
insert="false"
/>
....
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 12:26 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
1. save(B) then save (A)
2. add a one-to-many to B, cascaded and save B (as per the parent child relationship in refrence guide)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2003 7:30 am 
Beginner
Beginner

Joined: Tue Nov 25, 2003 11:55 am
Posts: 23
i'm sure that the second case (parent-child-relation) will solve my problem. but when I tried this I got a classcastexception, because now I mapped this relation as a Set but I have just one child and don't need a set. so what can I do?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2003 2:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
one-to-one ?

_________________
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.