Examples of IntTestEntity


Examples of org.hibernate.envers.test.entities.IntTestEntity

    @BeforeClass(dependsOnMethods = "init")
    public void initData() {
        // Revision 1
        EntityManager em = getEntityManager();
        em.getTransaction().begin();
        IntTestEntity ite = new IntTestEntity(10);
        em.persist(ite);
        id1 = ite.getId();
        em.getTransaction().commit();

        // Revision 2
        em.getTransaction().begin();
        ite = em.find(IntTestEntity.class, id1);
        ite.setNumber(20);
        em.getTransaction().commit();
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

    public void testCacheFindAfterRevisionsOfEntityQuery() {
        List entsFromQuery = getAuditReader().createQuery()
                .forRevisionsOfEntity(IntTestEntity.class, true, false)
                .getResultList();

        IntTestEntity entFromFindRev1 = getAuditReader().find(IntTestEntity.class, id1, 1);
        IntTestEntity entFromFindRev2 = getAuditReader().find(IntTestEntity.class, id1, 2);

        assert entFromFindRev1 == entsFromQuery.get(0);
        assert entFromFindRev2 == entsFromQuery.get(1);
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

        assert entFromFindRev2 == entsFromQuery.get(1);
    }

    @Test
    public void testCacheFindAfterEntitiesAtRevisionQuery() {
        IntTestEntity entFromQuery = (IntTestEntity) getAuditReader().createQuery()
                .forEntitiesAtRevision(IntTestEntity.class, 1)
                .getSingleResult();

        IntTestEntity entFromFind = getAuditReader().find(IntTestEntity.class, id1, 1);

        assert entFromFind == entFromQuery;
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

    public void initData() {
        // Revision 1
        EntityManager em = getEntityManager();
        em.getTransaction().begin();

        IntTestEntity ite1 = new IntTestEntity(12);
        IntTestEntity ite2 = new IntTestEntity(5);
        IntTestEntity ite3 = new IntTestEntity(8);
        IntTestEntity ite4 = new IntTestEntity(1);

        em.persist(ite1);
        em.persist(ite2);
        em.persist(ite3);
        em.persist(ite4);

        id1 = ite1.getId();
        id2 = ite2.getId();
        id3 = ite3.getId();
        id4 = ite4.getId();

        em.getTransaction().commit();

        // Revision 2
        em.getTransaction().begin();

        IntTestEntity ite5 = new IntTestEntity(3);
        em.persist(ite5);
        id5 = ite5.getId();

        ite1 = em.find(IntTestEntity.class, id1);
        ite1.setNumber(0);

        ite4 = em.find(IntTestEntity.class, id4);
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

                .addOrder(AuditEntity.property("number").desc())
                .setFirstResult(4)
                .setMaxResults(2)
                .getResultList();

        assert Arrays.asList(new IntTestEntity(12, id1), new IntTestEntity(8, id3)).equals(res_0_to_1);
        assert Arrays.asList(new IntTestEntity(5, id2), new IntTestEntity(1, id4)).equals(res_2_to_3);
        assert Arrays.asList().equals(res_empty);
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

                .addOrder(AuditEntity.property("number").desc())
                .setFirstResult(4)
                .setMaxResults(2)
                .getResultList();

        assert Arrays.asList(new IntTestEntity(15, id4), new IntTestEntity(8, id3)).equals(res_0_to_1);
        assert Arrays.asList(new IntTestEntity(5, id2), new IntTestEntity(3, id5)).equals(res_2_to_3);
        assert Arrays.asList(new IntTestEntity(0, id1)).equals(res_4);
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

        SimpleJtaTransactionManagerImpl.getInstance().begin();

        newEntityManager();
        EntityManager em = getEntityManager();
        em.joinTransaction();
        IntTestEntity ite = new IntTestEntity(10);
        em.persist(ite);
        id1 = ite.getId();

        SimpleJtaTransactionManagerImpl.getInstance().commit();

        //

        SimpleJtaTransactionManagerImpl.getInstance().begin();

        newEntityManager();
        em = getEntityManager();
        ite = em.find(IntTestEntity.class, id1);
        ite.setNumber(20);

        SimpleJtaTransactionManagerImpl.getInstance().commit();
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(IntTestEntity.class, id1));
    }

    @Test(dependsOnMethods = "initData")
    public void testHistoryOfId1() {
        IntTestEntity ver1 = new IntTestEntity(10, id1);
        IntTestEntity ver2 = new IntTestEntity(20, id1);

        assert getAuditReader().find(IntTestEntity.class, id1, 1).equals(ver1);
        assert getAuditReader().find(IntTestEntity.class, id1, 2).equals(ver2);
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

    public void initData() {
        // Revision 1
        EntityManager em = getEntityManager();
        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);
        em.persist(ite3);

        ite1 = em.find(IntTestEntity.class, id1);

        ite1.setNumber(0);
View Full Code Here

Examples of org.hibernate.envers.test.entities.IntTestEntity

    @Test
    public void initData() {
        EntityManager em = getEntityManager();
        em.getTransaction().begin();
        IntTestEntity ite = new IntTestEntity(10);
        em.persist(ite);
        id1 = ite.getId();
        em.getTransaction().commit();

        em.getTransaction().begin();
        ite = em.find(IntTestEntity.class, id1);
        ite.setNumber(20);
        em.getTransaction().commit();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.