Incorrect SQL generated when one-to-many foreign key is in a discriminated subcl

A bug reported for hibernate:http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015;http://opensource.atlassian.com/projects/hibernate/browse/HHH-2898



可以看到,Hibernate不能认识到用于外键连接的列是子类对应表中的某个列。或者说,会认为子类中的这个列也必然是父类对应表中的列。所导致的问题就是,Hibernate会去访问父类中并不存在的某个列。

一个解决此问题的方法是使用<joined-subclass>,而不是<subclass name="EventPayer" discriminator-value="-3"><join table="event_payer">。可以参考HHH-2898.



PS:Both of joined-subclass and subclass can be used for 'table per subclass'.

PS2: joined-subclass和subclass没有办法同时使用. Can't mix subclass and joined-subclass strategies for a hierarchy. You can try to use one-to-one mapping to substitute the joined-subclass.

PS3: PK must be used for the mapping of root class and subclass in 'table per subclass'.scenario. It means <joined-subclass> is used for one to one mapping.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值