I am using the following native query to get info back from an informix DB. I am trying to use the setResultTransform method to map the results to a dto class. I got it to work, but had the following problem:
when I renamed the columns to "myFlag1,myFlag2", it converted them to lowercase. I had to define new setter methods in the java class "MyClass" so that the proper methods would be found for the columns.
For instance, the "myFlag1" column was actually returned as "myflag1" column. So I had to create a setter method of "setmyflag1(...)". I have to do this for every returned column. Any way around this? Is this an informix issue or a hibernate issue?
Here is the code:
Code:
String query =
"select tbl1.my_flag1 as myFlag1, " +
" tbl1.my_flag2 as myFlag2" +
"from tbl1 where tbl1.id = :id";
org.hibernate.Query q = ((Session)em.getDelegate()).createSQLQuery(query)
.addScalar("myFlag1",Hibernate.STRING)
.addScalar("myFlag2",Hibernate.STRING)
.setResultTransformer(Transformers.aliasToBean(MyClass.class));
q.setParameter("id", 1);
q.list();
Any help would be great!!!!!!!!!!!!!!!!