在Hibernate中创建查询

时间:2015-06-22 09:46:45

标签: sql hibernate hql detachedcriteria

在hibernate中如何创建此查询

@Resource

这里假设您在数据库中拥有如下值:

"select test_type_nmbr from test_table where test_type_name in 
(select Test_type_name from test_table where test_type_nmbr in('111','222' ))". 

现在你想让所有test_type_ nmbr都有“gre”作为test_type_name(即'111'和'333'),而你只有111 test_type_nmbr。

我是否需要使用2种不同的回调标准,还是可以在1中使用?如果是1那么请让我知道如何。

2 个答案:

答案 0 :(得分:0)

尝试此查询

select a.test_type_nmbr from test_table a
join test_table b on a.Test_type_name=b.Test_type_name
 where b.test_type_nmbr in('111','222' )

答案 1 :(得分:0)

我找到答案并使用分离标准实现了它。在这里,我使用分离的条件来存储我的子查询,如果我以后想要使用这个子查询,我可以使用它的名称再次使用它。

让这些数字出现在名为testTypeList的列表中(' 111',' 222')。

you need to include cordova plugin before closing of body tag, as follows
<!doctype html>
<html>
    <head>
    </head>
    <body>

        <script src='cordova.js' type='text/javascript'></script>
        <script src='index.js' type='text/javascript'></script>
    </body>
</html>