[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5500?page=c...
]
Lukasz Antoniak commented on HHH-5500:
--------------------------------------
Erik, could you provide a business scenario where this functionality would be desired?
More or less the same can be achieved with
{{AuditReader.createQuery().forRevisionsOfEntity()}} query. Please review
{{org.hibernate.envers.test.integration.query.RevisionConstraintQuery}} class and the
following test method:
{code:title=org.hibernate.envers.test.integration.query.RevisionConstraintQuery|borderStyle=solid}
@Test
public void testMultipleRevisionsOfEntity() {
List results = getAuditReader().createQuery()
.forRevisionsOfEntity(StrIntTestEntity.class, true, true)
.add(AuditEntity.id().eq(id1))
.add(AuditEntity.revisionNumber().in(new Integer[] {1, 3}))
.getResultList();
assert results.size() == 2;
assert results.get(0).equals(new StrIntTestEntity("a", 10, id1));
assert results.get(1).equals(new StrIntTestEntity("d", 1, id1));
}
{code}
SQL query generated by Envers:
{code:title=SQL query|borderStyle=solid}
select
strinttest0_.id as id3103_,
strinttest0_.REV as REV3103_,
strinttest0_.REVTYPE as REVTYPE3103_,
strinttest0_.REVEND as REVEND3103_,
strinttest0_.number as number3103_,
strinttest0_.str1 as str6_3103_
from
StrIntTestEntity_AUD strinttest0_
where
strinttest0_.id=?
and (
strinttest0_.REV in (
? , ?
)
)
order by
strinttest0_.REV asc
{code}
The only difference between existing {{AuditReader.createQuery().forRevisionsOfEntity()}}
and proposed {{AuditReader.findEntities()}} method would be the "calculation" of
appropriate revision number when entity has been last modified. If an entity of
{{StrIntTestEntity}} type was updated during revisions 1, 3, and 5,
{{AuditReader.createQuery().forRevisionsOfEntity()}} would return no results for revisions
2 and 4. Proposed {{AuditReader.findEntities()}} shall return snapshot of entity at
revision 1 (for passed argument 2), and 3 (for passed argument 4).
Adam, maybe this functionality would be useful?
Regards,
Ćukasz Antoniak
Extend AuditReader interface with findEntities() method
-------------------------------------------------------
Key: HHH-5500
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5500
Project: Hibernate Core
Issue Type: Sub-task
Components: envers
Reporter: Erik-Berndt Scheper
Assignee: Lukasz Antoniak
To improve performance, it would be benificial to extend the Envers AuditReader
interface, so that a list of audited entities can be retrieved in one query.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira