1

i have a native sql query to transform (aliasToBean) to a bean with a boolean value.

My query can be something like this:

select val IS NOT NULL as boolValue , ...

or this:

select 1=0 as boolValue, ...

I can not understand how to let Hibernate knows that my bean.boolValue is a Boolan because I get errors in type conversion, in the first case I get a java.math.BigInteger in the second a java.lang.Integer.

Thank you.

1 Answer 1

2

You need to tell Hibernate that this column is a boolean, with the SQLQuery.addScalar() method.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you but how to tell if I have a namedQuery instead of a runtime query?
There are corresponding return-scalar XML elements, as the javadoc I linked to indicates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.