我试图避免加入课程创建。我测试了一些绑定配置,但似乎无法完成。
在标签 0.6.0 ejb/tests/po-customized 上来自 git 源的 PO 示例中,我尝试了一些配置。
首先,我在绑定中添加了 join-column 作为一对多映射
绑定.xjb
...
<hj:persistence>
<hj:default-one-to-many>
<orm:join-column />
<!-- <orm:join-table /> -->
</hj:default-one-to-many>
</hj:persistence>
...
这只会将 getItem 中的注释从 JoinTable 更改为 JoinColumn。
另外,我试图通过告诉它直接添加一个列表来覆盖 xsd 映射。以下代码不起作用,但这是我一直在尝试的一般想法......(永远不会让类似的东西起作用)
绑定.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>
...
是否可以使用此定义生成PurchaseOrderType ?(省略了一些 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() {
...
请注意,在此代码中,我直接指向生成的 Item,而不是 Items.Item。
非常感谢!