Back Forum Reply New

FLUSH EAGEL and rollback

Hi,
  I have a problem with rollback and FLUSH EAGEL.
  My problem is, I change the flush mode for HibernateTemplate to FLUSH EAGEL, and I have a manager that actually some tables in the same method, when method throw a Exception, the tables that have been changed no rollback.
   I'm using spring 2.0 with AOP for manage transactions. My AOP configuration is:Code:
lt;bean id=quot;txManagerquot; class=quot;org..orm.hibernate3.HibernateTransactionManagerquot;gt;     lt;property name=quot;sessionFactoryquot;gt;         lt;ref bean=quot;sessionFactoryquot;/gt;     lt;/propertygt; lt;/beangt;
lt;aop:configgt;       lt;aop:pointcut id=quot;operationquot; expression=quot;execution(* x.y.m.*.IManager*.*(..))quot;/gt;       lt;aop:advisor pointcut-ref=quot;operationquot; advice-ref=quot;txAdvicequot;/gt; lt;/aop:configgt;
lt;tx:advice id=quot;txAdvicequot; transaction-manager=quot;txManagerquot;gt;   lt;!-- the transactional semantics... --gt;   lt;tx:attributesgt;     lt;tx:method name=quot;get*quot; read-only=quot;truequot; propagation=quot;REQUIREDquot; /gt;     lt;tx:method name=quot;select*quot; read-only=quot;truequot; propagation=quot;REQUIREDquot; /gt;     lt;tx:method name=quot;*quot; propagation=quot;REQUIREDquot; /gt;   lt;/tx:attributesgt; lt;/tx:advicegt;    Thanks

Can we see the code that you are having problems with, and what is quot;FLUSH EAGELquot;?

Thanks for your reply, I'm sorry, is FLUSH_EAGER.
   I post the method defined in my transactional manager, ped is a object that I obtain for the ddbb for your update. In the method I want update CPed and CLin.Code:    public void updatePed(CPed ped, Long cant, String desc) {    try {      // Update ped      ped.setDesc(desc);      ped.setDate(new Date());
      // Update lins for ped      List lins = ped.getLins();      if (lins.isEmpty() == false) {          for (int i = 0; i lt; lins.size(); i++) {    CLin lin = (CLin) lins.get(i);    lin.setCant(cant);    managerLin.updateLin(lin);          }      }
      // Force error      daoPed.updatePed(null);    } catch (Exception e) {      throw new RuntimeException(quot;Errorquot;, e);     }  }  When I force the error, CPed y CLin are update in the ddbb, no rollback is apply for this objects, but in the log rollback is write. Can FLUSH_EAGER is the problem?.
  Thanks.

Can we see all of the applicationContext and the rest of the code.  There seems to be some missing e.g. daoPed, managerLin etc...

Hi,
      I work in zip file with the code and sortly attachmend in a post.
   Thanks for yours reply.

mons.dbcp.PoolableConnection@c2ea0b]
23/11/2006 22:24:52,799 DEBUG [HibernateTemplate] Found thread-bound Session for HibernateTemplate
23/11/2006 22:24:52,819 DEBUG [HibernateTemplate] Eagerly flushing Hibernate session
23/11/2006 22:24:52,819 DEBUG [HibernateTemplate] Not closing pre-bound Hibernate Session after HibernateTemplate
23/11/2006 22:24:52,819 DEBUG [HibernateTransactionManager] Triggering beforeCommit synchronization
23/11/2006 22:24:52,819 DEBUG [HibernateTransactionManager] Triggering beforeCompletion synchronization
23/11/2006 22:24:52,819 DEBUG [HibernateTransactionManager] Initiating transaction commit
23/11/2006 22:24:52,819 DEBUG [HibernateTransactionManager] Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@1c20de3]
23/11/2006 22:24:52,819 DEBUG [HibernateTransactionManager] Triggering afterCommit synchronization
23/11/2006 22:24:52,819 DEBUG [HibernateTransactionManager] Triggering afterCompletion synchronization
23/11/2006 22:24:52,819 DEBUG [HibernateTransactionManager] Not closing pre-bound Hibernate Session [org.hibernate.impl.SessionImpl@1c20de3] after transaction
23/11/2006 22:25:09,743 DEBUG [HibernateTransactionManager] Found thread-bound Session [org.hibernate.impl.SessionImpl@1c20de3] for Hibernate transaction
23/11/2006 22:25:09,753 DEBUG [HibernateTransactionManager] Using transaction object [org..orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@11d9f05]
23/11/2006 22:25:09,753 DEBUG [HibernateTransactionManager] Creating new transaction with name [x.y.manager.IManagerLin.getLin]
23/11/2006 22:25:09,753 DEBUG [HibernateTransactionManager] Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@1c20de3]
23/11/2006 22:25:09,783 DEBUG [HibernateTransactionManager] Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@c2ea0b]
23/11/2006 22:25:09,793 DEBUG [HibernateTemplate] Found thread-bound Session for HibernateTemplate
23/11/2006 22:25:09,833 DEBUG [HibernateTemplate] Eagerly flushing Hibernate session
23/11/2006 22:25:09,954 DEBUG [HibernateTemplate] Not closing pre-bound Hibernate Session after HibernateTemplate
23/11/2006 22:25:09,974 DEBUG [HibernateTransactionManager] Triggering beforeCommit synchronization
23/11/2006 22:25:09,974 DEBUG [HibernateTransactionManager] Triggering beforeCompletion synchronization
23/11/2006 22:25:09,974 DEBUG [HibernateTransactionManager] Initiating transaction commit
23/11/2006 22:25:09,974 DEBUG [HibernateTransactionManager] Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@1c20de3]
23/11/2006 22:25:09,974 DEBUG [HibernateTransactionManager] Triggering afterCommit synchronization
23/11/2006 22:25:09,974 DEBUG [HibernateTransactionManager] Triggering afterCompletion synchronization
23/11/2006 22:25:09,974 DEBUG [HibernateTransactionManager] Not closing pre-bound Hibernate Session [org.hibernate.impl.SessionImpl@1c20de3] after transaction   The rest for my configuration file is:Code:
  lt;bean id=quot;sessionFactoryquot; class=quot;org..orm.hibernate.LocalSessionFactoryquot;gt;     lt;property name=quot;dataSourcequot;gt;lt;ref bean=quot;dataSourcequot;/gt;lt;/propertygt;     lt;!-- Mapping files --gt;     lt;property name=quot;hibernatePropertiesquot;gt;      lt;ref local=quot;hibernatePropertiesquot; /gt;      lt;/propertygt;  lt;/beangt;
  lt;bean id=quot;hibernateTemplatequot; class=quot;org..orm.hibernate3.HibernateTemplatequot;gt;     lt;property name=quot;sessionFactoryquot;gt;       lt;ref bean=quot;sessionFactoryquot; /gt;     lt;/propertygt;     lt;property name=quot;flushModequot;gt;lt;valuegt;2lt;/valuegt;lt;/propertygt;  lt;/beangt;
  lt;bean id=quot;hibernateDaoSupportquot; abstract=quot;truequot; class=quot;org..orm.hibernate3.support.HibernateDaoSupportquot;gt;    lt;property name=quot;sessionFactoryquot;gt;lt;ref bean=quot;sessionFactoryquot; /gt;lt;/propertygt;    lt;property name=quot;hibernateTemplatequot;gt;lt;ref bean=quot;hibernateTemplatequot; /gt;lt;/propertygt;  lt;/beangt;
  lt;bean id=quot;txManagerquot; class=quot;org..orm.hibernate3.HibernateTransactionManagerquot;gt;    lt;property name=quot;sessionFactoryquot;gt;lt;ref bean=quot;sessionFactoryquot;/gt;lt;/propertygt; lt;/beangt;
lt;!-- Daos and Managers are configured how normal beans, but daos has parent to hibernateDaoSupport --gt;  When I chage the flush mode to auto, don't update ped in my action.
  Thanks

Hi,
I soved my problem. I pass all the transactional logic to managers and works fine.
Thanks.
¥
Back Forum Reply New