jueves, 9 de febrero de 2017

Unknown Microsoft SQL Server major version [12] using SQL Server 2000 dialect

Spring Boot version: 1.5.1.RELEASE (Hibernate 5.0.11.Final)
Dependencies:

  • compile("org.springframework.boot:spring-boot-starter-batch")
  • compile('org.springframework.boot:spring-boot-starter-data-jpa') 
Fix:

The following property fixed the warning: spring.jpa.properties.hibernate.dialect (spring.jpa.databasePlatform didn't seem to have any effect)

spring:
  datasource:
    url: jdbc:sqlserver://localhost:1433;databaseName=xxx
    username: yyy
    password: zzz
    test-on-borrow: true
    validation-query: "select 1"
  jpa:
    generate-ddl: false
    database: sqlserver
    #databasePlatform: org.hibernate.dialect.SQLServer2012Dialect
    properties:
      delimited-identifiers: true
      hibernate:
        dialect: org.hibernate.dialect.SQLServer2012Dialect
    hibernate:
      ddl-auto: none
      naming:
        implicit-strategy: ...
        physical-strategy: ...

This also fixed the following error due to the dialect selection: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'.
...
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet

This is the bug fix for the automatic dialect selection for SQL Server 2014: https://github.com/hibernate/hibernate-orm/pull/1353 (for Hibernate 5.1)

No hay comentarios: