Java @在DataNucleus中转换

Java @在DataNucleus中转换,java,jpa,datanucleus,Java,Jpa,Datanucleus,有人设法将@Convert注释用于DataNucleus吗?您是否有工作示例或文档链接 我试图以这种方式实现它 ... @Convert(converter = MyAttributeConverter.class) private String[] aField; ... MyAttributeConverter实现了javax.persistence.jpa21.AttributeConverter 当我运行DataNucleus增强器时,我得到了这个错误 WARN [main] (Log

有人设法将@Convert注释用于DataNucleus吗?您是否有工作示例或文档链接

我试图以这种方式实现它

...
@Convert(converter = MyAttributeConverter.class)
private String[] aField;
...
MyAttributeConverter
实现了
javax.persistence.jpa21.AttributeConverter

当我运行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文档,这似乎很好:,尽管在Google上我发现了一个问题报告,其中的内容有点不同:

我正在使用DataNucleus 3.1.3。

样本正在进行测试

同时,我升级到了datanucleus accessplatform jpa rdbms 3.3.2(datanucleus core 3.2.7,datanucleus api jpa 3.3.2),并使其正常工作

但这一信息可能有多种原因:

  • 类路径中可能缺少转换器类
  • 您的转换器可以从另一个类继承-请参阅我的另一个问题(尚未回答)
  • 转换器实体类型和使用@Convert注释的字段类型之间可能不兼容
  • 版本之间可能存在不兼容。例如,您的转换器可以实现
    javax.persistence.jpa21.AttributeConverter
    (旧版本),但增强器使用的是
    javax.persistence.AttributeConverter
    (新版本)或其他方法

我认为错误消息应该更具体一点,以帮助您更好地识别问题

我做了同样的事情,但正如你从我上面的问题中看到的,它不起作用。显然在我们的例子中,它起作用了,每次运行任何测试时都会运行它。您的建议是查看嵌套异常,因此只有您知道异常从何处抛出,因此您可以查看代码行,了解为什么这可能是因为检查样本的测试用例是一个不可思议的想法!请您帮助查找
JDO/RDBMS
的测试用例好吗?我似乎只点击了
JPOX
samples!