【发布时间】:2018-08-22 01:40:24
【问题描述】:
我想问一个关于 Hibernate 中的 Lazy Fetching 的问题。
据我所知,为了实现 Lazy Fetching,Hibernate 创建了一个占位符,它是真实属性的代理。
如果我的实体包含 String 属性或其他最终类怎么办? CGLIB 将如何对其进行子类化?
【问题讨论】:
我想问一个关于 Hibernate 中的 Lazy Fetching 的问题。
据我所知,为了实现 Lazy Fetching,Hibernate 创建了一个占位符,它是真实属性的代理。
如果我的实体包含 String 属性或其他最终类怎么办? CGLIB 将如何对其进行子类化?
【问题讨论】:
长话短说:
Could not generate CGLIB subclass of class [class SomeClass]: Common causes of this problem include using a final class or a non-visible class 的内容
myEntity.getMyString() |_ proxy.getMyString() |_ lazyAttributeLoadingInterceptor.fetchAttribute(myEntity,"myString") |_ ... (actual call to underlying DB if required)
也就是说,你在这里所说的一切都是正确的:
Hibernate 创建一个占位符,它是真实的代理 ...
如果你用 entity/pojo 代替 property 来结束这句话
【讨论】: