@Onetomany 查询出的集合与数据库不一致
问题描述:
@Entity
public class DeamonJob{
@OneToMany(
mappedBy = "deamonJob",
cascade = { CascadeType.ALL },
fetch = FetchType.LAZY
)
protected Set clientEnvironmentDeamonJobParams =
new LinkedHashSet();
}
@Entity
public class ClientEnvironmentDeamonJobParam{
@JoinColumn(
name = "deamonJobId",
nullable = true
)
@ManyToOne(fetch = FetchType.LAZY)
protected DeamonJob deamonJob;
}
实体映射关系如上,
"FROM DeamonJob" 我执行hql查询出DeamonJob,
deamonJob.getClientEnvironmentDeamonJobParams(),得到param的集合,
我现在数据库中有三条数据, 但是现在得到的param集合只有一条数据,有可能是什么原因造成的呢?
答
已解决 ,SET 去重了, 要重写对象的 hashset方法