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
- Properly handle null likes Properly handle null values with like or contains. Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queri... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Properly handle null values inside queries using LIKE or CONTAINS. Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Properly handle null values inside queries using LIKE or CONTAINS. Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Properly handle null values inside queries using LIKE or CONTAINS. Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Properly handle null values inside queries using LIKE or CONTAINS. Null values are wrapped with a special handler when interacting with Hibernate. However, this becomes an issue for queries when LIKE... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Properly handle null mixed with LIKE. Resolves: #2653. Related: #2548, #2683, #2655, #2461, possibly #2544 — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Properly handle null mixed with LIKE. Resolves: #2653. Related: #2548, #2683, #2655, #2461, possibly #2544 — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Properly handle null mixed with LIKE. Resolves: #2653. Related: #2548, #2683, #2655, #2461, possibly #2544 — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- gh-2544 - Prepare branch — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Handle nulls in stored procedure parameterss properly. Hibernate supports TypedParameterValue in queries, but not stored procedures. Until https://github.com/hibernate/hibernate-orm/pull/5438 is ado... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Handle nulls in stored procedure parameters properly. Hibernate supports TypedParameterValue in queries, but not stored procedures. Until https://github.com/hibernate/hibernate-orm/pull/5438 is adop... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Handle nulls in stored procedure parameters properly. Hibernate supports TypedParameterValue in queries, but not stored procedures. Until https://github.com/hibernate/hibernate-orm/pull/5438 is adop... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Handle nulls in stored procedure parameters properly. Hibernate 6.1 properly handles TypeParameterValue for general parameters, but not for temporal ones. So we must dereference in those scenarios. ... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Handle nulls in stored procedure parameters properly. Hibernate 6.1 properly handles TypeParameterValue for general parameters, but not for temporal ones. So we must dereference in those scenarios. ... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
- Handle nulls in stored procedure parameters properly. Hibernate 6.1 properly handles TypeParameterValue for general parameters, but not for temporal ones. So we must dereference in those scenarios. ... — committed to spring-projects/spring-data-jpa by gregturn 2 years ago
@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?
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:
@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-M3and it failed the same. I also ran it against Spring Boot3.0.0-SNAPSHOTand 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.