5 Replies Latest reply on Mar 30, 2010 7:10 AM by d0n0van

    @Type ignored?

    d0n0van

      I'm having a problem mapping a custom type with envers. I hope i forgot something.

       

       

      When i add "@NotAudited" to amount, everything works perfect.

       

       

      @Column(precision = 6, scale = 2)
      @Type(type="syndicus.domain.util.EuroType")
      private Euro amount = new Euro();
      
      

       

      When i merge, following exception occure

       

      java.lang.ClassCastException: syndicus.domain.util.Euro
           at org.hibernate.type.DoubleType.set(DoubleType.java:60)
           at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
           at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:131)
           at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2015)
           at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2261)
           at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
           at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
           at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
           at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
           at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
           at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
           at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
           at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
           at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:161)
           at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:274)
           at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:140)
           at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
           at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:456)
           at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)
           at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)
           at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
           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 $Proxy37.merge(Unknown Source)
      
        • 1. Re: @Type ignored?
          adamw

          Hello,

           

          this would need some debugging, hard to say what's happening right now. Custom types should work of course. Look at the CompositeCustomTypeEntity entity and CompositeCustom test. There, @Type is used and the test passes. I assume you're using newest Envers .

           

          Another thing to check is if BasicMetadataGenerator.addCustomValue is called.

           

          Adam

          • 2. Re: @Type ignored?
            d0n0van

            I forgot the give more info about version.

             

            Hibernate =  3.3.2-GA

             

            hibernate-entitymanager = 3.4.0.GA

             

            jboss-envers = 1.2.2.GA-hibernate-3.3

             

            spring = 2.5.6.SEC01

             

            Db = mysql

             

            I will try to setup a small maven test project.

             

            Attached simple test to the root question.

            • 3. Re: @Type ignored?
              d0n0van

              Attached simple test to the root question.

              • 4. Re: @Type ignored?
                adamw

                Can you please create a JIRA issue, and try to debug the test case to see if the methods called above work?
                Also, would be good to have a comparision with the test case that is in Envers already.

                 

                Adam

                • 5. Re: @Type ignored?
                  d0n0van

                  The method "BasicMetadataGenerator.addCustomValue" is not called.

                   

                  Found the problem

                   

                  EuroType extends org.hibernate.type.DoubleType => Not a org.hibernate.usertype.UserType

                   

                  Changing my implementation and fully implementing "org.hibernate.usertype.UserType" than it works and "BasicMetadataGenerator.addCustomValue" is called.

                   

                   

                  I wil send a JIRA, as soon svn hibernate-trunk(entitymanager) is buildable again.

                   

                  http://opensource.atlassian.com/projects/hibernate/browse/HHH-5048