-->
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: Saving Policies For Hibernate
PostPosted: Fri May 26, 2006 12:30 pm 
Beginner
Beginner

Joined: Mon Jun 06, 2005 6:48 pm
Posts: 45
Is there a way to tell hibernate not to save a column if the value in the hibernate object is a null and the current value in the column is not null?


Also, along the same lines if you have a complex object and one of the attributes which is a class that represents a table is a null I would assume the table entry creation (insert) would not happen?

Thanks,
-Tony


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 10:55 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
1) No, but you can simulate it by either putting the logic in your set method ("if (param == null && field != null) return;") or using a stored proc to do your save (see ref docs section 16.4).

2) Yes, associations with null values do not cause inserts. The only exception that I can think of is value collections (collections containing <element> rather than associations): if there is a null element in the collection, and if the element isn't not-null="true", then a row will be inserted into the collection's table, and it will contain null.

_________________
Code tags are your friend. Know them and use them.


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.