1

我是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
4

1 回答 1

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();
        }
    }
于 2013-08-14T05:19:34.037 回答