-->
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: Set only non-null fields on update?
PostPosted: Thu Jun 19, 2008 12:21 pm 
Newbie

Joined: Wed Jun 18, 2008 8:41 am
Posts: 8
Hi,

Is there a way to specify that only non-null fields should be written to the DB on an update?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 12:35 pm 
Newbie

Joined: Wed Jun 18, 2008 8:41 am
Posts: 8
Nevermind, I just noticed the dynamic-update attribute. That fixed it up.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 1:13 am 
Newbie

Joined: Wed Jun 18, 2008 8:41 am
Posts: 8
Well, for some reason, the dynamic-update is no longer having any effect (maybe it never was in the first place and I am just going nuts? :) ).

Take this simple example:

Code:
    <class
       entity-name = "test"
       dynamic-update = "true">
       <id name="id" type="string"/>
       <property name="foo" type="string"/>
       <property name="bar" type="string"/>   
    </class>


Persisting this from an XML such as this:

Code:
    <test>
       <id>1</id>
       <foo>1</foo>
    </test>


causes the "bar" field to be updated, despite my dynamic-update setting.

What gives?!?

:(


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 1:25 am 
Newbie

Joined: Wed Jun 18, 2008 8:41 am
Posts: 8
(I am constructing a dialogue with myself in here, but oh well) ... so I guess the issue here is that the dynamic-update will update only those fields that have changed. That is not exactly what I want -- what I want is a way to update only those fields that are non-null.

Is there a way to do this with the mappings? Or do I have to introduce something programmatic?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 2:00 am 
Newbie

Joined: Wed Jun 18, 2008 8:41 am
Posts: 8
OK ... so more elaboration on this topic:

it seems like it would make sense for there to be an option that allows a detached object with an existing ID to be merged into the session as an update, but only updating non-null values.

I can imagine a number of scenarios where a small delta change is made, and only that delta is sent to the receiving application that holds the Hibernate session ... from there, it would be really nice to be able to do an update against only those fields that differ and are non-null.


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.