Search code examples
jakarta-eejpa-2.0openjpa

OpenJPA: extend valuehandler for enums


I want to overwrite the enum value handler from openJpa because I want to add some custom functionality to it. Does anybody know how to do it?

I cannot find a parameter where I can configure which valuehandler OpenJpa uses for enum fields. For string or integer fields I can specify a custom valuehandler with the FieldStrategy parameter but for enum field it doesn't work.

I know I can specify a custom strategy for every single field in my entity by using the @Strategy annotation. It works great but I am looking for a more general solution because I do not want to annotate every single field in my datamodel.


Solution

  • To whom it may concern ;-)

    I debugged the source code of OpenJpa Source and it seems that it is not possible to implement a FieldStrategy for enums. I didn't searched in OpenJpa Jira but if it is not a bug yet, it should be one.

    Finally I solved this problem by providing a custom valueHandler and annotate every enum field with the @Strategy annotation.