-->
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.  [ 3 posts ] 
Author Message
 Post subject: createSQLQuery returns only first character
PostPosted: Fri Jan 21, 2011 5:18 am 
Newbie

Joined: Fri Jan 21, 2011 5:12 am
Posts: 2
Dear all,

I am new to hibernate and have only been working on this for 2 months or so. Recently I hit this problem which I feel really strange. The following is my code :
Code:
      String queryStr =    "SELECT a.assignmentID, a.assignmentName, a.assignmentStatus, b.accountCompany " +
                     "FROM Assignment a INNER JOIN Account b " +
                     "ON a.assignmentClient = b.accountID " +
                     "WHERE b.accountRole = 3 AND b.accountID = 10";
      Session session = HibernateUtil.getSession(getSessionFactoryNumber());
      List<Object[]> query = session.createSQLQuery(queryStr)
                              .list();
      
      for(Object[] o : query){
         for(Object oo : o){
            System.out.println(oo.toString());
         }
      }




The SQL code, if run on SQL client, will return the following
6;"Put Your Hands";1;"M. Brown"

Yet on the printing, it shows only the first character of each column, ie:
6,P,1,M

does anyone know the reason for this? Thank you!


Top
 Profile  
 
 Post subject: Re: createSQLQuery returns only first character
PostPosted: Mon Jan 24, 2011 2:50 am 
Newbie

Joined: Fri Jan 21, 2011 5:12 am
Posts: 2
seems like no one knows the answer for this mysterious problem~ could it be the configuration? or could it be a bug??


Top
 Profile  
 
 Post subject: Re: createSQLQuery returns only first character
PostPosted: Tue Feb 15, 2011 3:01 am 
Newbie

Joined: Tue Feb 15, 2011 2:56 am
Posts: 1
Looks like a bug to me. Somehow Hibernate does not care what is the length of a character (in DB). Solution is to use addScalar function.


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

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.