2 Replies Latest reply on Feb 25, 2009 6:38 AM by stephen.friedrich

    Maybe a bug on EntityManager.createNativeQuery(String)

    Alexandre Petrillo Newbie

      I need to do some sql native query (to a data base Oracle 9i) from an EJB session Bean.
      I use Jboss in version 4.0.4 G.A. patch 1

      My simple code :

      public List doNativeQueryMultiple(String sqlQuery) {
      List list = manager.createNativeQuery(sqlQuery).getResultList();
      return list;
      }

      This is some exemple for understand the probleme.

      SELECT 'OUI' val FROM dual union SELECT 'NON' FROM dual Order BY 1 asc
      Response is : O,N
      SELECT 'TOTO' val FROM dual union SELECT 'NON' FROM dual Order BY 1 asc
      Response is : TOTO,NON
      SELECT 'TOT' val FROM dual union SELECT 'NON' FROM dual Order BY 1 asc
      Response is : T,N
      SELECT 'OUI' val FROM dual union SELECT 'abc' FROM dual Order BY 1 asc
      Response is : O,a
      SELECT 'OUI' val FROM dual union SELECT 'abcd' FROM dual Order BY 1 asc
      Response is : OUI,abcd
      SELECT 'OUI' val FROM dual union SELECT 'NON' FROM dual union SELECT 'TOT' FROM dual Order BY 1 asc
      Response is : O,N,T
      SELECT 'OUI' val FROM dual union SELECT 'NON' FROM dual union SELECT 'TOTO' FROM dual Order BY 1 asc
      Response is : OUI,NON,TOTO


      When the response of the request is correct, the return class type is java.lang.String
      And when is incorrect , the return class type is java.lang.Charactere, and the response contain the first letter.

      The bug is when the size of all of the selected string have the same length.
      The test done by Jboss for determine the class return type maybe is wrong.