5
我有限定在购买一个懒惰@ManyToOne
列:休眠@ManyToOne(取= FetchType.LAZY)忽略
@ManyToOne(fetch = FetchType.LAZY)
Sale sale = null
然而,当我加载从分贝的实体,它被直接加载:
Purchase purchase = em.find(Purchase.class, id);
PersistenceUnitUtil unitUtil = em
.getEntityManagerFactory()
.getPersistenceUnitUtil();
System.err.println(unitUtil.isLoaded(purchase, "sale"));
即使该字段尚未加载,这将返回true
。
我在做什么错?
(休眠4.3.11.Final)
那么我能做些什么来防止这种情况呢? –
没有太多的选择,我知道。一种方法是“构建时字节码检测”。 http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/performance.html#performance-fetching-lazyproperties – kan
那么,为什么这个功能即使有,当它不能工作?我什至尝试'nullable = false'没有任何效果。 –