Skip to content
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
Closed

FactoryExpression usage in other parts than select #678

johnjaylward opened this issue Mar 11, 2014 · 4 comments
Milestone

Comments

@johnjaylward
Copy link

@johnjaylward johnjaylward commented Mar 11, 2014

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
Copy link
Author

@johnjaylward johnjaylward commented Mar 11, 2014

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 reopened this Mar 31, 2014
@timowest
Copy link
Member

@timowest 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 Hibernate/MySQL query error FactoryExpression usage in other parts than select Apr 2, 2014
@timowest
Copy link
Member

@timowest 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
Copy link
Member

@timowest 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.