-->
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.  [ 3 posts ] 
Author Message
 Post subject: Dirty checking using hibernate API ?
PostPosted: Fri May 02, 2008 11:55 am 
Beginner
Beginner

Joined: Mon Mar 31, 2008 10:05 am
Posts: 20
Hi,

I'm using JPA backed by hibernate 3.2.6.

What I would like to do is discover whether a managed entity is dirty prior to flushing the session.

Does hibernate provide such an API ? To my knowledge, no. There is only a session.isDirty() which doesnt really help to tell whether a specific entity is dirty.

I looked at @PreUpdate entitylistener but this will only fire as hibernate flushes the session (which is too late for me). I also read abit about DefaultDirtyCheckEventListener, but this too seems to be bound to the session flush lifecycle event.

Any advice on this would be greatly appreciated,

Thanks,
-Guillaume


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 3:36 pm 
Newbie

Joined: Thu Jul 28, 2005 5:59 pm
Posts: 5
Location: Rio de Janeiro, Brazil
Hi.

Did you find a solution to your question?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 4:35 pm 
Beginner
Beginner

Joined: Mon Mar 31, 2008 10:05 am
Posts: 20
Hi,

That is the best I found but again this is only triggered as the flush is happening,

Hibernate does not expose a public API to query managed entity dirtyness at any point in time:

Quote:
public class LoggingInterceptor extends EmptyInterceptor {

private final Logger log = Logger.getLogger(getClass().getSimpleName());
/**
*
*/
private static final long serialVersionUID = -6046643915512943849L;

public LoggingInterceptor() {}

@Override
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
String[] propertyNames, Type[] types) {
log.info("Instance of:" + entity.getClass().getSimpleName() + " is found dirty, currentState:" + Arrays.deepToString(currentState) + ", previousState:" + Arrays.deepToString(previousState));
return false;
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.