-->
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.  [ 5 posts ] 
Author Message
 Post subject: Order of hibernate operations
PostPosted: Tue Oct 19, 2004 4:04 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
Hibernate version: 2.1.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

General question using the following code

tx begin
Oldbj = session.find(1 , XX.class);
session.delete(Oldobj);
session.save(new Newobj("JJJ"));
tx end;

The output of the sql is the insert is issued first then the delete when showsql= true ? Why is this ? The Oldobj is detached object that exists in the database .. and of course the Newobj has not been saved to the database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:06 pm 
Newbie

Joined: Fri Aug 27, 2004 5:36 pm
Posts: 16
Location: Pittsburgh
post hibernate generated SQL queries.

_________________
--------------------------------------------
Vish
Help others too


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:28 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
it's just plain insert into a table and delete ... but not in the expected order
delete from XX where id = ...
insert into XX values ...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:29 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
sorry it was
insert then delete .. but the expectation was delete then insert


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:42 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can change
tx begin
Oldbj = session.find(1 , XX.class);
session.delete(Oldobj);
session.save(new Newobj("JJJ"));
tx end;

to
tx begin
Oldbj = session.find(1 , XX.class);
session.delete(Oldobj);
session.flush();
session.save(new Newobj("JJJ"));
tx end;

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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