I have a Class So as shown below:
@Entity
@Table(name = "so", schema = "public")
public class So implements java.io.Serializable , IBusiness {
private int idSo;
private Set<PartOrder> partOrders = new HashSet<PartOrder>();
public So() {
}
@Id
@SequenceGenerator(name = "seqGenerator", sequenceName = "so_seq", allocationSize=1, initialValue=1)
@GeneratedValue(generator="seqGenerator", strategy=GenerationType.SEQUENCE)
@Column(name = "id_so", unique = true, nullable = false)
public int getIdSo() {
return this.idSo;
}
public void setIdSo(int idSo) {
this.idSo = idSo;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "so")
public Set<PartOrder> getPartOrders() {
return this.partOrders;
}
public void setPartOrders(Set<PartOrder> partOrders) {
this.partOrders = partOrders;
}
}
I have a method that returns a Json with the SO. But i don not want the partOrders attribute to be included on the response json. I was using @JsonIgnore on the attribute but now, i have another method that receives an SO object and i need to get the partOders.
The question is: Is there any way to specify when to ignore the attribute (in specific method) ?