I was changing the database of my project from H2 to SQLite, and these errors appeared. How can I fix them?
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.sqlite.hibernate.dialect.SQLiteDialect.<init>(SQLiteDialect.java:58)
The following method did not exist:
'void org.sqlite.hibernate.dialect.SQLiteDialect.registerColumnType(int, java.lang.String)'
The calling method's class, org.sqlite.hibernate.dialect.SQLiteDialect, was loaded from the following location:
jar:file:/C:/Users/hbyeon/.m2/repository/com/github/gwenn/sqlite-dialect/0.1.4/sqlite-dialect-0.1.4.jar!/org/sqlite/hibernate/dialect/SQLiteDialect.class
The called method's class, org.sqlite.hibernate.dialect.SQLiteDialect, is available from the following locations:
jar:file:/C:/Users/hbyeon/.m2/repository/com/github/gwenn/sqlite-dialect/0.1.4/sqlite-dialect-0.1.4.jar!/org/sqlite/hibernate/dialect/SQLiteDialect.class
The called method's class hierarchy was loaded from the following locations:
org.sqlite.hibernate.dialect.SQLiteDialect: file:/C:/Users/hbyeon/.m2/repository/com/github/gwenn/sqlite-dialect/0.1.4/sqlite-dialect-0.1.4.jar
org.hibernate.dialect.Dialect: file:/C:/Users/hbyeon/.m2/repository/org/hibernate/orm/hibernate-core/6.5.3.Final/hibernate-core-6.5.3.Final.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.sqlite.hibernate.dialect.SQLiteDialect
This is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>task</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>task</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>23</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.github.gwenn</groupId>
<artifactId>sqlite-dialect</artifactId>
<version>0.1.4</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
And this is my application.properties
spring.application.name=task
spring.datasource.url=jdbc:sqlite:mydatabase.db
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.jpa.database-platform=org.hibernate.dialect.SQLiteDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
Previously, I had a error saying "Unable to resolve name org.hibernate.dialect.SQLiteDialect", which I resolved by adding the sqlite-dialect dependency to my pom.xml file. However, now these new errors are appearing.
And with this error, I tried to delete the .m2 folder in c:\users\ and close the project and open again, but not working.
This is the correct setting of SQLite dialect for Hibernate:
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-community-dialects</artifactId>
</dependency>
spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect
Based on: https://discourse.hibernate.org/t/sqlite-not-working-with-hibernate-6-2/8174/2