Hibernate如何创建final DTO的代理对象class?

How does Hibernate create a proxy object of final DTO class?

如果我将我的 DTO class 设为最终的,Hibernate 如何创建代理?

代码。

@Entity
public final class MyEntity {
    ...
}

听说Hibernate使用ReflectionAPI创建了一个对象的动态代理,并且继承自一位大师class。

无法创建代理。来自 the docs:

A central feature of Hibernate, proxies (lazy loading), depends upon the persistent class being either non-final, or the implementation of an interface that declares all public methods. You can persist final classes that do not implement an interface with Hibernate; you will not, however, be able to use proxies for lazy association fetching which will ultimately limit your options for performance tuning. To persist a final class which does not implement a "full" interface you must disable proxy generation.