-->
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: onPrepareStatement called twice on batch update statements
PostPosted: Tue Jun 16, 2009 5:23 am 
Newbie

Joined: Tue Jun 16, 2009 4:39 am
Posts: 2
Hi All,

I have 2 questions.

1) I've been playing with hibernate interceptors and I noticed that on batch statements the interceptor's onPrepareStatement gets called twice! Is this the normal behavior? If I want to register such an event only once what is the best way to do it (given a multi-threaded environment)?

2) While writing unit tests, I am extending AbstractTransactionalJUnit4SpringContextTests so as to not dirty my database with my tests, the events are fired upon session flush and issuing a roll back seems to exclude some events (mainly onCollectionUpdate for entities that didn't exist before). I tried using an in memory database and running setup scripts at the beginning but I assume this will be a PITA when the schema gets more and more complicated. Is there any other way to do this ?

I am using an EmptyInterceptor implementation that implements all onXXX methods this way:

Code:
public String onPrepareStatement(String sql) {
   log.trace("onPrepareStatement statement:\n"+sql);
   return super.onPrepareStatement(sql);
}


the interceptor is attached to the session factory as follows:

Code:
<bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
      <property name="dataSource" ref="dataSource"/>
      <property name="mappingResources">
         <list>
            ...
         </list>
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.show_sql">true</prop>         
         </props>
      </property>      
      <property name="entityInterceptor">
         <bean class="com.mycompany.play.EmptyLoggingInterceptor"/>
      </property>
</bean>


Top
 Profile  
 
 Post subject: Re: onPrepareStatement called twice on batch update statements
PostPosted: Wed Jun 17, 2009 2:35 am 
Newbie

Joined: Tue Jun 16, 2009 4:39 am
Posts: 2
Any idea about this anyone ?


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.