Skip to content

Instantly share code, notes, and snippets.

@thjanssen
Created December 13, 2016 18:53
Show Gist options
  • Save thjanssen/497757c313dcc9b4898128dac4469a81 to your computer and use it in GitHub Desktop.
Save thjanssen/497757c313dcc9b4898128dac4469a81 to your computer and use it in GitHub Desktop.
AuditQuery q = auditReader.createQuery().forEntitiesAtRevision(Book.class, 2);
q.traverseRelation(“publisher”, JoinType.LEFT, “p”);
q.add(AuditEntity.and(
AuditEntity.or(AuditEntity.property(“title”).ilike(“JPA”, MatchMode.ANYWHERE), AuditEntity.property(“title”).ilike(“Hibernate”, MatchMode.ANYWHERE)),
AuditEntity.property(“p”, “name”).ilike(“Manning”)));
q.addOrder(AuditEntity.property(“title”).asc());
List<Book> audit = q.getResultList();
AuditQuery q = auditReader.createQuery().forRevisionsOfEntity(Book.class, true, true);
q.add(AuditEntity.id().eq(b.getId()));
List<Book> audit = q.getResultList();
AuditQuery q = auditReader.createQuery().forRevisionsOfEntity(Book.class, false, true);
q.addProjection(AuditEntity.revisionNumber().min());
q.add(AuditEntity.id().eq(b.getId()));
q.add(AuditEntity.property(“title”).eq(“Hibernate Tips – 64 Tips for your day to day work”));
Number revision = (Number) q.getSingleResult();
AuditQuery q = auditReader.createQuery().forEntitiesAtRevision(Book.class, 2);
q.add(AuditEntity.property(“title”).ilike(“Hibernate”, MatchMode.ANYWHERE));
q.addOrder(AuditEntity.property(“title”).asc());
List<Book> audit = q.getResultList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment