是否可以像在这个SQL查询SELECT t1.name FROM table t1 INNER JOIN table2 t2 ON t2.table1_id=t1.id;
中一样加入Hibernate?例如:
class Table1Entity {
public int id;
public String name;
}
class Table2Entity {
public int id;
public Table1Entity table1Entity;
}
要使用SQL选择table1entity
使用的所有table2entity
,我将调用SELECT t1.name FROM table t1 INNER JOIN table2 t2 ON t2.table1_id=t1.id;
。我知道我可以这样做SELECT t1.name FROM Table1Entity t1, Table2Entity t2 WHERE t1.id=t2.table1Entity
,但我想使用JOIN。
答案 0 :(得分:1)
select t1 from Table2Entity t2 join t2.table1Entity t1