-->
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.  [ 1 post ] 
Author Message
 Post subject: Interceptor and Transaction receiving a AssertionFailure
PostPosted: Tue Jul 24, 2007 6:34 am 
Newbie

Joined: Tue Jul 24, 2007 5:55 am
Posts: 1
Hibernate version: Hibernate 3.2

Hi,

I am using spring to manage the transaction this way:

Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
         <ref local="dataSource" />
      </property>


and I am using an interceptor.

The interceptor is meant to do somework when a certain object is stored in the database.

Part of this work is retrieve some other objects from the database.

When I try to store the object using just the DAO the interceptor is called and does the work properly.

But when I try to store the object using a manager as TransactionProxyFactoryBean like this:

Code:
<bean id="mockJournalManager" parent="baseManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      <property name="target">
         <bean class="MockJournalManager">
            <property name="journalDAO">
               <ref bean="journalDAO" />
            </property>
         </bean>
      </property>
      <property name="transactionAttributeSource" ref="mockJournalManagerTxAttrSource" />
   </bean>
   
   <bean id="mockJournalManagerTxAttrSource" lazy-init="true"
      class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
      <property name="properties">
         <props>
            <prop key="storeJournal">PROPAGATION_REQUIRED</prop>
         </props>
      </property>
   </bean>


I received an AssertionFailure like this:

Code:

org.hibernate.AssertionFailure: null id in Journal entry (don't flush the Session after an exception occurs)
   at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:55)
   at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:157)
   at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
   at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
   at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1562)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
   ...


I understand that when the code of the interceptor tries to retrieve an object hibernate autoflush and then tries to store the object that has triggered the interceptor and for some reason this object this does not work properly.

It is important that the object that triggers the interceptor and the code done by the interceptor to be commited or rolledback together.

If it could help I do not need the object stored in the database for the code of the interceptor. I only need that the code of the interceptor be triggered when the object is stored.

The object to be stored is an insert and not an update.

Thank you

David

EDIT: Adding more code for the Manager declaration:

Code:

<bean id="baseManager" lazy-init="true">
      <property name="transactionManager" ref="transactionManager" />
      <property name="transactionAttributeSource" ref="managerTxAttrSource" />
      <property name="postInterceptors" ref="diagnosticsInterceptor" />
   </bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory">
         <ref local="sessionFactory" />
      </property>
   </bean>



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.