(Feature request) when using spring-integration-jdbc and HANA DB
In what version(s) of Spring Integration are you seeing this issue?
5.5.14
Describe the bug
Unable to start my spring-boot service when using spring-integration-jdbc and HANA DB. It looks like that it is not possible to determinate the database type when I am injecting my datasource (which uses HANA DB) to the org.springframework.integration.jdbc.lock.LockRepository. This exception is raised:
2023-02-06 14:13:28,361 WARN [restartedMain] - [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext] [] - Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'integrationDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration$IntegrationJdbcConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer]: Factory method 'integrationDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
I am using Hikari datasource, Hibernate and spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HANAColumnStoreDialect.
Expected behavior
I would expect that spring-integration-jdbc is compatible with HANA DB, but I might have wrongly assumed this. Does spring-integration-jdbc supports HANA DB? In that case this bug issue could be flagged rather as a feature request.
That's wrong assumption. Better to check docs before going into the woods: https://docs.spring.io/spring-integration/reference/html/jdbc.html#supported-databases.
Hibernate and Hikari has nothing to do with this LockRepository implementation.
I'd suggest you to back off Spring Boot database auto-creation and provide respective DB tables yourself.
You can borrow an SQL script from existing DB support: https://github.com/spring-projects/spring-integration/tree/main/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc
With this ticket we probably can take a look into including a support for this DB. Just need to understand how popular it is and if it has an open source JDBC driver.
Hello, you are right, there is no support for SAP HANA DB at the moment, I did not check the docs properly.
Actually, in my app, the int_lock table was already provided (as I have no permission to create tables from within the app), but I guess it will still fail as the other tables are somehow required. I am just interested in the LockRepository part of spring-integration-jdbc, but I imagine the support for the HANA DB has to be integrated fully in spring-integration-jdbc.
I noticed that SAP HANA DB support was recently added to spring-batch project here: https://github.com/spring-projects/spring-batch/issues/1087, so I guess that is a good point to consider this DB as a popular candidate.
I would be happy to help in this integration. How exactly could I help?
If you don't use any other Spring Integration JDBC features, you don't need other tables, just that INT_LOCK.
For contributing such a support back to the framework, please, look first into general Contribution Guideline: https://github.com/spring-projects/spring-integration/blob/main/CONTRIBUTING.adoc.
Then you need to open pull request against this issue and add something like schema-hana.sql, schema-drop-hana.sql alongside with existing schema-h2.sql, schema-mysql.sql etc.
Next you go to org.springframework.integration.jdbc.store.channel package and implement an AbstractChannelMessageStoreQueryProvider for HANA.
Another way might be a simple remapping fix in Spring Boot, if HANA is fully compatible with existing DB schema. For example we have over there a mapping like this:
platformResolver.withDriverPlatform(DatabaseDriver.MARIADB, "mysql")
We definitely need to know what is a databaseMetaData.getDatabaseProductName() for this DB to be able to map it properly in Spring Boot in the end for IntegrationDataSourceScriptDatabaseInitializer...