[英]Hibernate - Double left join to same table
I'm having two tables 我有两张桌子
First plan_time 第一次计划时间
NAME | START_FK | END_FK
------------------------
test | 1 | 2
start_fk and end_fk are FK refering to table times : start_fk和end_fk是FK引用表时间 :
ID | NAME
---------
1 | time1
2 | time2
I'm executing simple select query: 我正在执行简单的选择查询:
SELECT pt.*, t1.*, t2.* FROM plan_table pt LEFT JOIN times t1 ON t1.id = pt.start_fk LEFT JOIN times t2 ON t2.id = pt.end_fk
And here is the problem. 这就是问题所在。 Under sql console I'm getting good result:
在sql控制台下,我得到了很好的结果:
First row from plan_table join by first row from times table and second row from times table.
When I'm doing that via hibernate 当我通过休眠进行操作时
SQLQuery sqlQuery = s.createSQLQuery( SQL-QUERY )
.addEntity(PlanTime.class)
.addEntity(Times.class)
.addEntity(Times.class);
I'm getting 3 objects 我有3个物件
It have to be something with Hibernate... I checked SQL which is send to DB and it is ok. 一定是Hibernate的东西。。。我检查了发送到DB的SQL,没关系。
:/ :/
Please help. 请帮忙。
I found workaround for this problem. 我找到了解决此问题的方法。 Here are tips which helped me:
以下提示对我有帮助:
I'm still trying to find out what is status of this issue. 我仍在尝试找出此问题的状态。
https://hibernate.atlassian.net/browse/HHH-3988 https://hibernate.atlassian.net/browse/HHH-3988
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.