spring-data-jpa: Passing null as stored procedure argument is broken in v2.7.0 (works in v2.6.8).

With spring.jpa.properties.hibernate.proc.param_null_passing=true we can pass null as stored procedure as parameter without any problem with Spring Boot 2.6.8 but upgrading to v2.7.0 throws exception with the same Hibernate version. I’ve tried only with PostgreSQL and UUID as procedure parameter but I suppose it could be for any type of DB and parameters. The exception is: Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Bind value [org.hibernate.jpa.TypedParameterValue@5b1420f9] was not of specified type [class java.util.UUID; nested exception is java.lang.IllegalArgumentException: Bind value [org.hibernate.jpa.TypedParameterValue@5b1420f9] was not of specified type [class java.util.UUID

Example:

public interface TestModelRepository extends JpaRepository<TestModel, Long> {
  @Procedure("countByUuid")
  void countUuid(UUID one);
}

then just call testModelRepository.countUuid(null). I’ve prepared a sample project to reproduce the problem, just change Spring Boot version to 2.6.8 and it works fine: https://github.com/denis111/spring-data-jpa270test

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 22 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@gregturn it looks like it didn’t get to Spring Boot 2.7.7 (I’ve updated my test project), should we wait for 2.7.8 or it will never be included in 2.7.x branch?

is this still broken with 2.7.3? we downgraded to 2.6.8, waiting for the fix.

It should fixed in 2.7.3, but it’s not released yet. @gregturn

Seems like there is a dependency mismatch. Using springboot-starter-data-jpa 2.7.8 it works, and it has the transient dependency to spring-data-jpa 2.7.7.

Thank you for that analysis, but can you do one for what happened between 2.6.8 and 2.7.0? It was working and then not anymore.

On Fri, 16 Dec 2022 at 06:18, Greg L. Turnquist @.***> wrote:

The issue was clearly mended when Spring Data JPA moved to Hibernate 6 in Spring Boot 3.0.0-M4 (Spring Data 2022.0.0-M5).

You can see ALL the changes that happened in Spring Data JPA https://github.com/spring-projects/spring-data-jpa/compare/3.0.0-M4...3.0.0-M5 between 3.0.0-M4 and 3.0.0-M5, and nothing stands out except upgrading to Hibernate 6 and properly handling nulls for LIKEs. The former will never be backported to 2.7.x and the latter already has been in 2.7.6.

— Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-data-jpa/issues/2544#issuecomment-1353432200, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHK5HNKSI5OAWG6ADOHJHTWNNHGBANCNFSM5WWOS37Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

@denis111 It should be fixed at hibernate side, I have created https://github.com/hibernate/hibernate-orm/pull/5438

I’ve just tried 2.7.4 and the issue is still there, I have updated my test project.

I ran your code against Spring Boot 3.0.0-M3 and it failed the same. I also ran it against Spring Boot 3.0.0-SNAPSHOT and it worked. I’d like to pinpoint the patch so I can assess whether it’s a candidate for backporting.

Can also confirm the issue still resides in Spring Boot 2.7.2-SNAPSHOT, so a patch that wasn’t backported.