Spring Boot + Spring JPA: Fix Hibernate Dialect Mapping Error

Hibernate with Spring JPA along with Spring Boot makes it easy for user to manage their database connection. However there are certain column type that is not mapped by default by Hibernate. For an example column type nvarchar in MSSQL could lead to an exception.

Hibernate with Spring JPA along with Spring Boot makes it easy for user to manage their database connection. However there are certain column type that is not mapped by default by Hibernate. For an example column type nvarchar in MSSQL could lead to an exception.

This can be easily fix by adding a custom SQL Dialect. Here is an example of a typical application.yml without custom SQL dialect

To fix this you will have to create a custom SQL dialect which will map nvarchar to a respective type

Finally inform Spring Boot to use this dialect instead of the defaultĀ org.hibernate.dialect.SQLServer2012Dialect.

This should fixed the mapping exception.

Author: Rashidi Zin

I write code and run on the road.