I’m using Spring Boot 3.4.5
(spring-boot-starter-parent
) with Hibernate 6.6.13.Final
and hibernate-community-dialects
, using Informix:
spring.jpa.database-platform=org.hibernate.community.dialect.Informix10Dialect
My repository looks like this:
@Repository
public interface PacIdRepo extends JpaRepository<PacId, Integer> {
List<PacId> findAllByUziv(String uziv, Pageable pageable);
PacId findFirstByUziv(String uziv);
}
Calls like:
PacId pacId = pacIdRepo.findFirstByUziv("someVal");
List<PacId> pacIds = pacIdRepo.findAllByUziv("someVal", PageRequest.of(0, 2));
fail with:
org.hibernate.sql.exec.ExecutionException: A problem occurred in the SQL executor : JDBC parameter value not bound - null
at org.hibernate.sql.ast.spi.AbstractSqlAstTranslator.lambda$renderFetchPlusOffsetExpressionAsSingleParameter$7(AbstractSqlAstTranslator.java:4793)
at org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.bindParameters(DeferredResultSetAccess.java:207)
I debugged DeferredResultSetAccess.bindParameters(...)
and placed a breakpoint at line 207. In both failing cases, the first item in the loop was:
0 = {AbstractSqlAstTranslator$lambda@16594}
arg$1 = null
arg$2 = {AbstractSqlAstTranslator$OffsetReceivingParameterBinder@16595}
It works fine if I replace findFirstByUziv
with a native query like:
@Query(value = "SELECT FIRST 1 * FROM PAC_ID p WHERE p.uziv = :uziv", nativeQuery = true)
PacId findFirstByUziv(@Param("uziv") String uziv);
Also, when using PageRequest.of(1, N)
(pageNum=1) with pageable queries, the issue does not occur.
This issue appears to be caused by Hibernate always expecting an additional argument for FIRST
which, when using 0
as page number or query derivation method like findFirst
, remains unset. In Hibernate 5.3.11 this worked fine without problems, and from experience with other projects using databases like PostgreSQL, this usage should be valid.
Is this a mistake on my side or is it a bug? Thanks in advance for any help or insights.