I have 2 mapping classes (analogue to JPA classes):
@XmlType(propOrder = {"name", "children", })
@XmlRootElement(name = "a")
@XmlAccessorType( XmlAccessType.PROPERTY)
public class A implements Serializable {
private String name;
private List<B> children;
@XmlElement(name = "metadatum")
public List<B> getChildren(){
return children;
}
...
}
@XmlRootElement(name = "metadatum")
@XmlType(propOrder = {"name"})
public class B implements Serializable{
private String name;
private A parent;
...
}
A and B are in a OneToMany relation. The XML should look like this:
<A>
<B></B>
<B></B>
</A>
If I unmarshal the xml, map it to my JPA classes and persist it to my database everything is stored correctly except my references. This means that B is stored without a foreign key to A in the database.
No comments:
Post a Comment