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

Count distinct broken for PostgreSQL #587

timowest opened this Issue Dec 9, 2013 · 1 comment


None yet
1 participant

timowest commented Dec 9, 2013

For Postgres, SQLTemplates should be changed to:

private String distinctCountStart = "count(distinct(";
private String distinctCountEnd = "))";

As it is not possible today, reflection is used to set these two attributes.

The query produced without the correction is:
select count(distinct "menu"."id", "menu"."name", "menu"."screen", "menu"."parent_menu") from "utils"."menu" "menu"

And error is:

Exception in thread "main" com.mysema.query.QueryException: ERROR: function count(bigint, character varying, bigint, bigint) does not exist
  Dica: No function matches the given name and argument types. You might need to add explicit type casts.
  Posição: 8
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
at org.postgresql.core.v3.QueryExecutorImpl.processResults(
at org.postgresql.core.v3.QueryExecutorImpl.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(
at com.mysema.query.sql.AbstractSQLQuery.unsafeCount(
... 5 more

The correct sql is:
select count(distinct("menu"."id", "menu"."name", "menu"."screen", "menu"."parent_menu")) from "utils"."menu" "menu"


This comment has been minimized.

Show comment
Hide comment

timowest Dec 12, 2013


Released in 3.3.0.BETA2


timowest commented Dec 12, 2013

Released in 3.3.0.BETA2

@timowest timowest closed this Dec 12, 2013

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