constrained= "true "

salmon_ok 2008-12-30 04:31:28
hibernate中constrained= "true "
是不是只能用于one-to-one?我看到的很多例子在one-to-one的两边的配置文件中都有constrained= "true ",不明白这个声明的作用是什么?

请高手指教!!
...全文
308 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaolianbinbin 2009-09-21
  • 打赏
  • 举报
回复
例如:居民person和身份证Idcard之间
<one-to-one name="idCard" constrained="true" cascade="none" />

constrained="true"是指,你的person的id是由IdCard生成的。
也就是说。IdCard要先于你的Person存在了。
所以会先保存IDCard,然后才保存Person
myborn86 2009-01-10
  • 打赏
  • 举报
回复
学习啦
lihan6415151528 2009-01-10
  • 打赏
  • 举报
回复
constrained (optional) specifies that a foreign key constraint on the primary key of the mapped table references the table of the associated class. This option affects the order in which save() and delete() are cascaded, and determines whether the association may be proxied (it is also used by the schema export tool).
honhacker009 2009-01-10
  • 打赏
  • 举报
回复
constrained(约束) (可选) 表明该类对应的表对应的数据库表,和被关联的对象所对应的数据库表之间,通过一个外键引用对主键进行约束。 这个选项影响save()和delete()在级联执行时的先后顺序以及 决定该关联能否被委托(也在schema export tool中被使用).
zhangzb717 2009-01-10
  • 打赏
  • 举报
回复
路过,帮你顶了

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧