Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Dialect mapping for JDBC type: 1111

I'm working on a Spring JPA Application, using MySQL as database. I ensured that all spring-jpa libraries, hibernate and mysql-connector-java is loaded.

I'm running a mysql 5 instance. Here is a excerpt of my application.properties file:

spring.jpa.show-sql=false spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect  spring.datasource.url=jdbc:mysql://localhost/mydatabase spring.datasource.username=myuser spring.datasource.password=SUPERSECRET spring.datasource.driverClassName=com.mysql.jdbc.Driver 

When executing an integration test, spring startsup properly but fails on creating the hibernate SessionFactory, with the exception:

org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111 

I think my dialects should be Mysql5Dialect, I also tried the one explicitly stating InnoDB, and the two dialect options which don't indicate the version 5. But I always end up with the same 'No Dialect mapping for JDBC type: 1111' message. My application.properties file resides in the test/resources source folder. It is recognized by the JUnit Test runner (I previously got an exception because of an typo in it).

Are the properties I'm setting wrong? I couldn't find some official documentation on these property names but found a hint in this stackoverflow answer: https://stackoverflow.com/a/25941616/1735497

Looking forward for your answers, thanks!

BTW The application is already using spring boot.

like image 667
SakeSushiBig Avatar asked Jan 28 '15 12:01

SakeSushiBig


People also ask

What is JDBC Type?

The JDBC type system mediates the conversion between SQL Server data types and Java language types and objects. The JDBC types are modeled on the SQL-92 and SQL-99 types. The JDBC driver adheres to the JDBC specification and is designed to provide the right balance between predictability and flexibility.


2 Answers

I got the same error because my query returned a UUID column. To fix that I returned the UUID column as varchar type through the query like "cast(columnName as varchar)", then it worked.

Example:

public interface StudRepository extends JpaRepository<Mark, UUID> {      @Modifying     @Query(value = "SELECT Cast(stuid as varchar) id, SUM(marks) as marks FROM studs where group by stuid", nativeQuery = true)     List<Student> findMarkGroupByStuid();      public static interface Student(){         private String getId();         private String getMarks();     } } 
like image 68
Ramya Avatar answered Sep 29 '22 11:09

Ramya


Here the answer based on the comment from SubOptimal:

The error message actually says that one column type cannot be mapped to a database type by hibernate. In my case it was the java.util.UUID type I use as primary key in some of my entities. Just apply the annotation @Type(type="uuid-char") (for postgres @Type(type="pg-uuid"))

like image 32
SakeSushiBig Avatar answered Sep 29 '22 12:09

SakeSushiBig