TypeDef not working with EntityManager but working with SessionFactory

Hi Team

We are trying to use TypeDef annotation to apply custom encryption / decryption for a set of fields. This is working perfectly with SessionFactory but not with EntityManager approach.

Is there any additional configuration or jar that needs to be included to make it work with EntityManager approach ?

Since spring has issues scanning package-info.java, we have moved the @TypeDefs to all entity classes.

If you define the @TypeDef at entity class level, it should work just fine with JPA too.

Hi vlad,
Yes, we moved the @TypeDefs to entity clases. However, they doesnt seem to be scanned.

We also tried with a small spring-boot-jpa project and observed the same issue

Hi vlad,

Some update.

The issue was resolved in EntityManager approach when we moved the @Type annotation on the getter method.

With sessionFactory it worked when the @Type was defined on the field or the getter method.

So, we’ve decided to move all @TypeDefs to entity class and @Type to getter methods