-->
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: Delete an object with non-nullable fields
PostPosted: Sun Aug 19, 2007 10:21 am 
Newbie

Joined: Thu Oct 19, 2006 4:28 am
Posts: 2
Hello,

I want to delete an object using its ID.

I do :

Code:
Book book = new Book();
book.setId(new Long(1));
getHibernateTemplate().delete(book);


And I get the following exception :
Code:
"not-null property references a null or transient value"


Where does-it come from ? I am forced to refresh the object before deleting it ? What is the better way to delete an object with it's ID ?

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 19, 2007 4:57 pm 
Newbie

Joined: Sat Jul 28, 2007 7:24 am
Posts: 8
What you should do is to session.load an object with the specified id. This returns a proxy obect without hitting a database, and then you can use session.delete() with the proxy as the argument. Should work.


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.