Given a root class with a property private List<Base> items
and Base
being an abstract
class:
// 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;
}
The expected output for an entity of Root <base-url>/persistence/PU/entity/Root/123
should look like this:
<?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>
But actually it looks like this:
<?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>
The elements are available at the provided url, but to me that's not consistent with the usual JPA-RS model.
Question: Is it a bug or intended for inherited classes?
I'm using EL 2.5.1.v20130918