是否有人设法对DataNucleus使用@Convert注释?您有可行的示例或文档链接吗?

我试图以这种方式实施

...
@Convert(converter = MyAttributeConverter.class)
private String[] aField;
...


MyAttributeConverter实现javax.persistence.jpa21.AttributeConverter<String[], String>

当我运行DataNucleus Enhancer时出现此错误

WARN [main] (Log4JLogger.java:96) - Class "XXX" has an annotation "javax.persistence.jpa21.Convert" specified with property "converter" yet this is invalid. Please check the specification for that annotation class. Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
ERROR [main] (Log4JLogger.java:125) - DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details org.datanucleus.exceptions.NucleusUserException: Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
    at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:536)
    ...


根据DataNucleus的文档,它看起来不错:http://www.datanucleus.org/products/accessplatform/jpa/annotations.html#Convert,尽管在​​谷歌搜索中我发现了一个问题报告,其中的内容有些不同:http://www.datanucleus.org/servlet/jira/browse/NUCJPA-164

我正在使用DataNucleus 3.1.3。

最佳答案

样品在http://datanucleus.svn.sourceforge.net/viewvc/datanucleus/test/accessplatform/trunk/test.jpa.general/src/java/org/jpox/samples/typeconversion/下进行测试
http://datanucleus.svn.sourceforge.net/viewvc/datanucleus/test/accessplatform/trunk/test.jpa.general/src/test/org/datanucleus/tests/TypeConversionTest.java?revision=16466&view=markup

关于java - @在DataNucleus中转换,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14582431/

10-13 21:27