Skip to content

Commit

Permalink
Added two tests that show issues with grouping joined entities #194
Browse files Browse the repository at this point in the history
  • Loading branch information
jwgmeligmeyling committed Nov 23, 2018
1 parent 252b0f5 commit bf4cc6e
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,50 @@ public void work(EntityManager em) {
});
}

@Test
public void groupByImplicitlyJoinedEntityTest() {
CriteriaBuilder<Tuple> tupleCriteriaBuilder = cbf.create(em, Tuple.class)
.from(Document.class, "d")
.select("d.owner.id", "ownerId")
.select("d.owner.age", "ownerAge")
.select("d.owner.name", "ownerName")
.select("max(d.id)", "latestDocument")
.groupBy("d.owner.name")
.groupBy("d.owner.age")
.groupBy("d.owner.id")
.orderByAsc("d.owner.name")
.orderByAsc("d.owner.age")
.orderByAsc("d.owner.id");

PaginatedCriteriaBuilder<Tuple> page = tupleCriteriaBuilder
.page(0, 10);

page.getResultList();
}


@Test
public void groupByJoinedEntityTest() {
CriteriaBuilder<Tuple> tupleCriteriaBuilder = cbf.create(em, Tuple.class)
.from(Document.class, "d")
.innerJoinDefault("d.owner", "theOwner")
.select("theOwner.id", "ownerId")
.select("theOwner.age", "ownerAge")
.select("theOwner.name", "ownerName")
.select("max(d.id)", "latestDocument")
.groupBy("theOwner.name")
.groupBy("theOwner.age")
.groupBy("theOwner.id")
.orderByAsc("theOwner.name")
.orderByAsc("theOwner.age")
.orderByAsc("theOwner.id");

PaginatedCriteriaBuilder<Tuple> page = tupleCriteriaBuilder
.page(0, 10);

page.getResultList();
}

@Test
public void simpleTest() {
CriteriaBuilder<DocumentViewModel> crit = cbf.create(em, Document.class, "d")
Expand Down

0 comments on commit bf4cc6e

Please sign in to comment.