给定一个属性为private List<Base> items
且Base
属于abstract
类的根类:
// omitted properties, Constructor, Getter, Setter, etc.
@Entity
@XmlRootElement(name = "ROOT")
@XmlAccessorType(XmlAccessType.FIELD)
public class Root implements Serializable {
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "ROOT_TO_BASE", joinColumns = {
@JoinColumn(name = "PARENT_ROOT_ID") }, inverseJoinColumns = {
@JoinColumn(name = "BASE_ID") })
@XmlElementWrapper(name = "ITEMS")
@XmlElements({ @XmlElement(name = "FOO", type = Foo.class),
@XmlElement(name = "BAR", type = Bar.class) })
private List<Base> items;
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlSeeAlso({ Foo.class, Bar.class })
public class Base implements Serializable {
@XmlElement(name = "BASE-NAME")
private String baseName;
}
Root <base-url>/persistence/PU/entity/Root/123
实体的预期输出应如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<ROOT ID="123">
<ITEMS>
<_link href="<base-url>/persistence/PU/entity/Foo/6" method="GET" rel="self" />
<_link href="<base-url>/persistence/PU/entity/Bar/7" method="GET" rel="self" />
</ITEMS>
<_relationships>
<_link href="<base-url>/persistence/PU/entity/Root/123/items" rel="items"/>
</_relationships>
</ROOT>
但实际上它看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<ROOT ID="123">
<ITEMS/>
<_relationships>
<_link href="<base-url>/persistence/PU/entity/Root/123/items" rel="items"/>
</_relationships>
</ROOT>
这些元素可以在提供的网址上找到,但对我而言,这与通常的JPA-RS模型不一致。
问题:这是一个bug还是用于继承的类?
我正在使用EL 2.5.1.v20130918