小白,求解答关联映射问题。希望好心人解答。
小白,求解答疑惑仿照系统表TSRoleUser, 关联映射VoteEntity和TSUser实体。测试后成功插入。仿制的VoterEntity大致具体如下。
@Entity
@Table(name = "tabvoter")
public class VoterEntity extends IdEntity implements java.io.Serializable {
private VoteEntity VoteEntity;
private TSUser TSUser;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "varvoteid")
public VoteEntity getVoteEntity() {
return this.VoteEntity;
}
public void setVoteEntity(VoteEntity VoteEntity) {
this.VoteEntity = VoteEntity;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "varuserid")
public TSUser getTSUser() {
return this.TSUser;
}
public void setTSUser(TSUser TSUser) {
this.TSUser = TSUser;
}
但查询实体时
List<VoterEntity> VoterEntity = voteService.findByProperty(VoterEntity.class, "VoteEntity.id", vote.getId());
其中
findByProperty(VoterEntity.class, "VoteEntity.id", vote.getId())里的VoteEntity.id属性找不到,报错。
而如下查询
List<VoterEntity> VoterEntity = voteService.findByProperty(VoterEntity.class, "TSUser.id", vote.getId());里的TSUser.id正确。
是不是配置映射时,还是其中哪一步少配了什么,请好心人指点,都需配哪些东西。
页:
[1]