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: Checking "dirty" state of an object
PostPosted: Wed Mar 22, 2006 5:50 pm 
Beginner
Beginner

Joined: Mon Dec 06, 2004 4:20 pm
Posts: 34
Hibernate version: 3.0.5

So it appears that it's just not possible to tell if an object has been changed when doing a save. I have a Web application that uses detached objects, and have written an interceptor for "onFlushDirty". My save method looks like this:

Code:
public PersistentObject save(PersistentObject persistentObject)
throws EosException {
       Transaction tx = null;
   try {
      tx = session.beginTransaction();
      session.saveOrUpdate(persistentObject);
      session.flush();
      tx.commit();
      }
        catch(...) { ...}
}


The problem is, when the onFlushDirty method is called, the "previousState" array is null. I have a lot of model objects in my application, and the number continues to grow - I certainly don't want to implement setDirty(true) in every set method. So, apart from AspectJ, does anyone have any ideas? Am I missing something?

Thanks,

Don


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 8:30 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Use Extended Session scope.


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.