I created a simple test case to demonstrate this problem and attached it (TestJPAConverters.zip). I used the in-memory database HSQLDB so that it is completely self-contained. When I persist a simple entity with recognized property types and no @Convert types, everything works fine. When I persist a more complex entity containing a non-standard property type with an @Converter specified with @Convert, it fails to persist with the following error:
org.hsqldb.HsqlException: incompatible data type in conversion
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.types.CharacterType.convertToDefaultType(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.setParameter(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.setBytes(Unknown Source)
at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$1.doBind(VarbinaryTypeDescriptor.java:62)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:281)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:276)
at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:56)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2793)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2768)
at org.hibernate.persister.entity.AbstractEntityPersister$4.bindValues(AbstractEntityPersister.java:2975)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2982)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3494)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:97)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:364)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:205)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:185)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:169)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:322)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:84)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:209)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:152)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:79)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:854)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:828)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:832)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:996)
at net.nicholaswilliams.java.TestClass.persistComplexEntities(TestClass.java:90)
at net.nicholaswilliams.java.TestClass.main(TestClass.java:135)
I set an exception breakpoint for this exception with this message. When I hit the breakpoint, I navigated to the highest Hibernate method on the stack: org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$1.doBind(VarbinaryTypeDescriptor.java:62). In that method, the javaTypeDescriptor is an org.hibernate.type.descriptor.java.SerializableTypeDescriptor, which is not correct. Hibernate is trying to serialize the type instead of using the @Converter javax.persistence.AttributeConverter specified with the @Convert annotation on the property.
Is there any way we can get this fixed by 4.3.0.Beta3? Frustrating that I can't try these out yet.
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
I created a simple test case to demonstrate this problem and attached it (TestJPAConverters.zip). I used the in-memory database HSQLDB so that it is completely self-contained. When I persist a simple entity with recognized property types and no @Convert types, everything works fine. When I persist a more complex entity containing a non-standard property type with an @Converter specified with @Convert, it fails to persist with the following error:
I set an exception breakpoint for this exception with this message. When I hit the breakpoint, I navigated to the highest Hibernate method on the stack: org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$1.doBind(VarbinaryTypeDescriptor.java:62). In that method, the javaTypeDescriptor is an org.hibernate.type.descriptor.java.SerializableTypeDescriptor, which is not correct. Hibernate is trying to serialize the type instead of using the @Converter javax.persistence.AttributeConverter specified with the @Convert annotation on the property.
Is there any way we can get this fixed by 4.3.0.Beta3? Frustrating that I can't try these out yet.