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.  [ 2 posts ] 
Author Message
 Post subject: createSQLquery().list() returns strange values
PostPosted: Tue Sep 28, 2010 11:17 pm 
Newbie

Joined: Tue Sep 28, 2010 10:46 pm
Posts: 2
I use Hibernate 3.3.2 GA with MySQL 5.1. I try to use session.createSQLquery(string SQL).list(), but can't get right answer back. I find the problem may be caused of db table schema. We have a db table named stock_info includes CODE and PRICE two fileds and contains 100 records inside. For example {(1001, 10.8), (1002, 2.5), (1003, 4.7), ... }. SQL script is "SELECT CODE, PRICE FROM STOCK_INFO". There is no problem I run it using JDBC directly. If I use session.createSQLquery(string SQL).list(), I always get result {(1, 10.8), (1, 2.5), (1, 4.7), ..} back. The values of CODE is replaced by Hibernate, but others not. Is the word "CODE" reserved in Hibernate? I try many different tables have filed named CODE, and all of them got same error. Can anybody help? Thank for you kindly reply in advance.


Top
 Profile  
 
 Post subject: Re: createSQLquery().list() returns strange values
PostPosted: Tue Sep 28, 2010 11:32 pm 
Newbie

Joined: Tue Sep 28, 2010 10:46 pm
Posts: 2
I know what's the problem. HB cast string type to char(1), so I have to addScalar("CODE", HB.STRING). Is it a bug ?? or I just don't know how to use it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.