在jpa中连接表和子查询

时间:2011-11-03 15:04:11

标签: jpa jpa-2.0 jpql

我有两个表T1和T2,其中t2是子查询的结果

说清楚

select * from T1 join (select * from T3 where foo is not null) T2 on T1.key = T2.fk

1 个答案:

答案 0 :(得分:0)

SELECT T1 FROM Table1Entity T1 JOIN Table1Entity.table2EntityAssociationField T2 WHERE T2.foo IS NOT NULL

其中

@Entity
class Table1Entity {

      @OneToOne
      Table2Entity table2EntityAssociationField;

}

@Entity
class Table2Entity {

     private Object foo;

}