Description
Jakarta persistence 3.1.0
SpringBoot 3.5.+
Database SAP Hana HDB 2.0
Hibernate 6.6.18.Final
Java 17
I am writing to get current value/next value for generated sequences.
The correct way to get sequences in Hana are:
SELECT <schema name>."<sequence name>".CURRVAL from DUMMY
to get the current value of a sequence
SELECT <schema name>."<sequence name>".NEXTVAL from DUMMY
to get the next value of a sequence
In Hana double quotes around sequence name are mandatory
This is the code I try to use:
String sequenceNameTag = "_sequence";
String getCurrentSapHanaSequence= "SELECT {h-schema}:" + sequenceNameTag + ".CURRVAL FROM DUMMY";
@Query(value = getCurrentSapHanaSequence, nativeQuery = true) Long getCurrentSequenceSapHana( @Param(sequenceNameTag ) String sequenceName );
This is the response:
No argument for named parameter ':_sequence.CURRVAL'
The same behaviour trying to get NEXTVAL.
I also tried to add double quote around sequence name, but raises an sql syntax exception and the query is not fired.
I don't know if there is a way to make these queries run properly.
Thanks in advance