Skip to content

Add the ability to choose the join type with ElementCollection #176

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

Open
jfb-NRB opened this issue Mar 28, 2025 · 2 comments · May be fixed by #179
Open

Add the ability to choose the join type with ElementCollection #176

jfb-NRB opened this issue Mar 28, 2025 · 2 comments · May be fixed by #179

Comments

@jfb-NRB
Copy link

jfb-NRB commented Mar 28, 2025

Hello,

Could you add the ability to choose the join type when using a collection.
Without this possibility, the result of the 2 examples below added to RSQLJPASupportTest.java is not correct. We get 2 elements instead of 4.

	@Test
	final void testElementCollection1WithJoinHints() {
		final Map<String, JoinType> joinHints = Map.of("Company.tags", JoinType.LEFT);
		final String rsql = "tags!=tech,tags=na=''";
		final List<Company> companies = companyRepository.findAll(toSpecification(rsql, null, joinHints));
		final long count = companies.size();
		log.info("rsql: {} -> count: {}", rsql, count);
		assertThat(rsql, count, is(4L));
	}

	@Test
	final void testElementCollection2WithJoinHints() {
		final Map<String, JoinType> joinHints = Map.of("Company.bigTags", JoinType.LEFT);
		final String rsql = "bigTags.tag!=tech,bigTags.tag=na=''";
		final List<Company> companies = companyRepository.findAll(toSpecification(rsql, null, joinHints));
		long count = companies.size();
		log.info("rsql: {} -> count: {}", rsql, count);
		assertThat(rsql, count, is(4L));
	}

in RSQLJPAPredicateConverter.java, you just need to add the JoinType recovery when you are in the case of a collection if (isElementCollectionType(mappedProperty, classMetadata)), that is to say replace root = join(keyJoin, root, mappedProperty); by root = join(keyJoin, root, mappedProperty, joinHints.get(keyJoin));.

Could you also fix version 5.x because our project is still in SpringBoot 2.

Thanks for your follow-up

Regards

@perplexhub
Copy link
Owner

Thank you so much for opening this issue and pointing out the area that needs attention! Your input is invaluable, and it’s fantastic to see your interest in improving the project. We would love for you to contribute! If you're comfortable with it, I encourage you to submit a Pull Request (PR) with the suggested changes, along with any necessary test cases. If you have any questions or need assistance, please feel free to reach out—I'm here to help! Looking forward to seeing your contributions!

@jfb-NRB
Copy link
Author

jfb-NRB commented Apr 5, 2025

Hello, I've followed your suggestion and created two PR for version 6 and version 5.
I'm very happy to be able to make my small contribution to your project.
I hope I did things well.
Best regards.

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