JPA SQL Server No Dialect mapping for JDBC type: -9

后端 未结 5 1604
终归单人心
终归单人心 2020-11-27 22:06

Iam writing a native query like

Query query = 
  entityManagerUtil.getEntityManager().createNativeQuery(\"SELECT c.NodeID,c.Code,c.Name FROM COM_Location c\"         


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 22:32

    I had a similar issue, my sql is this

    Query nmspQuery = em.createNativeQuery("select aster from MyTable where my_column = 1001")
    

    The datatype for PRODUCT_NODE_ONIX_TYPE in the Oracle 11g is nvarachar2

    I fixed it by casting the value astr to to_char. This worked fine

    Query nmspQuery = em.createNativeQuery("select TO_CHAR(aster) from MyTable where my_column = 1001")
    

提交回复
热议问题