Search in sources :

Example 1 with UnusualIdNamingEntity

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

the class AggregateQuery method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    IntTestEntity ite1 = new IntTestEntity(2);
    IntTestEntity ite2 = new IntTestEntity(10);
    em.persist(ite1);
    em.persist(ite2);
    Integer id1 = ite1.getId();
    Integer id2 = ite2.getId();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    IntTestEntity ite3 = new IntTestEntity(8);
    UnusualIdNamingEntity uine1 = new UnusualIdNamingEntity("id1", "data1");
    em.persist(uine1);
    em.persist(ite3);
    ite1 = em.find(IntTestEntity.class, id1);
    ite1.setNumber(0);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    ite2 = em.find(IntTestEntity.class, id2);
    ite2.setNumber(52);
    em.getTransaction().commit();
    em.close();
}
Also used : EntityManager(javax.persistence.EntityManager) UnusualIdNamingEntity(org.hibernate.envers.test.entities.ids.UnusualIdNamingEntity) IntTestEntity(org.hibernate.envers.test.entities.IntTestEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 2 with UnusualIdNamingEntity

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

the class AggregateQuery method testUnusualIdFieldName.

@Test
@TestForIssue(jiraKey = "HHH-8036")
public void testUnusualIdFieldName() {
    UnusualIdNamingEntity entity = (UnusualIdNamingEntity) getAuditReader().createQuery().forRevisionsOfEntity(UnusualIdNamingEntity.class, true, true).add(AuditEntity.id().like("id1")).getSingleResult();
    Assert.assertEquals(new UnusualIdNamingEntity("id1", "data1"), entity);
}
Also used : UnusualIdNamingEntity(org.hibernate.envers.test.entities.ids.UnusualIdNamingEntity) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

UnusualIdNamingEntity (org.hibernate.envers.test.entities.ids.UnusualIdNamingEntity)2 Test (org.junit.Test)2 EntityManager (javax.persistence.EntityManager)1 Priority (org.hibernate.envers.test.Priority)1 IntTestEntity (org.hibernate.envers.test.entities.IntTestEntity)1 TestForIssue (org.hibernate.testing.TestForIssue)1