-2

Is DataNucleus (latest 5.1.1) JPA 2.1 compliant?

JPA 2.1 supports @Converter. But DataNucleus has its own way (as extension) ignoring JPA standard:

http://www.datanucleus.org/documentation/extensions/type_converter.html

UPDATE

The same code with AttributeConverter works for EclipseLink, but failed with DataNucleus.

@Converter(autoApply=true)
public class FooConverter implements AttributeConverter<Foo, String> {

    @Override
    public String convertToDatabaseColumn(Foo attribute) {
                ....
    }

    @Override
    public Foo convertToEntityAttribute(String value) {
        ...
    }

}


@Entity
public class Bar {

      @Convert(converter=FooConverter.class) 
      public Foo getFoo() {
           ...
      }

      public void setFoo(Foo foo) {
           ...
      }

}

Error:

org.datanucleus.exceptions.NucleusUserException: Identifier hello.world is unresolved (not a static field)
        at org.datanucleus.query.expression.PrimaryExpression.bind(PrimaryExpression.java:215)
        at org.datanucleus.query.expression.DyadicExpression.bind(DyadicExpression.java:131)
        at org.datanucleus.query.expression.DyadicExpression.bind(DyadicExpression.java:131)
        at org.datanucleus.query.expression.DyadicExpression.bind(DyadicExpression.java:89)
        at org.datanucleus.query.compiler.JavaQueryCompiler.compileFilter(JavaQueryCompiler.java:617)
        at org.datanucleus.query.compiler.JPQLCompiler.compile(JPQLCompiler.java:86)
        at org.datanucleus.store.query.AbstractJPQLQuery.compileGeneric(AbstractJPQLQuery.java:304)
        at org.datanucleus.store.query.AbstractJPQLQuery.compileInternal(AbstractJPQLQuery.java:365)

The 'hello.world' in error message is the string value of Foo.

eastwater
  • 4,624
  • 9
  • 49
  • 118
  • User *now* has some query apparently (undisclosed what the query is) and gets some error ... who knows what is the problem with that. AttributeConverters are used in persisting data, and retrieving it. Looking at the log on your persist you would see that it is used. I see nothing in the new question (stack trace) that refers to AttributeConverter – Neil Stockton Aug 17 '17 at 15:52
  • I suspect the converter is ignored. – eastwater Aug 17 '17 at 16:41
  • If you suspect something then you DEMONSTRATE that thing by providing the JPA provider with a testcase, and report a problem. Just throwing about suspicions with no details (like what query) really doesn't help anyone – Neil Stockton Aug 17 '17 at 16:54

1 Answers1

0

DataNucleus supports JPA 2.1 AttributeConverter, as their docs tell you. It also allows you to inject state into them (JPA 2.2). AKA Compliant with all JPA specs around. So I have absolutely no idea what is this "ignoring JPA standard" thing.

DataNucleus also provides access to its own (internal) mechanism for value adding, which you refer to.

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29