我是hibernate的新手,我想在hibernate中转换下面的查询
Select a.* from ((select b.* from B b) full
join (select c.* from C c) on b.id=c.id) a where a.somecoulumn=condition
答案 0 :(得分:0)
使用createSqlQuery而不是createQuery ..
public List getList(String sql) {
Session session = factory.openSession();
Transaction tx = null;
List list = null;
try {
tx = session.beginTransaction();
list = session.createSQLQuery(sql).list();
tx.commit();
return list;
} catch (HibernateException e) {
if (tx != null) {
tx.rollback();
}
e.printStackTrace();
return null;
} finally {
session.close();
}
}