Skip to content

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

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private RSQLJPAContext findPropertyPathInternal(String propertyPath, Path startR
classMetadata = getManagedElementCollectionType(mappedProperty, classMetadata);
String keyJoin = getKeyJoin(root, mappedProperty);
log.debug("Create a element collection join between [{}] and [{}] using key [{}]", previousClass, classMetadata.getJavaType().getName(), keyJoin);
root = join(keyJoin, root, mappedProperty);
root = join(keyJoin, root, mappedProperty, joinHints.get(keyJoin));
} else if (JsonbSupport.isJsonType(mappedProperty, classMetadata)) {
root = root.get(mappedProperty);
attribute = RSQLVisitorBase.getAttribute(mappedProperty, classMetadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,26 @@ final void testElementCollection2() {
assertThat(rsql, count, is(4L));
}

@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));
final long count = companies.size();
log.info("rsql: {} -> count: {}", rsql, count);
assertThat(rsql, count, is(4L));
}

@Test
final void testToComplexMultiValueMap() {
String rsql = "sites.trunks.id==2,id=na=2,company.id=='2',id=na=3,name==''";
Expand Down