hibernate有关主键

2025-05-14 01:21:32
推荐回答(1个)
回答1:

如实体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