Uploaded image for project: 'Spring Data JPA'
  1. Spring Data JPA
  2. DATAJPA-1223

SPeL Processor Auto-Increment the Synthetic Value for Same Mapped Value

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Spring Boot 1.5.7.RELEASE

      Description

      I have a query that reuses the same mapped element in spel:

      That's my basic query:

      static final String basicQuery ="e.exerciseAttributes.strength >= :#{#program.minExerciseAttributes.strength} and "
      			+ "e.exerciseAttributes.endurance >= :#{#program.minExerciseAttributes.endurance} and "
      			+ "e.exerciseAttributes.balance >= :#{#program.minExerciseAttributes.balance} and "
      			+ "e.exerciseAttributes.strength <= :#{#program.maxExerciseAttributes.strength} and "
      			+ "e.exerciseAttributes.endurance <= :#{#program.maxExerciseAttributes.endurance} and "
      			+ "e.exerciseAttributes.balance <= :#{#program.maxExerciseAttributes.balance} and "
      			+ "e not in (select prepExercises from Program as program inner join program.prepExerciseList prepExerciseList join prepExerciseList.exerciseItems prepExercisesItems inner join prepExercisesItems.exercise prepExercises where program = :#{#program}) and "
      			+ "e not in (select postExercises from Program as program inner join program.postExerciseList postExerciseList join postExerciseList.exerciseItems postExercisesItems inner join postExercisesItems.exercise postExercises where program = :#{#program})"; 
      
      	@Query(name="Exercise.findAllByScore",value="select e from Exercise e where "
      			+ basicQuery)
      	List<Exercise> findAllByScore(@Param("program") Program program);
      
      

      Where I have

      program=:#{#program}
      

      twice, Spring automatically increments to Synthetic_8, however it should be still referencing Synthetic_7.

      The error below is thrown:

      You have attempted to set a parameter value using a name of __$synthetic$__8 that does not exist in the query string select e from Exercise e where e.exerciseAttributes.strength >= :__$synthetic$__1 and e.exerciseAttributes.endurance >= :__$synthetic$__2 and e.exerciseAttributes.balance >= :__$synthetic$__3 and e.exerciseAttributes.strength <= :__$synthetic$__4 and e.exerciseAttributes.endurance <= :__$synthetic$__5 and e.exerciseAttributes.balance <= :__$synthetic$__6 and e not in (select prepExercises from Program as program inner join program.prepExerciseList prepExerciseList join prepExerciseList.exerciseItems prepExercisesItems inner join prepExercisesItems.exercise prepExercises where program = :__$synthetic$__7) and e not in (select postExercises from Program as program inner join program.postExerciseList postExerciseList join postExerciseList.exerciseItems postExercisesItems inner join postExercisesItems.exercise postExercises where program = :__$synthetic$__7).
      

      Apologizes for the lack of extra information, however not sure to map the current pom.xml to the various versions.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                schauder Jens Schauder
                Reporter:
                alisson.godoi Alisson Godoi
                Last updater:
                Jens Schauder
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: