Skip to content

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

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: 5.x
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 @@ -133,7 +133,7 @@ RSQLJPAContext findPropertyPath(String propertyPath, Path startRoot) {
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 {
log.debug("Create property path for type [{}] property [{}]", classMetadata.getJavaType().getName(), mappedProperty);
root = root.get(mappedProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,26 @@ public final void testElementCollection2() {
assertThat(rsql, count, is(4l));
}

@Test
public final void testElementCollection1WithJoinHints() {
final Map<String, JoinType> joinHints = new HashMap<String, JoinType>(){{put("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
public final void testElementCollection2WithJoinHints() {
final Map<String, JoinType> joinHints = new HashMap<String, JoinType>(){{put("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
public final void testToComplexMultiValueMap() {
String rsql = "sites.trunks.id==2,id=na=2,company.id=='2',id=na=3,name==''";
Expand Down