有没有人设法在DataNucleus中使用@Convert注释?您是否有可用的示例或文档链接?
我试着这样实现它。
...
@Convert(converter = MyAttributeConverter.class)
private String[] aField;
...MyAttributeConverter实现了javax.persistence.jpa21.AttributeConverter<String[], String>。
当我运行DataNucleus增强器时,我得到这个错误
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。
发布于 2013-09-14 15:01:49
同时,我升级到datanucleus-accessplatform-jpa-rdbms 3.3.2 (datanucleus-core 3.2.7,datanucleus-api-jpa 3.3.2)并使其正常工作。
但这条信息可能有多种原因:
转换器可以是从另一个类继承的classpath.
javax.persistence.jpa21.AttributeConverter (较旧版本),但增强器使用的是javax.persistence.AttributeConverter (较新版本)或相反的情况。我认为错误消息应该更具体一点,以帮助您更好地识别问题。
发布于 2013-01-29 21:50:27
样本正在http://datanucleus.svn.sourceforge.net/viewvc/datanucleus/test/accessplatform/trunk/test.jpa.general/src/test/org/datanucleus/tests/TypeConversionTest.java?revision=16466&view=markup上进行http://datanucleus.svn.sourceforge.net/viewvc/datanucleus/test/accessplatform/trunk/test.jpa.general/src/java/org/jpox/samples/typeconversion/和测试
https://stackoverflow.com/questions/14582431
复制相似问题