[英]Hyperjaxb3: Is it possible to avoid Items table/class creation on PO sample?
I'm trying to avoid join classes creation. 我试图避免加入班级创建。 I tested some binding configuration but can't seem to get it done. 我测试了一些绑定配置,但似乎无法完成。
In PO Sample from git sources on tag 0.6.0 ejb/tests/po-customized, I tried some configuration. 在标签为0.6.0 ejb / tests / po-customized的git来源的PO Sample中 ,我尝试了一些配置。
First, I added join-column as one-to-many mapping in bindings 首先,我在绑定中将join-column添加为一对多映射
bindings.xjb 绑定文件
...
<hj:persistence>
<hj:default-one-to-many>
<orm:join-column />
<!-- <orm:join-table /> -->
</hj:default-one-to-many>
</hj:persistence>
...
This only change the annotation in getItem, from JoinTable to JoinColumn. 这只会将getItem中的注释从JoinTable更改为JoinColumn。
Also, I tried to override xsd mapping by telling it to add a list directly. 另外,我尝试通过告诉xsd映射直接添加列表来覆盖它。 the following code doesn't work, but it's the general idea of what I've been trying... (never get something like it to work) 下面的代码不起作用,但这是我一直在尝试的基本思想……(从没让它起作用)
bindings.xjb 绑定文件
...
<jaxb:bindings node="xs:complexType[@name='PurchaseOrderType']">
<hj:entity>
<orm:table name="po" />
</hj:entity>
<jaxb:bindings node=".//xs:element[@name='items']">
<hj:one-to-many>
<orm:join-column name="PO_ID" />
</hj:one-to-many>
</jaxb:bindings>
</jaxb:bindings>
...
Is it possible to generate PurchaseOrderType with this definition? 是否可以使用此定义生成PurchaseOrderType ? (some xml annotations omitted) (省略了一些xml注释)
...
public class PurchaseOrderType ... {
protected USAddress shipTo;
protected USAddress billTo;
@XmlElementWrapper(name="items")
@XmlElement(name="item")
protected List<Item> items;
protected XMLGregorianCalendar orderDate;
protected Long hjid;
...
@OneToMany(targetEntity = Item.class, cascade = {
CascadeType.ALL
})
public List<Item> getItems() {
...
Note in this code, I'm pointing directly to generated Item, and not Items.Item. 请注意,在此代码中,我直接指向生成的Item,而不是Items.Item。
Thanks a lot! 非常感谢!
This worked in HJ2 but was is not implemented in HJ3 yet. 这在HJ2中有效,但尚未在HJ3中实现。 Here's an issue for this. 这是一个问题 。
In principle, the XmlElementWrapper
plugin you mention is a way to go. 原则上,您提到的XmlElementWrapper
插件是一种解决方法。 I've just never tested it with HJ3. 我只是从未使用HJ3进行过测试。
If you want this feature, please file an issue here , I'll see what I can do. 如果您想使用此功能,请在此处提出问题,我将解决。
Disclosure: I'm the author of Hyperjaxb3. 披露:我是Hyperjaxb3的作者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.