-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: native query: setTransform
PostPosted: Sat Dec 18, 2010 1:06 pm 
Newbie

Joined: Wed Oct 20, 2010 11:22 am
Posts: 14
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!!!!!!!!!!!!!!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.