1

I am getting an exception while using a native query nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -15

my code is

String sqlQuery = "select emp_id, name, address, dept from employee  where dept in ( Select dept  from department  where status=:status)";
Map<String, Object> queryParams = new HashMap<>();
queryParams.put("status", "Active");
Query sqlQuery = entityManager.createNativeQuery(query.toString());
queryParams.forEach(sqlQuery::setParameter);
List queryResults = (List) sqlQuery.getResultList(); // This line is throwing exception

Database I am using is : SQLServer 2012. DB Config is :

spring.datasource.username=testUser
spring.datasource.password=******
spring.datasource.url=jdbc:sqlserver://server:port;databaseName=testDB;
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.hikari.maximum-pool-size=75
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.minimum-idle=10

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.id.new_generator_mappings=false
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.generate_statistics=false
spring.jpa.properties.hibernate.default_batch_fetch_size=100
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

Praful Jha
  • 187
  • 4
  • 18

1 Answers1

0

I really don't know how looks you JPA for employee and department, but I see that you selecting dept from two different tables and you need some how-to differentiate these columns.

String sqlQuery = "select emp_id as emp_id  , name as name , address address, dept as dept  from employee  where dept in ( Select dept as dept_department  from department  where status=:status)";

see the following question.. Spring Data JPA map the native query result to Non-Entity POJO

Happy Coder
  • 1,293
  • 1
  • 19
  • 35