Spring Data JPA add support to Set-returning Functions in from
Clause
#3864
Labels
status: waiting-for-triage
An issue we've not yet triaged
Spring Data JPA add support to Set-returning Functions in
from
ClauseContext
This test suite test suite demonstrates the current behavior of Spring Data JPA when handling SQL set-returning functions (SRF) in the
FROM
clause, as described in the Hibernate ORM documentation. While such queries work correctly when executed directly via Hibernate (e.g., throughEntityManager
) or declared with@NativeQuery
, they currently cause aBeanCreationException
when used in a Spring Data JPA repository method.This does not necessarily indicate a limitation, but rather that support for this pattern may not yet have been considered or integrated into the Spring Data JPA query parser. This document can serve as a reference for evaluating the possibility of supporting this usage in future versions.
Spring Boot Versions
We test the same codebase using different POM files to control the Spring Boot version:
-f
parameter).-f pom350RC1.xml
.-f pom400SNAP.xml
.Hibernate
All examples use Hibernate 7.0.0.CR1 and JPA 3.2.
Function Mapping
The PostgreSQL set-returning function is mapped using a custom
FunctionContributor
, allowing us to call:The mapped function returns a result set that can be queried via JPQL.
Repository Tests
1.
DepartmentSpringDataRepositorySimpleTest
findAll()
test using Spring Data JPA.@NativeQuery
, introduced in Spring Data 3.2.2.
DepartmentManualRepositoryTest
EntityManager
.3.
DepartmentSpringDataRepositoryTest
from
clause.EntityManager
.Query Constants
Summary
from get_department_function(:date)
.See also: Hibernate 7 User Guide - Set-returning functions
The text was updated successfully, but these errors were encountered: