// This is what I have in my Model Class...
public class Quotation {
@JoinColumn(name = "party_id", referencedColumnName = "id")
@ManyToOne (fetch = FetchType.LAZY)
private Party party;
}
在我控制我加载报价对象是这样的:Hibernate的延迟加载不工作
// Load Quotation object by the Entity Manager:- em.find(Quotation.class, quoteId)
quotation = quotationService.getQuoteHeadById(quoteId);
log.debug(" party ID --> "+ quotation.getParty.getId());
,但我不能在这个懒惰,甚至得到对方表/对象的方ID加载。但是,如果我将提取类型更改为Eager,那么log.debug()会完美地为我提供ID。
我错了吗?
尝试@ManyToOne(fetch = FetchType.LAZY,可选= false) –
您可以提供查询代码吗? –
@Eva Mariam:(fetch = FetchType.LAZY,可选= false)没有解决问题。 – obsolete