关于key
来源:互联网 发布:阿里云虚拟主机能干嘛 编辑:程序博客网 时间:2024/05/22 01:31
举个例子
hbm1
<set name="childrenReplies" lazy="false" cascade="all" > <key column="PARENT_REPLY_ID"/> <one-to-many class="Reply"/> </set>
用hbm1时,当你想l取出childrenReplies
Hibernate: select replies0_.MESSAGEBOX_ID as MESSAGEBOX5_1_1_, replies0_.id as id1_, replies0_.id as id2_0_, replies0_.title as title2_0_, replies0_.content as content2_0_, replies0_.PARENT_REPLY_ID as PARENT4_2_0_, replies0_.MESSAGEBOX_ID as MESSAGEBOX5_2_0_, replies0_.SEND_REPLY_PERSON_ID as SEND6_2_0_, replies0_.SEND_REPLY_TIME as SEND7_2_0_ from reply replies0_ where replies0_.PARENT_REPLY_ID=?
16:50:50,847 TRACE BasicBinder:82 - binding parameter [1] as [VARCHAR] - 402845ca3daa5a9a013daa5ced790000
hbm2
<set name="childrenReplies" lazy="false" cascade="all" > <key column="id"/> <one-to-many class="Reply"/> </set>
而hbm2
Hibernate: select replies0_.MESSAGEBOX_ID as MESSAGEBOX5_1_1_, replies0_.id as id1_, replies0_.id as id2_0_, replies0_.title as title2_0_, replies0_.content as content2_0_, replies0_.PARENT_REPLY_ID as PARENT4_2_0_, replies0_.MESSAGEBOX_ID as MESSAGEBOX5_2_0_, replies0_.SEND_REPLY_PERSON_ID as SEND6_2_0_, replies0_.SEND_REPLY_TIME as SEND7_2_0_ from reply replies0_ where replies0_ID=?
16:50:50,847 TRACE BasicBinder:82 - binding parameter [1] as [VARCHAR] - 402845ca3daa5a9a013daa5ced790000
忽略那些列名,主要看where从句
让我们看下文档
7.2.1. Collection foreign keys
On the database level collection instances are distinguished by the foreign key of the entity that owns the collection. This foreign key is referred to as thecollection key column, or columns, of the collection table. The collection key column is mapped by the@JoinColumn
annotation respectively the<key>
XML element.
key就相当于 where replies0_.PARENT_REPLY_ID=?
中的PARENT_REPLY_ID,而?就是多对一的外键指向的键
比如
CONSTRAINT "FK_REPLY_REFERENCE_REPLY" FOREIGN KEY ("PARENT_REPLY_ID") REFERENCES "SCOTT"."REPLY" ("ID") ENABLE,
因为外键PARENT_REPLY_ID指向的是reply的id
所有?就是reply的id即402845ca3daa5a9a013daa5ced790000
- 关于key
- 关于key?
- 关于BISS Key的教程
- 关于JSON对象的key
- 关于Office 2010无法Change Key
- 关于键保留表(key-preserved table)
- 关于SQL的key的总结
- 关于mysql中的key和index
- 关于STL中map的key
- [C++]关于map的Key值
- 关于SAP的“Sort key 排序码”
- 关于获取NSDictionary的key问题
- 关于“Duplicate entry '1403070003' for key 'PRIMARY'”
- 关于申请Google places key的步骤
- 关于百度地图 key值的问题
- 关于usb key和bootstrap的冲突
- 关于百度地图api的key问题
- 关于bitbucket和github的key问题
- Ruby on Rails命令
- Http 错误代码详解
- Eclipse快捷键大全(转载)
- antlr.collections.AST.getLine()I异常
- 总结:粮食粘度测定中的几个问题
- 关于key
- gridview快速字符转换
- HDU4267(2012长春网络赛)
- Python中PyQuery库的使用总结
- Java文件file操作总结
- 两种方式使用tabhost/tabwidget布局
- 通俗感性多线程学习
- quartz2D 学习 1
- C++矩阵处理工具——Eigen .