@Basic(fetch = FetchType.LAZY)不起作用? [英] @Basic(fetch = FetchType.LAZY) does not work?

查看:1715
本文介绍了@Basic(fetch = FetchType.LAZY)不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JPA(Hibernate)和Spring。
当我想延迟加载一个Stirng属性时,我使用这个语法:

  @Lob 
@Basic (fetch = FetchType.LAZY)
public String getHtmlSummary(){
return htmlSummary;
}

但是当我查看hibernate创建的sql时,看起来这个属性是不是懒加载?我也在ANT脚本中使用这个类org.hibernate.tool.instrument.javassist.InstrumentTask来测试这个属性,但它似乎不起作用。



请帮助我。



Khosro。

解决方案

Lazy Lob loading会要求字节码检测工具正常工作,所以它在默认情况下在我知道的任何JPA实现中都不可用。



打赌是将Lob放入一个单独的实体中,如 HtmlSummary ,并使用延迟加载的一对一关联。

I use JPA (Hibernate) with Spring. When i want to lazy load a Stirng property i use this syntax:

@Lob
@Basic(fetch = FetchType.LAZY)
public String getHtmlSummary() {
    return htmlSummary;
}

But when i look at the sql that hibernate creates, it seems this property is not lazy loaded? I also use this class org.hibernate.tool.instrument.javassist.InstrumentTask in ANT script to instrument this property but it seems it does not work.

Please help me.

Khosro.

解决方案

Lazy Lob loading would require bytecode instrumentation to work properly, so it is not available by default in any JPA implementation I'm aware of.

Your best bet is to put the Lob into a separate entity, like HtmlSummary, and use a lazily loaded one-to-one association.

这篇关于@Basic(fetch = FetchType.LAZY)不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆