简体   繁体   English

hbm.xml文件中的@OneToOne(optional = false)等效项是什么?

[英]What is the equivalent of @OneToOne(optional=false) in hbm.xml files?

We use hibernate 3 with some hbm.xml files. 我们将hibernate 3与一些hbm.xml文件一起使用。 Recently, we found that a one-to-one association (based on primary keys) is not loaded lazily and thus, making some memory issues. 最近,我们发现一对一关联(基于主键)的加载不是很懒,因此会引起一些内存问题。 After a little search, we found the solution for annotation-based hibernate configurations: Since the other side of the association is always present, it is only needed to add @OneToOne(optional=false) before the corresponding property in the java class. 稍作搜索后,我们找到了基于注释的休眠配置的解决方案:由于关联的另一端始终存在,因此仅需要在java类中的相应属性之前添加@OneToOne(optional = false)。

The problem is that we have not used annotations! 问题是我们还没有使用注释! We tried to add the attribute optional="false" in the tag, which resulted in some xml parsing exceptions. 我们试图在标记中添加属性optional =“ false”,这导致了一些xml解析异常。 We are looking for the equivalent of @OneToOne(optional=false) in hbm.xml files. 我们正在hbm.xml文件中寻找与@OneToOne(optional = false)等效的文件。

根据源,看起来constrained=true是等效的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM