-->
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.  [ 5 posts ] 
Author Message
 Post subject: Database char(8) returning Character
PostPosted: Tue Mar 03, 2009 6:21 pm 
Newbie

Joined: Mon Mar 02, 2009 3:06 pm
Posts: 5
I am trying to use SQLQuery and we have a column that is a char(8) and our internal mappings map it to a java.lang.String. I am trying to do a fetch using the SQLQuery object and it is only returning the first character of the char field.

Is there a way to return the whole column and not just the first character?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 5:08 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Probably the simplest solution is to convert your char-column to a varchar within your native query.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 10:51 am 
Newbie

Joined: Mon Mar 02, 2009 3:06 pm
Posts: 5
I've never had to do that before, can you give me an example how?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 11:30 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
I think it depends on your database. Normally its like "select CAST ( yourCharColumn AS varchar(8)) as yourColumn from..."

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 12:14 pm 
Newbie

Joined: Mon Mar 02, 2009 3:06 pm
Posts: 5
kudos to you!!!

It works now.

Thanks.


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