XSD 架构 - JAXB 封送处理 - 数据存储(JPA/JDO)往返

2022-01-19 00:00:00 java jpa jaxb jdo

我正在尝试找到一种方法来完成 xsd 架构到数据存储的往返,而且工作量最小.

I'm trying to find a way to accomplish a xsd schema to datastore roundtrip, with minimum effort.

我使用 jaxb 从模式构建对象模型,现在我想基于 JPA(或 JDO 或其他东西?)存储这些对象.是否可以根据 JAXB 注释自动增强缺少注释的对象?这是可取的吗?

I used jaxb to build my object model from schemas, now I would like to store these objects based on JPA (or JDO or something else?). Is it possible, to auto enhance the objects with the missing annotations based on the JAXB Annotations? Is it desirable?

谢谢

推荐答案

这个用例有几个选项.

选项 #1 - Hyperjaxb3

我自己没有用过这个,但是Hyperjaxb3应该在模型上同时生成JAXB和JPA注解:

I have not used this myself, but Hyperjaxb3 is supposed to generate both JAXB and JPA annotations on the model:

  • http://confluence.highsource.org/display/HJ3/Home

选项 #2 - 使用 Dali 将您的 POJO 映射到数据库 (JPA)

Eclipse Dali 工具提供了使用 JPA 将 POJO 轻松映射到关系数据库的工具:

The Eclipse Dali tool provides tooling to easily map your POJOs to a relational database using JPA:

  • http://www.eclipse.org/webtools/dali/

选项 #3 - 使用 EclipseLink

EclipseLink 提供 JPA 和 JAXB 实现.JAXB 实现 (MOXy) 包含专门用于处理 JPA 实体的扩展:

EclipseLink provides both JPA and JAXB implementations. The JAXB implementation (MOXy) contains extensions specifically for handling JPA entities:

  • http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA

相关文章