-->
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: Deleting a record using Hibernate
PostPosted: Mon May 09, 2005 1:49 am 
Newbie

Joined: Mon May 02, 2005 12:56 am
Posts: 17
How do i delete a record from the table using Hibernate.

Thanks in advance.
Shrimon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 2:59 am 
Newbie

Joined: Fri Mar 18, 2005 1:05 pm
Posts: 8
Location: Delhi
Hi you can delete by first load the object using
HibernateUtil.load("class name",id);
and then use
HibernateUtil.delete(object);

Hope this helps u.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 8:58 am 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
So when deleting an object you have to load the object fully first? Is it not enough to create an instance of the object populating just the primary key field and then call session.delete() on that object. i.e. does Hibernate require that all fields in the object are fully populated before it can delete the corresponding db record? I have noticed that this is the case with my application recently.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 12, 2005 6:05 pm 
Newbie

Joined: Tue Feb 08, 2005 6:16 pm
Posts: 5
Quote:
does Hibernate require that all fields in the object are fully populated before it can delete the corresponding db record? I have noticed that this is the case with my application recently.


Have you solved this one? I tried to delete by only populating the identifier. It complaines the not-null properties, I then faked these not-null properties with some random values. It then went ahead deleted the record. Any insight why Hibernat needs to check the not-null thing before doing delete? Thanks.



[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 3:44 am 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Yeah, I discovered that so long as the identifier is correct you can populate the other fields with dummy values and the delete works okay then. Seems a bit odd though.


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.