Skip to content
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

SPeL Processor Auto-Increment the Synthetic Value for Same Mapped Value [DATAJPA-1223] #1545

Closed
spring-projects-issues opened this issue Nov 16, 2017 · 2 comments
Assignees
Labels
status: duplicate type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Nov 16, 2017

Alisson Godoi opened DATAJPA-1223 and commented

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


Issue Links:

  • DATAJPA-1179 Duplicate SpEL expressions create only one parameter name but multiple bindings
    ("duplicates")
@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 16, 2017

Jens Schauder commented

This should be solved by DATAJPA-1179.

So updating to Boot 1.5.8 or which includes Spring Data JPA 1.11.8 should solve the problem.

@Alisson Godoi Can you please confirm this?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 17, 2017

Alisson Godoi commented

Yes! @Jens Schauder, I have checked the new version (1.5.8) and it is working.
Thanks for finding that out.
Regards

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

No branches or pull requests

2 participants