Announcement Announcement Module
Collapse
No announcement yet.
Error using BeanNameAutoProxyCreator and Hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error using BeanNameAutoProxyCreator and Hibernate

    When I use BeanNameAutoProxyCreator, defined as:

    Code:
        <bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager" >        
            <property name="sessionFactory">
                <ref bean="hibernateSessionFactory" />
            </property>
        </bean>
        
        <bean id="matchAllWithPropReq" class="org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource">
            <property name="transactionAttribute"><value>PROPAGATION_REQUIRED</value></property>
        </bean>
        <bean id="matchAllTxInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
            <property name="transactionManager"><ref bean="myTransactionManager"/></property>
            <property name="transactionAttributeSource"><ref bean="matchAllWithPropReq"/></property>
        </bean>
    
        <!-- One BeanNameAutoProxyCreator handles all beans where we want all methods to use PROPAGATION_REQUIRED -->
        <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
            <property name="interceptorNames">
                <list>
                    <idref local="matchAllTxInterceptor"/>
              </list>
            </property>
            <property name="beanNames">
                <list>
                    <idref local="modificaCommessaController"/>
                </list>
            </property>
        </bean>
    I get the following error, using the SaveOrUpdate method; if I don't use AOP to manage transactions, there is no problem (I'm using Spring 1.1.4 and Hibernate 2.1.7).
    Any help?

    Thanks,
    Luigi


    Code:
    org.springframework.orm.hibernate.HibernateSystemException&#58; a different object with the same identifier value was already associated with the session&#58; 174, of class&#58; comm.domain.fatturazione.Commessa; nested exception is net.sf.hibernate.NonUniqueObjectException&#58; a different object with the same identifier value was already associated with the session&#58; 174, of class&#58; comm.domain.fatturazione.Commessa
    	org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException&#40;SessionFactoryUtils.java&#58;613&#41;
    	org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException&#40;HibernateAccessor.java&#58;234&#41;
    	org.springframework.orm.hibernate.HibernateTemplate.execute&#40;HibernateTemplate.java&#58;317&#41;
    	org.springframework.orm.hibernate.HibernateTemplate.saveOrUpdate&#40;HibernateTemplate.java&#58;529&#41;
    	comm.persistence.fatturazione.CommessaDAOImpl.modifica&#40;CommessaDAOImpl.java&#58;117&#41;
    	comm.service.fatturazione.CommessaManagerImpl.modifica&#40;CommessaManagerImpl.java&#58;69&#41;
    	comm.web.controller.fatturazione.CommessaModificaFormController.onSubmit&#40;CommessaModificaFormController.java&#58;336&#41;
    	org.springframework.web.servlet.mvc.SimpleFormController.onSubmit&#40;SimpleFormController.java&#58;298&#41;
    	org.springframework.web.servlet.mvc.SimpleFormController.onSubmit&#40;SimpleFormController.java&#58;273&#41;
    	org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission&#40;SimpleFormController.java&#58;224&#41;
    	org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal&#40;AbstractFormController.java&#58;230&#41;
    	org.springframework.web.servlet.mvc.AbstractController.handleRequest&#40;AbstractController.java&#58;128&#41;
    	sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
    	sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
    	java.lang.reflect.Method.invoke&#40;Method.java&#58;324&#41;
    	org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection&#40;AopUtils.java&#58;282&#41;
    	org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint&#40;ReflectiveMethodInvocation.java&#58;155&#41;
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed&#40;ReflectiveMethodInvocation.java&#58;122&#41;
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke&#40;TransactionInterceptor.java&#58;56&#41;
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed&#40;ReflectiveMethodInvocation.java&#58;144&#41;
    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke&#40;JdkDynamicAopProxy.java&#58;174&#41;
    	$Proxy0.handleRequest&#40;Unknown Source&#41;
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle&#40;SimpleControllerHandlerAdapter.java&#58;44&#41;
    	org.springframework.web.servlet.DispatcherServlet.doDispatch&#40;DispatcherServlet.java&#58;595&#41;
    	org.springframework.web.servlet.DispatcherServlet.doService&#40;DispatcherServlet.java&#58;543&#41;
    	org.springframework.web.servlet.FrameworkServlet.serviceWrapper&#40;FrameworkServlet.java&#58;390&#41;
    	org.springframework.web.servlet.FrameworkServlet.doPost&#40;FrameworkServlet.java&#58;350&#41;
    	javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;709&#41;
    	javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
Working...
X