use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class StoreDeletedData method testMaximizeInDisjunction.
@Test
@TestForIssue(jiraKey = "HHH-7800")
public void testMaximizeInDisjunction() {
List<Integer> queryIds = Arrays.asList(id2, id3);
AuditDisjunction disjunction = AuditEntity.disjunction();
for (Integer id : queryIds) {
AuditCriterion crit = AuditEntity.revisionNumber().maximize().add(AuditEntity.id().eq(id)).add(AuditEntity.revisionType().ne(RevisionType.DEL));
disjunction.add(crit);
// Workaround: using this line instead works correctly:
// disjunction.add(AuditEntity.conjunction().add(crit));
}
List<?> beforeDeletionRevisions = getAuditReader().createQuery().forRevisionsOfEntity(StrIntTestEntity.class, false, false).add(disjunction).addOrder(AuditEntity.property("id").asc()).getResultList();
Assert.assertEquals(2, beforeDeletionRevisions.size());
Object[] result1 = (Object[]) beforeDeletionRevisions.get(0);
Object[] result2 = (Object[]) beforeDeletionRevisions.get(1);
Assert.assertEquals(new StrIntTestEntity("b", 20, id2), result1[0]);
// Making sure that we have received an entity added at revision 3.
Assert.assertEquals(3, ((SequenceIdRevisionEntity) result1[1]).getId());
Assert.assertEquals(RevisionType.ADD, result1[2]);
Assert.assertEquals(new StrIntTestEntity("c", 30, id3), result2[0]);
// Making sure that we have received an entity added at revision 3.
Assert.assertEquals(3, ((SequenceIdRevisionEntity) result2[1]).getId());
Assert.assertEquals(RevisionType.ADD, result2[2]);
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class ProxyIdentifier method testNullReferenceWithNotFoundActionIgnoreInParent.
@Test
@TestForIssue(jiraKey = "HHH-8912")
public void testNullReferenceWithNotFoundActionIgnoreInParent() {
ExtManyToOneNotAuditedNullEntity emtoRev2 = getAuditReader().find(ExtManyToOneNotAuditedNullEntity.class, emtonane1.getId(), 2);
Assert.assertEquals(emtonane1, emtoRev2);
Assert.assertNull(emtoRev2.getReference());
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class ProxyIdentifier method testNullReferenceWithNotFoundActionIgnore.
@Test
@TestForIssue(jiraKey = "HHH-8174")
public void testNullReferenceWithNotFoundActionIgnore() {
ManyToOneNotAuditedNullEntity mtoRev2 = getAuditReader().find(ManyToOneNotAuditedNullEntity.class, mtonane1.getId(), 2);
Assert.assertEquals(mtonane1, mtoRev2);
Assert.assertNull(mtoRev2.getReference());
ManyToManyNotAuditedNullEntity mtmRev2 = getAuditReader().find(ManyToManyNotAuditedNullEntity.class, mtmnane1.getId(), 2);
Assert.assertEquals(mtmnane1, mtmRev2);
Assert.assertTrue(mtmRev2.getReferences().isEmpty());
OneToManyNotAuditedNullEntity otmRev2 = getAuditReader().find(OneToManyNotAuditedNullEntity.class, otmnane1.getId(), 2);
Assert.assertEquals(otmnane1, otmRev2);
Assert.assertTrue(otmRev2.getReferences().isEmpty());
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class EvictAuditDataAfterCommitTest method testSessionCacheCollectionClear.
@Test
@TestForIssue(jiraKey = "HHH-6614")
public void testSessionCacheCollectionClear() {
final String[] auditEntityNames = new String[] { "org.hibernate.envers.test.entities.onetomany.SetRefEdEntity_AUD", "org.hibernate.envers.test.entities.onetomany.SetRefIngEntity_AUD" };
SetRefEdEntity ed1 = new SetRefEdEntity(1, "data_ed_1");
SetRefEdEntity ed2 = new SetRefEdEntity(2, "data_ed_2");
SetRefIngEntity ing1 = new SetRefIngEntity(3, "data_ing_1");
SetRefIngEntity ing2 = new SetRefIngEntity(4, "data_ing_2");
Session session = openSession();
session.getTransaction().begin();
session.persist(ed1);
session.persist(ed2);
session.persist(ing1);
session.persist(ing2);
session.getTransaction().commit();
checkEmptyAuditSessionCache(session, auditEntityNames);
session.getTransaction().begin();
ed1 = (SetRefEdEntity) session.load(SetRefEdEntity.class, ed1.getId());
ing1.setReference(ed1);
ing2.setReference(ed1);
session.getTransaction().commit();
checkEmptyAuditSessionCache(session, auditEntityNames);
session.getTransaction().begin();
ed2 = (SetRefEdEntity) session.load(SetRefEdEntity.class, ed2.getId());
Set<SetRefIngEntity> reffering = new HashSet<SetRefIngEntity>();
reffering.add(ing1);
reffering.add(ing2);
ed2.setReffering(reffering);
session.getTransaction().commit();
checkEmptyAuditSessionCache(session, auditEntityNames);
session.getTransaction().begin();
ed2 = (SetRefEdEntity) session.load(SetRefEdEntity.class, ed2.getId());
ed2.getReffering().remove(ing1);
session.getTransaction().commit();
checkEmptyAuditSessionCache(session, auditEntityNames);
session.getTransaction().begin();
ed2 = (SetRefEdEntity) session.load(SetRefEdEntity.class, ed2.getId());
ed2.getReffering().iterator().next().setData("mod_data_ing_2");
session.getTransaction().commit();
checkEmptyAuditSessionCache(session, auditEntityNames);
session.close();
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class BasicIntegratorTest method testNoAudited.
/**
* Tests that nothing crazy happens if the hibernate-envers jar happens
* to be on the classpath but we have no audited entities
*/
@Test
@TestForIssue(jiraKey = "HHH-9675")
public void testNoAudited() {
new Configuration().buildSessionFactory().close();
new Configuration().addAnnotatedClass(SimpleNonAuditedEntity.class).buildSessionFactory().close();
}
Aggregations