-->
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: session.delete(Object) difference between Hibernate 2 and 3
PostPosted: Wed Apr 13, 2005 2:25 pm 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
Hi, I would like to use a feature of Hibernate 2 (2.0.3) in Hibernate 3.

In Hibernate 2, I could delete a batch of record by passing a String in the session.delete. Like:
Code:
session.delete(SQL String).


It seems that now in hibernate3 this feature is not there anymore. How can we delete all record from a table?

I would need this feature for my initializing my UnitTest...
Must I do a "from mytable" iterate in it and delete each Object??

According to the PDF documentation of Hibernate 3, the function is not there anymore:


HIBERNATE 2.0.3 PDF
Code:
7.6. Deleting persistent objects
Session.delete() will remove an object's state from the database. Of course, your application might still hold
a reference to it. So it's best to think of delete() as making a persistent instance transient.
sess.delete(cat);
---------> You may also delete many objects at once by passing a Hibernate query string to delete().
You may now delete objects in any order you like, without risk of foreign key constraint violations. Of course,
it is still possible to violate a NOT NULL constraint on a foreign key column by deleting objects in the wrong order.



HIBERNATE 3 PDF:
Code:
10.8. Deleting persistent objects
Session.delete() will remove an object's state from the database. Of course, your application might still hold
a reference to a deleted object. It's best to think of delete() as making a persistent instance transient.
sess.delete(cat);
You may delete objects in any order you like, without risk of foreign key constraint violations. It is still possible
to violate a NOT NULL constraint on a foreign key column by deleting objects in the wrong order, e.g. if
you delete the parent, but forget to delete the children.




Thanks

Etienne
Montreal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 2:33 pm 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
Hi all,

I found some information about this at : http://forum.hibernate.org/viewtopic.php?t=940248&highlight=deleting+persistence+object

Thanks

Etienne.


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.