hibernate constrained属性
来源:互联网 发布:cacti监控windows模板 编辑:程序博客网 时间:2024/05/21 20:28
Hibernate文档上是这么写的:
constrained(约束) (可选) 表明该类对应的表对应的数据库表,和被关联的对象所对应的数据库表之间,通过一个外键引用对主键进行约束。这个选项影响save() 和delete() 在级联执行时的先后顺序(也在schema export tool中被使用)。 constrained默认值为false
constrained只能在one-to-one的映射中使用,(一般在主表的映射中,有外键的那个表)。如果constrained=true, 则表明存在外键与关联表对应,并且关联表中肯定存在对应的键与其对应, 另外该选项最关键的是影响save和delete的先后顺序。例如增加的时候,如果constainted=true,则会先增加关联表,然后增加本表。 删除的时候反之。 one-to-one的单向关联中,如果constrained=false,则会在查询时就全部取出来,用left outer join的方式。如果constrained=true,hibernate即会延迟加载sql,只把主表的查出来,等有用到关联表的再发sql取。
one-to- one的双向关联中,必须设置constrained=true,要不然会有重复数据读,如2个表user,car;在位false时sql如 下:select * from user a left outer join car b on a.id=b.id left outer join on user c on a.id=c.id where a.id=? 删除的时候最好删除从表,删除主表会先查询下主表,在联合查询下。
0 0
- hibernate constrained属性
- hibernate constrained属性
- hibernate constrained属性
- hibernate constrained属性
- hibernate constrained属性的作用
- hibernate constrained
- hibernate中constrained
- hibernate之constrained详解
- hibernate之constrained详解
- hibernate之constrained详解
- javabean之Constrained属性
- hibernate constrained属性 其在表的映射关联关系 的作用
- hibernate的constrained(约束)
- 【SSH三大框架】Hibernate基础第十三篇:lazy、constrained、fetch三个属性的作用和使用方法
- hibernate中设置constrained的问题
- JavaBean的属性(Simple,Indexed,Bound,Constrained)
- JavaBean的属性(Simple,Indexed,Bound,Constrained)
- Hibernate属性
- QT程序异常结束
- SQL Server 附加数据库失败的解决办法 (3415错误)
- maven 找不到类的解决方式
- java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind 报错的原因
- 代理模式
- hibernate constrained属性
- hibernate测试案例
- one-to-one与many-to-one的区别
- org.hibernate.exception.GenericJDBCException: Cannot open connection
- 【转】python文件和目录操作方法大全(含实例)
- Hibernate复合主键
- 归并排序的C++实现
- 悲观锁
- 外置命名查询