我使用 Hibernate 来访问旧数据库。对于某些表,不强制执行父子引用完整性,并且long
对于子表中的某些“父”列,使用 0 值代替 NULL 以表示“无父”。
我仍然想使用这些关系@ManyToOne
and @OneToMany
字段,但得到EntityNotFound
错误,因为 0 值与主表中的任何记录都不对应。
我有什么选择?
Use the NotFound http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/annotations/NotFound.html注解:
@NotFound(action = NotFoundAction.IGNORE)
See http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#mapping-declaration-manytoone http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#mapping-declaration-manytoone
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)