hibernate符合主键
- 作者: 夏丶biubiu
- 来源: 51数据库
- 2021-01-21
如实体User(firstName,lastName,age)
如想定义 firstName 和 lastName 为复合主键,分两个步骤:
1) 在User 类中以firstName 和lastName为依据定义equals 和 hashCode 方法,hibernate 通过这个判定两个对象主键是否相等
2)映射文件中,把部分替换为:
hibernate annotation 主键映射 http://hi.baidu.com/magicdetective/blog/item/9ece2434c8810f3c5ab5f562.html
如想定义 firstName 和 lastName 为复合主键,分两个步骤:
1) 在User 类中以firstName 和lastName为依据定义equals 和 hashCode 方法,hibernate 通过这个判定两个对象主键是否相等
2)映射文件中,把
hibernate annotation 主键映射 http://hi.baidu.com/magicdetective/blog/item/9ece2434c8810f3c5ab5f562.html
推荐阅读
