[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5891) AuditReaderImpl.getRevisions result is not ordered as specified in Javadoc
Thierry Monney (JIRA)
noreply at atlassian.com
Thu Feb 3 03:57:06 EST 2011
AuditReaderImpl.getRevisions result is not ordered as specified in Javadoc
--------------------------------------------------------------------------
Key: HHH-5891
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5891
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.1
Reporter: Thierry Monney
The Javadoc of org.hibernate.envers.AuditReader.getRevisions specifies that results are
{quote}
sorted in ascending order (so older revisions come first)??.
{quote}
The implementation in {{org.hibernate.envers.reader.AuditReaderImpl}} is as follows:
{{return createQuery().forRevisionsOfEntity(cls, entityName, false, true).addProjection(AuditEntity.revisionNumber()).add(AuditEntity.id().eq(primaryKey)).getResultList();}}
The Javadoc of {{AuditQueryCreator.forRevisionsOfEntity}} specifies that
{quote}
The results of the query will be sorted in ascending order by the revision number, unless an order or projection is added
{quote}
Since the implementation adds a projection on the revision number, no ordering is performed, which causes randomly ordered results to be returned.
The fix looks simple: just replace the above code with
{{return createQuery().forRevisionsOfEntity(cls, entityName, false, true).addProjection(AuditEntity.revisionNumber()).add(AuditEntity.id().eq(primaryKey)).addOrder(AuditEntity.revisionNumber().asc()).getResultList();}}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list