我遇到 nvarchar 类型的SQL Server问题,需要在Spring Boot Application中注册它。由于我正在调用现有的存储过程,因此我没有选择强制转换为查询。请建议我是否有其他方法来处理 nvarchar
我正在使用JPA存储库来调用存储过程
@Repository
public interface CustomRepo extends JpaRepository<ArchEntity, Long> {
@Query(value = "{call dbo.storedproc(:objectType)}", nativeQuery = true)
public List<Object> getData(@Param("objectType") String type);
}
属性
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.datasource.initialize=false
spring.datasource.url=jdbc:sqlserver:**********
spring.datasource.username=*****
spring.datasource.password=*****
例外是
2018-11-13 09:43:02 - Servlet.service() for servlet
[dispatcherServlet] in context with path [] threw exception [Request
processing failed; nested exception is
org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC
type: -9; nested exception is org.hibernate.MappingException: No Dialect
mapping for JDBC type: -9] with root cause
org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
at org.hibernate.dialect.TypeNames.get(TypeNames.java:70)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:101)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:666)
at