在浏览 Hibernate 3.x 文档时,我发现我们可以为具有私有(private)可见性的 POJO 声明一个无参数构造函数,但文档说它有限制:
The no-argument constructor is a requirement for all persistent classes; Hibernate has to create objects for you, using Java Reflection. The constructor can be private, however package or public visibility is required for runtime proxy generation and efficient data retrieval without bytecode instrumentation.
我是 Hibernate 的新手,试图了解何时使用运行时代理、何时使用字节码以及它在 Hibernate 中的工作原理。另外什么是字节码检测以及它在 Hibernate 中的使用方式。
最佳答案
Hibernate 在集合或关联的延迟初始化期间使用运行时代理来提高性能。您可以阅读各种抓取策略及其影响here
字节码检测是另一种允许您在加载类时修改字节码(即类文件)的技术。 this link可能会有所帮助。
关于java - Hibernate 无参数构造函数可见性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19503279/