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

FactoryExpression usage in other parts than select #678

Closed
johnjaylward opened this Issue Mar 11, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@johnjaylward

A Query like the one below:

final Expression<TwoColumns> select = ConstructorExpression.create(TwoColumns.class, qc.col1,  qc.col2);

return new HibernateQuery(this.getHibernateSession()).from(qc).groupBy(select).list(select);

will throw an MySQL error because it generated a query like this:

SELECT col1,col2 FROM MyTable GROUP BY (col1,col2)

org.hibernate.exception.DataException   could not execute query
Caused By: java.sql.SQLException        Operand should contain 1 column(s)

MySQL does not like the parentheses in the group by. It should instead generate like this:

SELECT col1,col2 FROM MyTable GROUP BY col1,col2

Obviously I can re-write my query to look like:

.from(qc).groupBy(qc.col1,  qc.col2).list(select);

However, it would be preferable to be able to re-use my select clause in my group by so that I don't have to re-write the 2 clauses and possibly have them differ should I need to change the select requirements.

@johnjaylward

This comment has been minimized.

Show comment
Hide comment
@johnjaylward

johnjaylward Mar 11, 2014

Forgot to mention this is on QueryDSL 3.3.1

Forgot to mention this is on QueryDSL 3.3.1

@johnjaylward johnjaylward reopened this Mar 11, 2014

@timowest timowest added bug and removed bug labels Mar 14, 2014

timowest added a commit that referenced this issue Mar 31, 2014

timowest added a commit that referenced this issue Mar 31, 2014

@timowest timowest closed this in #689 Mar 31, 2014

@timowest timowest reopened this Mar 31, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 31, 2014

Member

@johnjaylward Could you verify that the fix works for you? You get the latest SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/

Member

timowest commented Mar 31, 2014

@johnjaylward Could you verify that the fix works for you? You get the latest SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/

@timowest timowest added the fixed label Mar 31, 2014

@timowest timowest changed the title from Hibernate/MySQL query error to FactoryExpression usage in other parts than select Apr 2, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 2, 2014

Member

Any chance you could test this?

Member

timowest commented Apr 2, 2014

Any chance you could test this?

@timowest timowest modified the milestone: 3.3.3 Apr 13, 2014

@timowest timowest modified the milestone: 3.3.3 Apr 30, 2014

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 2, 2014

Member

Released in 3.3.3

Member

timowest commented May 2, 2014

Released in 3.3.3

@timowest timowest closed this May 2, 2014

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