Skip to content

Incompatible with spring-data-jpa 3.5.0 #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmarotta77 opened this issue May 23, 2025 · 1 comment
Closed

Incompatible with spring-data-jpa 3.5.0 #251

dmarotta77 opened this issue May 23, 2025 · 1 comment

Comments

@dmarotta77
Copy link
Contributor

dmarotta77 commented May 23, 2025

What steps will reproduce the problem ?

Steps to reproduce the behavior:

  1. Clone the Cosium/spring-data-jpa-entity-graph project from GitHub.
  2. In the pom.xml file of the cloned project, set the <spring.data.jpa> property to 3.5.0.
  3. Run test

What is the expected output ?

The project should build successfully, and all existing tests should pass without errors, demonstrating compatibility with Spring Data JPA 3.5.0.

What happens instead ?

Existing tests fail with java.lang.IllegalArgumentException. Specifically, many tests produce the following error:

Caused by: java.lang.IllegalArgumentException: At least 2 parameter(s) provided but only 1 parameter(s) present in query

Environment

  • Spring Data JPA version: 3.5.0
  • spring-data-jpa-entity-graph version: 3.2.3
@dmarotta77
Copy link
Contributor Author

dmarotta77 commented May 23, 2025

Proposed Fix for Spring Data JPA 3.5.0 Incompatibility

I've investigated this incompatibility with Spring Data JPA 3.5.0 and have a proposed fix.

The changes involve two parts:

  1. pom.xml modification:
    I updated the spring.data.jpa dependency version:

    <spring.data.jpa>3.2.1</spring.data.jpa>

    to

    <spring.data.jpa>3.5.0</spring.data.jpa>
  2. EntityGraphAwareJpaQueryMethod.java class update:
    The EntityGraphAwareJpaQueryMethod class needs to be updated to support the new JpaQueryMethod constructor signature in Spring Data JPA 3.5.0. Here's the updated class:

    package com.cosium.spring.data.jpa.entity.graph.repository.query;
    
    import java.lang.reflect.Method;
    import org.springframework.data.jpa.provider.QueryExtractor;
    import org.springframework.data.jpa.repository.query.JpaQueryMethod;
    import org.springframework.data.projection.ProjectionFactory;
    import org.springframework.data.repository.core.RepositoryMetadata;
    import org.springframework.data.repository.query.Parameters;
    import org.springframework.data.repository.query.ParametersSource;
    
    /**
     * @author Réda Housni Alaoui
     */
    class EntityGraphAwareJpaQueryMethod extends JpaQueryMethod {
    
      protected EntityGraphAwareJpaQueryMethod(
          Method method,
          RepositoryMetadata metadata,
          ProjectionFactory factory,
          QueryExtractor extractor) {
        super(method, metadata, factory, extractor, EntityGraphAwareJpaParameters::new);
      }
    }

These changes have passed all unit tests on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants