如何用cast来编写hql查询? [英] How do I write hql query with cast?
本文介绍了如何用cast来编写hql查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要结合使用hql的两个表,它们都具有公共列,但是 table1
common列是 integer
和 table2
common列是字符串
例如,
选择a.id作为ID,a.name作为名称,b.address作为地址
作为个人作为,Home作为b
其中a.id = b.studid
这里 a.id
是一个整数
,而 b.stduid
是一个 string
,但两列的数据是相同的。
如何使用hql查询得到查询结果?< HQL支持 CAST
(如果底层数据库支持它的话),你可以使用HQL支持 CAST
使用它:
选择a.id作为id,a.name作为名称,b.address作为地址
从(a.id as string)= b.studid
另见:
I need to combine 2 tables using hql, both are having common column, but table1
common column is integer
and table2
common column is String
For example,
select a.id as id,a.name as name,b.address as address
from Personal as a,Home as b
where a.id=b.studid
Here a.id
is an integer
while b.stduid
is a string
, but Data of both columns is the same.
How can I get the result of the query using hql query?
解决方案
HQL supports CAST
(if underlying database supports it), you can use it:
select a.id as id,a.name as name,b.address as address
from Personal as a,Home as b
where cast(a.id as string) = b.studid
See also:
这篇关于如何用cast来编写hql查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文