-->
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: why the oldStates is null when i use eventListeners
PostPosted: Wed Apr 18, 2012 9:56 pm 
Newbie

Joined: Wed Apr 18, 2012 9:43 pm
Posts: 1
I want to get the old values after a jdbc update ;
so I use the eventListerner to listern post-update event but the oldstates i get was always null;
why? my hibernate version is 3.2

this is my code:

public class MyListener extends DefaultLoadEventListener
2. implements PostUpdateEventListener {
3.
4. public void onPostUpdate(PostUpdateEvent event) {
5. System.out.println(event.getEntity().getClass().getName()+":更新完毕");
6. for (int i = 0; i < event.getState().length; i++) {
7. // old values
8. Object oldValue = event.getOldState()[i]; //why it always null!!!!!!
9. // new values
10. Object newValue = event.getState()[i];
11. //property name
12. String propertyName = event.getPersister().getPropertyNames()[i];
13. }
14. }
15. }


my config:
<bean id="sessionFactory"
2. class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
3. ...
4. <property name="eventListeners">
5. <map>
6. <entry key="post-update">
7. <ref bean="myListener" />
8. </entry>
9. </map>
10. </property>
11. ...
12. </bean>
<bean id="myListener" class="com.app.common.util.hibernateSupport.MyListener">


no matter the pre-update or post-update the oldSates was always null.
Could you please help me! Thanks very much!


Top
 Profile  
 
 Post subject: Re: why the oldStates is null when i use eventListeners
PostPosted: Thu Feb 14, 2013 7:13 am 
Newbie

Joined: Thu Jan 03, 2013 9:09 am
Posts: 3
hello

have you found any answer to your problems ?

Btw , i have this post... if you have any idea ... :)
https://forum.hibernate.org/viewtopic.php?f=1&t=1025393

Thanks


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.