How to integrate SQLite with Spring Boot having Hiberate 6

I’m trying to integrate SQLite.
For that before hibernate 6 we were able to do it by using class extending Dialect
but from hibernate 6 onwards registerColumnType and registerFunction methods, StandardSQLFuntion(String, Type registeredType) are not available anymore how can I overcome this issue in hibernate 6?

registerColumnType(Types.BIT, "integer");
   	registerColumnType(Types.TINYINT, "tinyint");
   	registerColumnType(Types.SMALLINT, "smallint");
   	registerColumnType(Types.INTEGER, "integer");
   	registerColumnType(Types.BIGINT, "bigint");
   	registerColumnType(Types.FLOAT, "float");
   	registerColumnType(Types.REAL, "real");
   	registerColumnType(Types.DOUBLE, "double");
   	registerColumnType(Types.NUMERIC, "numeric");
   	registerColumnType(Types.DECIMAL, "decimal");
   	registerColumnType(Types.CHAR, "char");
   	registerColumnType(Types.VARCHAR, "varchar");
   	registerColumnType(Types.LONGVARCHAR, "longvarchar");
   	registerColumnType(Types.DATE, "date");
   	registerColumnType(Types.TIME, "time");
   	registerColumnType(Types.TIMESTAMP, "timestamp");
   	registerColumnType(Types.BINARY, "blob");
   	registerColumnType(Types.VARBINARY, "blob");
   	registerColumnType(Types.LONGVARBINARY, "blob");
   	// registerColumnType(Types.NULL, "null");
   	registerColumnType(Types.BLOB, "blob");
   	registerColumnType(Types.CLOB, "clob");
   	registerColumnType(Types.BOOLEAN, "integer");

   	registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
   	registerFunction("mod", new SQLFunctionTemplate(StringType.INSTANCE, "?1 % ?2"));
   	registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
   	registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));

The hibernate-community-dialects module comes with a SQLite dialect: hibernate-orm/SQLiteDialect.java at main · hibernate/hibernate-orm · GitHub

Use that one

1 Like

Thank you for solution :100:

Can you post the actual solution? Using the driver still fails to connect for me. I was able to connect to MySQL, H2, and Postgres, but SQLite is failing.

driver = “com.mysql.cj.jdbc.Driver”;
dialect = "org.hibernate.community.dialect.SQLiteDialect ";

You are trying to use the MySQL driver to connect to a SQLite database? Maybe you should think about what you wrote here or at least re-read it before clicking reply :wink: