I have two classes:
public class A implements Serializable {
...
@OneToMany(cascade = CascadeType.ALL, mappedBy = "fieldID")
private Collection<B> bCollection;
...
public Collection<B> getBCollection()
{
return bCollection;
}
public void setBCollection(Collection<B> bCollection)
{
this.bCollection = bCollection;
}
}
public class B implements Serializable {
...
@JoinColumn(name = "aID", referencedColumnName = "id")
@ManyToOne(optional = false)
private A aID;
...
@XmlTransient
public A getAID() {
return aID;
}
public void setAID(A aID) {
this.aID= aID;
}
}
I was always using A
class - it is working as inteded, but now, I want to use B
class in RESTful GET
method. However, when I try to do that, @XmlTransient
prevents showing A
field. Is it possible to use @XmlTransient
on A
class, when I am using B
class and to use it on B
class, when I am using A
class?