Search in sources :

Example 31 with StrIntTestEntity

use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.

the class SimpleQuery method testEntitiesRemovedAtRevision.

@Test
public void testEntitiesRemovedAtRevision() {
    StrIntTestEntity site1 = new StrIntTestEntity(null, null, id1);
    List result = getAuditReader().createQuery().forEntitiesModifiedAtRevision(StrIntTestEntity.class, 4).getResultList();
    RevisionType revisionType = (RevisionType) getAuditReader().createQuery().forEntitiesModifiedAtRevision(StrIntTestEntity.class, 4).addProjection(AuditEntity.revisionType()).add(AuditEntity.id().eq(id1)).getSingleResult();
    Assert.assertTrue(TestTools.checkCollection(result, site1));
    Assert.assertEquals(revisionType, RevisionType.DEL);
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) RevisionType(org.hibernate.envers.RevisionType) List(java.util.List) Test(org.junit.Test)

Example 32 with StrIntTestEntity

use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.

the class SimpleQuery method testIlike.

@Test
@TestForIssue(jiraKey = "HHH-8495")
public void testIlike() {
    StrIntTestEntity site1 = new StrIntTestEntity("aBc", 10, id1);
    StrIntTestEntity result = (StrIntTestEntity) getAuditReader().createQuery().forRevisionsOfEntity(StrIntTestEntity.class, true, true).add(AuditEntity.property("str1").ilike("abc")).getSingleResult();
    Assert.assertEquals(site1, result);
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 33 with StrIntTestEntity

use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.

the class SimpleQuery method testBetweenInsideDisjunction.

@Test
@TestForIssue(jiraKey = "HHH-7800")
public void testBetweenInsideDisjunction() {
    List result = getAuditReader().createQuery().forRevisionsOfEntity(StrIntTestEntity.class, true, true).add(AuditEntity.disjunction().add(AuditEntity.property("number").between(0, 5)).add(AuditEntity.property("number").between(20, 100))).getResultList();
    for (Object o : result) {
        StrIntTestEntity entity = (StrIntTestEntity) o;
        int number = entity.getNumber();
        Assert.assertTrue((number >= 0 && number <= 5) || (number >= 20 && number <= 100));
    }
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) List(java.util.List) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 34 with StrIntTestEntity

use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.

the class SimpleQuery method testIlikeWithMatchMode.

@Test
@TestForIssue(jiraKey = "HHH-8495")
public void testIlikeWithMatchMode() {
    StrIntTestEntity site1 = new StrIntTestEntity("aBc", 10, id1);
    StrIntTestEntity result = (StrIntTestEntity) getAuditReader().createQuery().forRevisionsOfEntity(StrIntTestEntity.class, true, true).add(AuditEntity.property("str1").ilike("BC", MatchMode.ANYWHERE)).getSingleResult();
    Assert.assertEquals(site1, result);
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 35 with StrIntTestEntity

use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.

the class SimpleQuery method testEntitiesPropertyLeQuery.

@Test
public void testEntitiesPropertyLeQuery() {
    List ver1 = getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 1).add(AuditEntity.property("number").le(10)).getResultList();
    List ver2 = getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 2).add(AuditEntity.property("number").le(10)).getResultList();
    List ver3 = getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 3).add(AuditEntity.property("number").le(10)).getResultList();
    assert new HashSet(ver1).equals(TestTools.makeSet(new StrIntTestEntity("a", 10, id1), new StrIntTestEntity("a", 10, id2), new StrIntTestEntity("b", 5, id3)));
    assert new HashSet(ver2).equals(TestTools.makeSet(new StrIntTestEntity("aBc", 10, id1), new StrIntTestEntity("b", 5, id3)));
    assert new HashSet(ver3).equals(TestTools.makeSet(new StrIntTestEntity("aBc", 10, id1), new StrIntTestEntity("a", 5, id3)));
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) List(java.util.List) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

StrIntTestEntity (org.hibernate.envers.test.entities.StrIntTestEntity)36 Test (org.junit.Test)36 List (java.util.List)14 EntityManager (javax.persistence.EntityManager)12 Priority (org.hibernate.envers.test.Priority)12 StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)8 TestForIssue (org.hibernate.testing.TestForIssue)7 RevisionType (org.hibernate.envers.RevisionType)6 HashSet (java.util.HashSet)3 AuditDisjunction (org.hibernate.envers.query.criteria.AuditDisjunction)2 AuditCriterion (org.hibernate.envers.query.criteria.AuditCriterion)1 EmbId (org.hibernate.envers.test.entities.ids.EmbId)1 EmbIdTestEntity (org.hibernate.envers.test.entities.ids.EmbIdTestEntity)1 MulId (org.hibernate.envers.test.entities.ids.MulId)1 MulIdTestEntity (org.hibernate.envers.test.entities.ids.MulIdTestEntity)1 CollectionRefEdEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity)1 CollectionRefIngEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity)1 SetRefIngEmbIdEntity (org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity)1