[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5891) AuditReaderImpl.getRevisions result is not ordered as specified in Javadoc

Michael Rudolf (JIRA) noreply at atlassian.com
Wed Jan 4 11:29:15 EST 2012


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44932#comment-44932 ] 

Michael Rudolf commented on HHH-5891:
-------------------------------------

Added pull request: https://github.com/hibernate/hibernate-core/pull/242

> 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
>            Assignee: Adam Warski
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list