We're updating the issue view to help you get more done. 

Envers projection max causes mysql syntax error

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

Status

Assignee

Lukasz Antoniak

Reporter

andrew chen

Components

Fix versions

Affects versions

4.1.9
4.2.0.CR1

Priority

Major