JPA and JAXB Annotated POJOs [message #491926] |
Fri, 16 October 2009 10:59  |
Eclipse User |
|
|
|
Hello Everyone
I am still working on my little rcp application which uses a JPA annotated model. Now I want to have a functionallity that allows me to export some objects and import them again. So I added some JAXB annotations as well.
My problem now is, that I can only have one of the mentioned annotations working properly. When I combine both, I get into erros. I couldnt find much information about this issue, even though I expected this to be a very common usecase (a model that is persisted to a db, and exported imported via jaxb, transfered via webservice etc.).
It seems the biggest problem is my abstract superclass which only contains the id field. Currently my setup looks like the following:
@MappedSuperclass
@XmlType
public abstract class EntityBase implements Serializable{
@Transient
public static final long serialVersionUID = -3178098860021538369L;
@Id
@GeneratedValue
@Column(name = "Id")
@XmlElement
private long id;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
@Entity
@XmlType
public class Person extends EntityBase {
private static final long serialVersionUID = EntityBase.serialVersionUID;
@Column (name="FirstName", nullable=false)
private String firstName;
@Column (name="LastName", nullable=false)
private String lastName;
@OneToOne
@PrimaryKeyJoinColumn
private Address address;
...
@Entity @Table(name = "Customers")
@DiscriminatorValue("C")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType
public class Customer extends Person {
private static final long serialVersionUID = EntityBase.serialVersionUID;
I probably have some more errors in there now, after I tried different types of annotations, but the main error is, that jaxb complains about an XmlId which occurs multiple times?
Does anyone have an idea how to solve this? I am also interested in a best-practise approach.
Thanks a lot
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03833 seconds