此信封映射的只有一个信封对象和两个发票对象。当我尝试使用以下代码查询时,它返回两个相同的信封对象。我认为我的休眠注释有问题。有什么解决办法吗?
Envelope envelope = new Envelope();
envelope.setPostBox(EnvelopePostBox.INBOX.name());
List<Envelope> byTemplate = genericDao.getByTemplate(envelope);
信封实体;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "envelope", fetch = FetchType.EAGER)
private List<Invoice> invoiceList;
发票实体;
@JoinColumn(name = "envelope", referencedColumnName = "instance_identifier")
@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
private Envelope envelope;
我的道法;
@Transactional(readOnly = true)
public <T> List<T> getByTemplate(T templateEntity) {
Criteria criteria = getCurrentSession().createCriteria(templateEntity.getClass());
criteria.add(Example.create(templateEntity));
return criteria.list();
}