Java 如何使用完全联接在hibernate中编写子查询

Java 如何使用完全联接在hibernate中编写子查询,java,hibernate,Java,Hibernate,我不熟悉hibernate,我想在hibernate中转换以下查询 从b中选择a.*从b完全选择b.* 在b.id=c.id a上从c中选择c.*,其中a.somecoulumn=condition 使用createSqlQuery而不是createQuery public List getList(String sql) { Session session = factory.openSession(); Transaction tx = null;

我不熟悉hibernate,我想在hibernate中转换以下查询

从b中选择a.*从b完全选择b.* 在b.id=c.id a上从c中选择c.*,其中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();
        }
    }

您尝试了什么?????我创建了一个函数,如下所示:public List getListString hql{Session Session=factory.openSession;Transaction tx=null;List List=null;try{tx=session.beginTransaction;list=session.createQueryhql.list;tx.commit;return list;}catch hibernateeException e{if tx!=null{tx.rollback;}e.printStackTrace;return null;}finally{session.close;}}并尝试编写hql,但在其工作区附近出现语法错误。我也曾想过使用本机SQL。但如何使用hql实现同样的效果?因为本机SQL可能会出现问题,它将成为hibernate中使用条件的数据库依赖项。这比hql容易