2016-07-28 43 views
-1
public class Customer{ 

@Id 
private String customerId; 
private String lastName; 
private String firstName; 

@OneToOne(cascade = CascadeType.ALL) 
private Image profileImage;... 

以上面的例子,讓我們留Customer類是兩個類的一個實例變量 -傑克遜@JsonIgnore Java的子對象 - 多用

RandomClassA{ 
.. 
private Customer customer; 
.. 
} 

RandonClassB{ 
.. 
private Customer customer; 
.. 
} 

的問題是我想忽略客戶Image及其變量訪問RandomClassA時,但我希望它顯示爲RandonClassB

是否有任何簡單的方法來做到這一點 - 在上進行一些操作分別爲和RandomClassB

回答

0

實測溶液

@JsonIgnoreProperties({"property1","property2"})