This content has been marked as final.
Show 3 replies
-
1. Re: Getting all revisions for Entity
plaky Nov 10, 2008 9:01 AM (in response to amin1977)Try something like
VersionsReader reader = .. ; List objects = reader.createQuery().forRevisionsOfEntity(cls, true).add( VersionsRestrictions.idEq(primaryKey))
-
2. Re: Getting all revisions for Entity
adamw Nov 10, 2008 2:53 PM (in response to amin1977)Exactly, this will return you a list of 3-element arrays which contain the entity at a given revision, the revision entity instance, and the revision type.
See here for further reference:
http://www.jboss.org/envers/queries.html
Adam -
3. Re: Getting all revisions for Entity
amin1977 Nov 10, 2008 5:58 PM (in response to amin1977)Thanks guys. I am now doing the following:
VersionsReader reader = VersionsReaderFactory.get(hibernateTemplate.getSessionFactory().getCurrentSession()); Contact contact = contactDao.findById(contactId); VersionsOrder versionOrder = asc ? RevisionProperty.asc(): RevisionProperty.desc(); @SuppressWarnings("unchecked")List<? extends Contact> result = reader.createQuery().forRevisionsOfEntity(contact.getClass(),true, true).add(VersionsRestrictions.idEq(contact.getId())).addOrder(versionOrder).getResultList();
As I have set the first param to true I should only get back the entites.
Cheers