有没有人设法在 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。
最佳答案
sample 在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 中的@Convert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14582431/