遇到一个非常奇怪的问题,感觉象hibernate的bug,即使不是bug,也是设计的有失偏颇。
一个简单的Pojo映射如下:
oid为自增long类型,id为guid,表中为string类型.
简单查询的hql为:from Member as t where t.id = ?
ok,这看起来是没有问题的,一切都很ok.
可事实上,这条hql执行时,它应该去根据哪个属性去查询呢?
凭感觉,它应该根据属性名称即“property name='id'”去做查询,因为非id属性就是如此;
可事实上,它却去根据oid即hibernate的id结点去查询.......
当然,这种情况是一种极特别的情况,被我遇到了而已..........
这也许不算bug,也许人家就是如此设计的吧....
一个简单的Pojo映射如下:
1.
<
hibernate-mapping
package
="cn.crazyasp.album.user"
>
2. < class name ="Member" table ="V_MemberDetail_info" >
3. < id name ="oid" type ="long" column ="MBDT_index" >
4. < generator class ="native" />
5. </ id >
6. < property name ="id" column ="MBDT_MBUid" type ="string" />
7. < property name ="name" column ="MBDT_City" type ="string" />
8. </ class >
9. </ hibernate-mapping >
2. < class name ="Member" table ="V_MemberDetail_info" >
3. < id name ="oid" type ="long" column ="MBDT_index" >
4. < generator class ="native" />
5. </ id >
6. < property name ="id" column ="MBDT_MBUid" type ="string" />
7. < property name ="name" column ="MBDT_City" type ="string" />
8. </ class >
9. </ hibernate-mapping >
oid为自增long类型,id为guid,表中为string类型.
简单查询的hql为:from Member as t where t.id = ?
ok,这看起来是没有问题的,一切都很ok.
可事实上,这条hql执行时,它应该去根据哪个属性去查询呢?
凭感觉,它应该根据属性名称即“property name='id'”去做查询,因为非id属性就是如此;
可事实上,它却去根据oid即hibernate的id结点去查询.......
当然,这种情况是一种极特别的情况,被我遇到了而已..........
这也许不算bug,也许人家就是如此设计的吧....