【发布时间】:2017-04-27 15:02:45
【问题描述】:
有这样的实体:
@Entity
public class Player {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private long id;
private String userName;
@OneToMany(mappedBy="player", fetch=FetchType.EAGER)
private Set<Participation> participations;
public long getId() {
return id;
}
public String getUserName() {
return userName;
}
public Set<Participation> getParticipations() {
return participations;
}
}
当我使用调试器访问 url http://localhost:8080/rest/players/1 时,我可以看到 getUserName 是如何被调用的(我猜是由序列化程序调用的)。 getId 和 getParticipations 未被调用。
这种行为对我来说没问题,我的意思是,这只是好奇,为什么不调用这些 getter?
【问题讨论】:
标签: java spring spring-data spring-data-rest serialization