| I've verified that version 4.3.11 does not have this behavior. I have a class Money that derives from BigDecimal. I have an entity Widget that has a field of type BigDecimal and another of type Money. If I create a simply MoneyConverter and annotate just the Money field of Widget, the conversion happens just fine. However, if instead, I annotate the MoneyConverter class with @Converter and set autoApply = true, Hibernate attempts to use the MoneyConverter for the field of type BigDecimal. This is an error. The attached project uses spring-boot. Execute mvn package and then jar -jar target/hibernate-conversion-0.0.1-SNAPSHOT.jar to see the error. The exception of interest is: Caused by: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to com.eclecticlogic.hibernate.demo.Money at com.eclecticlogic.hibernate.demo.CostConverter.convertToDatabaseColumn(CostConverter.java:23) at org.hibernate.type.descriptor.converter.AttributeConverterMutabilityPlanImpl.deepCopyNotNull(AttributeConverterMutabilityPlanImpl.java:29) In the project, comment out the @Converter annotation in MoneyConverter.java and then uncomment the @Convert annotation in Widget.java getCost() method. You will see that the project runs just fine. |