use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.
the class AssociationToOneLeftJoinQueryTest method testEntitiesWithANullRelatedIdAreNotJoinedToOtherEntities.
/**
* In a first attempt to implement left joins in Envers, a full join
* has been performed and than the entities has been filtered in the
* where clause. However, this approach did only work for inner joins
* but not for left joins. One of the defects in this approach is,
* that audit entities, which have a null 'relatedId' are and do not
* match the query criterias, still joined to other entities which matched
* match the query criterias.
* This test ensures that this defect is no longer in the current implementation.
*/
@Test
public void testEntitiesWithANullRelatedIdAreNotJoinedToOtherEntities() {
final AuditReader auditReader = getAuditReader();
List<Car> resultList = auditReader.createQuery().forEntitiesAtRevision(Car.class, 1).traverseRelation("owner", JoinType.LEFT, "p").up().add(AuditEntity.and(AuditEntity.property("make").eq("car3"), AuditEntity.property("p", "age").eq(30))).getResultList();
assertTrue("Expected no cars to be returned, because car3 does not have an owner", resultList.isEmpty());
}
use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.
the class DataPointServiceImpl method getRevisions.
public Map<Number, DefaultRevisionEntity> getRevisions(long id) {
Session s = hibernateUtil.getSession();
AuditReader reader = AuditReaderFactory.get(s);
List<Number> revisionNums = reader.getRevisions(DataPoint.class, id);
return reader.findRevisions(DefaultRevisionEntity.class, new HashSet<Number>(revisionNums));
}
use of org.hibernate.envers.AuditReader in project wildfly by wildfly.
the class SLSBAudit method retrieveOldPhoneListVersionFromCustomer.
public String retrieveOldPhoneListVersionFromCustomer(int id) {
AuditReader reader = AuditReaderFactory.get(em);
Customer cust_rev = reader.find(Customer.class, id, 2);
return cust_rev.getPhones().get(1).getType();
}
use of org.hibernate.envers.AuditReader in project wildfly by wildfly.
the class SLSBAudit method retrieveOldPhoneListSizeFromCustomer.
public int retrieveOldPhoneListSizeFromCustomer(int id, int revnumber) {
AuditReader reader = AuditReaderFactory.get(em);
Customer cust_rev = reader.find(Customer.class, id, revnumber);
return cust_rev.getPhones().size();
}
use of org.hibernate.envers.AuditReader in project wildfly by wildfly.
the class SLSBAudit method verifyOtherFields.
public List<Object> verifyOtherFields(int id) {
AuditReader reader = AuditReaderFactory.get(em);
boolean b;
Customer cust1_rev = reader.find(Customer.class, id, 3);
String queryString = "select a.originalId.phones_id from CUSTOMER_PHONE_AUD a";
Query query = em.createQuery(queryString);
List<Object> custHistory = query.getResultList();
return custHistory;
}
Aggregations