Hibernate子查询

原始hql:(子查询写在from中,执行报错)

    String hql = "select q from TWorkAutoQueue q ,( "
           +"select distinct e.extId "
           +"from YIProcessExt e,TWorkitem t "
           +"where t.processInsId = e.extProcessInsId ) ext "
           +"where ext.extid = q.extid";

修改后hql:

    String hql = "select q from TWorkAutoQueue q "
                +"where q.extId in( "
                +"select distinct e.extId "
                +"from YIProcessExt e,TWorkitem t "
                +"where t.processInsId = e.extProcessInsId ) ";

总结:hibernate中使用子查询只能写在where后面

发布了18 篇原创文章 · 获赞 0 · 访问量 352

猜你喜欢

转载自blog.csdn.net/Mr_ye931/article/details/105182598