Search code examples
xmljpaormannotationseclipselink

Eclipselink mixing annotation and xml


My target is to save some converters & named queries declaration in eclipselink-orm.xml. and use the annotation @convert within entities implementation, call the named queries inside EJB.

  • List item : <converter name="date-time-converter" class="domaine.dateTimeConverter/>

  • annotation @convert("date-time-converter")

eclipse shows me an error : The attribute value is undefined for the annotation type Convert

how to implement it ?


Solution

  • The annotation @Convert does not have an attribute "value". You need to define the "converter" attribute, as

    @Convert(converter=DateTimeConverter.class)
    MyDateTime dateTime;
    

    as per the javadocs for JPA 2.1. You can see use of JPA AttributeConverter on this link. The @Converter is to define whether it is autoApply. If so, then you don't need the @Convert against a field. The same applies if using orm.xml