当我从数据库中选择Test2时,可以看到正在进行单独的选择以获取关联的test3类的详细信息。
我对另一个答案的代码非常感兴趣,因为这也是我在测试所显示的代码时看到的内容,它为a生成两个选择
from Test2。
我正在使用以下依赖项:
- org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:compile
- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
- org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile
- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
- org.hibernate:hibernate-core:jar:3.3.0.SP1:编译
我出于绝望而将FetchType设置为EAGER,尽管对于OneToOne映射无论如何它都默认为EAGER,但没有任何区别。
如果您使用Hibernate批注,则不会产生任何影响,因为Hibernate批注会覆盖EJB3的获取选项。见2.4.5.1。懒惰的选项和获取模式。



