You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quarkus is not automatically generating a method to count entities in a one-to-many relationship where the parent entity has a child entity with a specific attribute, without needing to provide a custom JPQL query.
Expected behavior
Spring Data JPA is capable of automatically generating a method to count entities in a one-to-many relationship where the parent entity has a child entity with a specific attribute, without needing to provide a custom JPQL query. You can define the method signature in the repository interface, and Spring Data JPA will create the query for you based on the method name.
Assuming you have a Parent entity with a List relationship, and the Child entity has a name attribute, here's how you could define the method:
Repository Interface:
public interface ParentRepository extends JpaRepository<Parent, Long> {
long countByChildren_Nombre(String nombre);
}
This method should count Parent entities that have children where the child's nombre matches the given value.
Actual behavior
The method is generated but the he following error is thrown when called:
Suppressed: org.hibernate.query.PathException: Plural path 'at.atc.database.entities.Parent(1).children' refers to a collection and so element attribute 'name' may not be referenced directly (use element() function)
Just run mvn clean test and the test will fail
Or start the application with mvn clean compile quarkus:dev and call the endpoint http://localhost:41000/test/rest/parents/1
Output of uname -a or ver
Darwin amunozhe-mac 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 arm64
Output of java -version
openjdk version "21.0.3" 2024-04-16 LTS
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version or gradlew --version)
No response
Additional information
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
Quarkus is not automatically generating a method to count entities in a one-to-many relationship where the parent entity has a child entity with a specific attribute, without needing to provide a custom JPQL query.
Expected behavior
Spring Data JPA is capable of automatically generating a method to count entities in a one-to-many relationship where the parent entity has a child entity with a specific attribute, without needing to provide a custom JPQL query. You can define the method signature in the repository interface, and Spring Data JPA will create the query for you based on the method name.
Assuming you have a Parent entity with a List relationship, and the Child entity has a name attribute, here's how you could define the method:
Repository Interface:
This method should count Parent entities that have children where the child's nombre matches the given value.
Actual behavior
The method is generated but the he following error is thrown when called:
How to Reproduce?
Here updated reproducer:
reproducerJPAListPropertyExpression.zip
Just run
mvn clean test
and the test will failOr start the application with mvn clean compile quarkus:dev and call the endpoint http://localhost:41000/test/rest/parents/1
Output of
uname -a
orver
Darwin amunozhe-mac 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 arm64
Output of
java -version
openjdk version "21.0.3" 2024-04-16 LTS
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: