-->
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: char(6) database field, only get the first character
PostPosted: Tue Jul 15, 2008 6:03 am 
Newbie

Joined: Tue Jul 15, 2008 5:33 am
Posts: 3
list = (List) entityManager .createNativeQuery(sb.toString()).getResultList();

if(list!=null){
Iterator it = list.iterator();
while(it.hasNext()){
Object[] row = (Object[])it.next();
System.out.println(row[1].toString());
}

query use jpa; but only get the first character of the char(6) ;

why?
thanks;


Top
 Profile  
 
 Post subject: Re: char(6) database field, only get the first character
PostPosted: Tue Jul 15, 2008 9:15 pm 
Newbie

Joined: Tue Jul 15, 2008 5:33 am
Posts: 3
no answer for this problem?
it puzzle me a long time.




springwinder wrote:
list = (List) entityManager .createNativeQuery(sb.toString()).getResultList();

if(list!=null){
Iterator it = list.iterator();
while(it.hasNext()){
Object[] row = (Object[])it.next();
System.out.println(row[1].toString());
}

query use jpa; but only get the first character of the char(6) ;

why?
thanks;


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 15, 2008 10:35 pm 
Newbie

Joined: Mon Jun 16, 2008 1:15 pm
Posts: 15
It sounds like a simple problem, but you have to show us what is in sb, so we can know whether your query is correct, and by the way what database is this? Maybe someone can try for you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 15, 2008 10:36 pm 
Newbie

Joined: Mon Jun 16, 2008 1:15 pm
Posts: 15
It sounds like a simple problem, but you have to show us what is in sb, so we can know whether your query is correct, and by the way what database is this? Maybe someone can try for you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 15, 2008 11:18 pm 
Newbie

Joined: Tue Jul 15, 2008 5:33 am
Posts: 3
sb = "select stockCode from table1";

(sqlserver2005)table1:
feild:
stockCode char(6);
stockName varchar(50);



list = (List) entityManager .createNativeQuery(sb.toString()).getResultList();

if(list!=null){
Iterator it = list.iterator();
while(it.hasNext()){
Object[] row = (Object[])it.next();
System.out.println(row[0].toString());
}



peiguo wrote:
It sounds like a simple problem, but you have to show us what is in sb, so we can know whether your query is correct, and by the way what database is this? Maybe someone can try for you.


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.