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

fetchResults() generating wrong count query #1472

renanleandrof opened this Issue Aug 11, 2015 · 0 comments


None yet
2 participants

renanleandrof commented Aug 11, 2015

QueryDSL: 4.0.3

Given the scenario:

@Table(name = "document")
public class Document {

private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "subDepartmentId", nullable = false)
private SubDepartment subDepartment;

private BigDecimal value;

@Table(name = "subDepartment")
public class SubDepartment{

private Long id;

private Department department;

@Table(name = "department")
public class Department{

private Long id;

private String code;

private String name;

When i try to do an aggregation query with some group by, it generates a wrong count query in fetchResults:

.select(qDocument.value.sum(), qDocument.subDepartment.department.code)

The generated count is:

SELECT count(s.deparmentCode) AS col_0_0_
FROM document d CROSS JOIN
  subDepartment s
WHERE d.subDepartmentId =

GROUP BY s.departmentCode

That will generate multiple results, not a single result.

Is this a bug or am i doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment