HQL: left outer join on subquery
Let's assume I have 2 mysql tables:
create table tableA (
   id bigint not null auto_increment,
   name varchar(255), 
   primary key (id)
);
create table tableB (
   id bigint not null auto_increment,
   title varchar(255), 
   big_data longtext,
   tableA_id bigint,
   primary key (id)
);
And corresponding hibernate entities:
public class A {
private String name;
private List<B> list;
}
public class B {
private String title;
private String data;
private A a;
} 
I have 开发者_开发知识库the following SQL:
select a.id, count(b.id) 
from tableA as a left outer join 
    (select id, title, tableA_id from tableB) as b on a.id = b.tableA_id 
group by a.id;
How can i convert it to HQL?
PLEASE DO NOT OPTIMIZE QUERY! I'd like to have HQL which will produce exactly this SQL. Even if it is not optimal.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论