Hello,
I have a question regarding the DB2iDialect in Hibernate. It appears to support sequences and uses the following SQL to fetch sequence data:
SELECT DISTINCT sequence_name
FROM qsys2.syssequences
WHERE current_schema = '*LIBL'
AND sequence_schema IN (SELECT schema_name FROM qsys2.library_list_info)
OR sequence_schema = current_schema
However, the dialect uses SequenceInformationExtractorDB2DatabaseImpl, which extends SequenceInformationExtractorLegacyImpl. In the extractMetadata method, it triggers the above query and attempts to read several columns (e.g., sequence_name, start, increment, etc.). Since the query only returns sequence_name, this results in a runtime exception.
Am I missing something, or is it the case that DB2iDialect doesn’t support sequences?
Context:
-
I’m using a DB2 (IBM i V7R4M0) database.
-
I have a JPA entity that I cannot modify.
-
The entity uses
@GeneratedValue(strategy = GenerationType.AUTO). -
With Hibernate 5.6, the dialect defaults to SEQUENCE, but I was able to override this by setting:
spring.jpa.hibernate.use-new-id-generator-mappings=falseThis forced Hibernate to use the IDENTITY strategy instead, which worked fine.
Now I’m upgrading to Spring Boot 3.6.4 and Hibernate 6. This property has been removed, and I haven’t found an alternative. Since I cannot change the generation type on the entity, I’m trying to switch to using sequences — but the current dialect setup fails due to the issue above.
Questions:
-
Is
DB2iDialectsupposed to support sequences properly in Hibernate 6? -
Is there a workaround or recommended approach for this situation, given the limitations?
Thanks in advance!