5

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?

Victor
  • 16,609
  • 71
  • 229
  • 409

1 Answers1

12
select cast('Canada' as varchar2(100)) as "country", emp.name as "name" from emp
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Victor
  • 16,609
  • 71
  • 229
  • 409
  • interesting! it also worked for me! thanks! but why do we need to do this cast solution, if it works perfectly when we run the query? what's the difference? – periback2 Feb 28 '14 at 20:33
  • @periback2 this answers the question https://stackoverflow.com/questions/4873201/hibernate-native-query-char3-column – andrei Oct 20 '20 at 17:45