[jboss-user] [EJB 3.0 Users] - Can't read with native query a type of CHAR(2)

jadtn@laposte.net do-not-reply at jboss.com
Sun Aug 23 11:19:20 EDT 2009


Hello
I'm working with mysql 5 / jboss4.2.2/EJB3/JDK6
I want from a nativequery read a field of CHAR(n) in a database, when I user varchar , it s works, but if i use char(n), I always get a Character instead of a String.


  | CREATE TABLE testchar(
  | myid CHAR(2) PRIMARY KEY
  | )

When i user native query to retrive data then I get a java.lang.Character instead of a String.


  | q=em.createNativeQuery("SELECT myid FROM testchar");
  | q.setMaxResults(2);
  | List<Object[]> r= q.getResultList();
  | log.info("class="+ r.get(0).getClass()+" "+r.get(0));
  |  -->return java.lang.Character and value is the first character of the row

There is someone who have an idea of what is wrong?
Thanks

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251037#4251037

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4251037



More information about the jboss-user mailing list