5 Replies Latest reply on Nov 6, 2013 11:29 PM by Alexander Hartner

    No Dialect mapping for JDBC type: -9

    Alexander Hartner Expert

      Previously our application was using JTDS on JBoss 4/5, however for JBoss 7 we opted to migrate to the Microsoft driver. Most things are working, however this one query results in an error:

       

      public String getProject(int batchId) {
          try {
              String queryString = "SELECT PROJECTNAME FROM PROJECTS WHERE PROJECTID = (SELECT PROJECTID FROM BATCHES WHERE BATCHID=?1)";
              Query query = entityManager.createNativeQuery(queryString);
              query.setParameter(1, batchId);
              return query.getSingleResult().toString();
          }
          catch (javax.persistence.NoResultException re) {
              return "";
          }
      }
      

       

      The exceptions seems to be caused by the driver not being able to interpret the column type for PROJECTNAME which happens to be nvarchar(50)

      org.hibernate.MappingException: No Dialect mapping for JDBC type: -9

      I tried specifying the type using the following, but this didn't resolve the prolbem either, just produced a different exception: "Unknown entity: java.lang.String", which kind of does make sence since String is not an entity.

       

      Query query = m_entityManager.createNativeQuery(queryString,String.class);
      

       

      Any pointers on how to best resolve this. Is using the JTDS driver the recomended option or did I miss something on the configuration of the Microsoft driver.