我是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
使用 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();
}
}