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.
First, I added join-column as one-to-many mapping in bindings
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.
Also, I tried to override xsd mapping by telling it to add a list directly. 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? (some xml annotations omitted)
...
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.
Thanks a lot!
This worked in HJ2 but was is not implemented in HJ3 yet. Here's an issue for this.
In principle, the XmlElementWrapper
plugin you mention is a way to go. I've just never tested it with 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.