Skip to content

Incompatible with spring-data-jpa 3.5.0 #251

Closed
@dmarotta77

Description

@dmarotta77

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

Activity

dmarotta77

dmarotta77 commented on May 23, 2025

@dmarotta77
ContributorAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Incompatible with spring-data-jpa 3.5.0 · Issue #251 · Cosium/spring-data-jpa-entity-graph