Issue Type: Bug Bug
Affects Versions: 4.2.0.CR1, 4.1.9
Assignee: Unassigned
Components: envers
Created: 26/Feb/13 2:09 PM
Description:

Envers causes SQL Error: 1064, SQLState: 42000 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version error when adding projection with max

AuditQuery query = AuditReaderFactory.get(entityManager).createQuery().forRevisionsOfEntity(Relationship.class, true, true)
.addProjection(AuditEntity.property("id").max()) //this line causes problem
.add(AuditEntity.revisionNumber().gt(1l))
.add(AuditEntity.revisionType().eq(RevisionType.DEL));

which generates select max(relationsh0_.`id`, relationsh0_.rev) as col_0_0_ from `aud_relationships_aud` relationsh0_ where relationsh0_.rev>? and relationsh0_.revtype=?, which is invalid sql.

Expected sql: select max(relationsh0_.`id`) as col_0_0_ from `aud_relationships_aud` relationsh0_ where relationsh0_.rev>? and relationsh0_.revtype=?

Environment: MySQL
Project: Hibernate ORM
Priority: Major Major
Reporter: andrew chen
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira