-->
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: Inspecting whether an entity has changed its state
PostPosted: Thu Jan 10, 2008 7:32 am 
Beginner
Beginner

Joined: Mon Apr 02, 2007 8:08 am
Posts: 24
I know Hibernate detects whether an entity has changed its state or not. How does he do it? Cglib? How can I detect it?

_________________
--
<a href="http://ideasse.blogspot.com/">Ideas + Software Engineering</a> (English)
<a href="http://iiso.blogspot.com/">Ideas + IngenierĂ­a del Software</a> (Spanish)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 12:25 pm 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
You can get informed by Hibernate if you write an Interceptor. For example see this:

Code:
public class HistoryInterceptor extends EmptyInterceptor {

(...)
public boolean onFlushDirty(final Object pEntity,
                              final Serializable pId,
                              final Object[] pCurrentState,
                              final Object[] pPreviousState,
                              final String[] pPropertyNames,
                              final Type[] pTypes) throws CallbackException {
// do something
}


There are other methods you might override, if needed. Have a look into the docs and Hibernate's source.
And: be aware that you are restricted in what you can (not) do in the interceptor!

Carlo


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 12:53 pm 
Beginner
Beginner

Joined: Mon Apr 02, 2007 8:08 am
Posts: 24
Thanks for your response. We followed your suggestion of looking inside the code (attatching source code to binary jars for debugging is priceless!). Finally we managed to do it with _post_ events. Post events are triggered only after effective database comunication.

_________________
--
<a href="http://ideasse.blogspot.com/">Ideas + Software Engineering</a> (English)
<a href="http://iiso.blogspot.com/">Ideas + IngenierĂ­a del Software</a> (Spanish)


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.