-->
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.  [ 1 post ] 
Author Message
 Post subject: isDirty() always returns false for a change to null
PostPosted: Wed Jul 06, 2005 1:45 pm 
Newbie

Joined: Wed Jul 06, 2005 1:33 pm
Posts: 1
Hi,

I've got a POJO I'm persisting using using Hibernate 3.05. If I do the following

Code:
pojo = session.get(MyPojo.class, 3);
assertNull(pojo.getBirthday());
pojo.setBirthday(today);
session.flush();


then nothing gets flushed. The debug logs shows zero dirty objects.

I've traced this through to DefaultFlushEntityEventListener.dirtyCheck() which calls BasicEntityPersister.findDirty(), which calls TypeFactory.findDirty() which , for my property calls DateType.isDirty(), which is inherited from AbstractType.

The final code looks like this...

Code:
return x==y || ( x!=null && y!=null && x.equals(y) );


So if either the original or the new value is null, then the object is not considered dirty! But it is dirty, because I've just changed a property!

To me this seems like a bad default. Can anyone defend it. (I'm new to hibernate, btw)

Is there any way to solve this other than implementing my own interceptor?

Thanks for reading.

David


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.