-->
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.  [ 3 posts ] 
Author Message
 Post subject: Delete - Many-to-one Mapping
PostPosted: Mon Jul 18, 2005 4:29 pm 
Newbie

Joined: Mon Jul 18, 2005 3:51 pm
Posts: 4
I am new to Hibernate. In my application a class "Analysis" have unidirrectional many-to-one association with a class called "Dataset".

In the "Analysis" mapping file the relationship specified as follows:
<many-to-one
name="dataset"
class="emissions.emisview.Dataset"
column="DATASET_ID"
cascade="save-update"
/>

When I delete Dataset object using Session.delete() I am getting an exception, org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch updae.

Is there any setting available in Hibernate that will check whether the deleting dataset is referenced in the analyses table, if so set the reference to null before delete them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 1:12 pm 
Newbie

Joined: Thu Feb 17, 2005 3:01 pm
Posts: 9
One way would be to have a collection property on Dataset class and check the size of the collection before deleting.
Add the set element to the dataset.hbm file
<set
name=""
lazy="true"
inverse="true"

>
<key>
<column name="" />
</key>
<one-to-many
class="Analysis"
/>
</set>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 4:00 pm 
Newbie

Joined: Mon Jul 18, 2005 3:51 pm
Posts: 4
I believe that won't work. In my case I can have only uni directional relationship. So the "Dataset" won't have "Analysis".


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