hibernate查询只返回字符串的第一个字符 [英] hibernate query returns only first character of string

查看:363
本文介绍了hibernate查询只返回字符串的第一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在oracle 10g中使用sqldeveloper运行这样的查询时,它运行良好。

 从emp中选择'Canada'作为country,emp.name作为name。 

给我的名字和国家。
当我在hibernate中将它作为命名查询运行时,我只得到'C'而不是'Canada'作为country。

为什么会这样

解决方案

选择Cast('Canada'as varchar2(100))ascountry,emp.name asname从emp。

When I run a query like this in oracle 10g using sqldeveloper, it runs fine.

select 'Canada' as "country", emp.name as "name" from emp.

Gives me the name and country. When I run it in hibernate as a named query, I get only 'C' instead of 'Canada' for "country".

Why is this so?

解决方案

select cast('Canada' as varchar2(100)) as "country", emp.name as "name" from emp.

这篇关于hibernate查询只返回字符串的第一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆