JPA converter and subclasses

I tried to use JPA converter with subclass, ie a converter class that extends as class which implements
javax.persistence.AttributeConverter.
Unfortunately, it doesn’t work. See EclipseLink JPA converter subclasses doesn't work - Stack Overflow

Has anybody used JPA converter with subclasses ? What shall be done to make it work ?

Hi,

First I was confused and I thought you wanted the converter to use subclasses of the type used in the entity.

It seems indeed that EclipseLink only takes the converter if the class itself has the AttributeConverter interface defined. Initially Hibernate worked the same but after this report [HHH-8854] Could not extract ParameterizedType representation of AttributeConverter definition - Hibernate JIRA they changed the behaviour.

So you can use either Hibernate (add it to your web application and change the classloader hierarchy in Payara to application first) or/and you could report this behaviour as EclipseLink issue Issues · eclipse-ee4j/eclipselink · GitHub.

regards
Rudy

Thank you Rudy !
An easy workaround to this “bug” is to add the interface AttributeConverter to the class itself. It’s useless as the base class implements it but it solves the problem. Thanks to sed, I was able to do it smoothlessly.

As you say, Hibernate doesn’t need the extra implements in the subclass.

Rudy, I suggest you answer the Stackoverflow question and I will give you credit for that.

regards.