Announcement Announcement Module
Collapse
No announcement yet.
IdTransferringMergeEventListener problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IdTransferringMergeEventListener problem

    hi,
    i'm using hibernate 3.2.5 ga, spring 2.0.
    i have a org.springframework.jdbc.datasource.DriverManagerD ataSource datasource registered and in my session factory i have also registered :
    Code:
    <property name="eventListeners">
    			<map>
    				<entry key="merge">
    					<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
    				</entry>
    			</map>
    		</property>
    also in my spring context i have this :
    Code:
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
    	    <property name="sessionFactory"><ref bean="sessionFactory"/></property>
    	</bean>
    i have a problem with an entity of this form:
    A{
    id,
    value,
    B{
    id
    }
    }

    this A entity is binded in my command object, and when i make a request i pass the B.id parameter which changes the B.id in the command binded A entity.
    Then when i do a A.merge() i get this :
    Code:
    identifier of an instance of com.domain.Denomination was altered from 102 to 104; nested exception is org.hibernate.HibernateException: identifier of an instance of com.domain.Denomination was altered from 102 to 104
    
    org.springframework.orm.hibernate3.HibernateSystemException: identifier of an instance of com.domain.Denomination was altered from 102 to 104; nested exception is org.hibernate.HibernateException: identifier of an instance of com.domain.Denomination was altered from 102 to 104
    at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:659)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:690)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:566)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:319)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy44.enableAutomatic(Unknown Source)
    at com.controllers.EnableAutomaticController.onSubmit(EnableAutomaticController.java:179)
    i read on the forums that for the identifier in database you have int and in java you have long; well...that wasn't my case...i tried and nothing.
    And then i read the api of HibernateTemplate.merge() that says like this:
    Code:
    Note that merge will not update the identifiers in the passed-in object graph (in contrast to TopLink)! Consider registering Spring's IdTransferringMergeEventListener if you would like to have newly assigned ids transferred to the original object graph too.
    well, the B.id has modified and according to the merge() API the new B.id sould be copied too when the A.merge() is called, because i have a IdTransferringMergeEventListener registered in my session factory;

    but, i doesn't work;
    and it is curios that if i use JTATransactionManager it doesn't say a word. So my guess is tthis HibernateTransactionManager is behaving badly; i hope i'm not right.

    so, how can i merge entity A with the B.id modified , and not getting this error?

    thanks,
    Viorel
Working...
X