Examples of StrTestEntity


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

    @BeforeClass(dependsOnMethods = "init")
    public void initData() {
        EntityManager em = getEntityManager();

        StrTestEntity str1 = new StrTestEntity("str1");
        StrTestEntity str2 = new StrTestEntity("str2");

        SetJoinColumnRefCollEntity coll1 = new SetJoinColumnRefCollEntity(3, "coll1");

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

        em.persist(str1);
        em.persist(str2);

        coll1.setCollection(new HashSet<StrTestEntity>());
        coll1.getCollection().add(str1);
        em.persist(coll1);

        em.getTransaction().commit();

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

        str2 = em.find(StrTestEntity.class, str2.getId());
        coll1 = em.find(SetJoinColumnRefCollEntity.class, coll1.getId());

        coll1.getCollection().add(str2);

        em.getTransaction().commit();

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

        str1 = em.find(StrTestEntity.class, str1.getId());
        coll1 = em.find(SetJoinColumnRefCollEntity.class, coll1.getId());

        coll1.getCollection().remove(str1);

        em.getTransaction().commit();

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

        coll1 = em.find(SetJoinColumnRefCollEntity.class, coll1.getId());

        coll1.getCollection().clear();

        em.getTransaction().commit();

        //

        str1_id = str1.getId();
        str2_id = str2.getId();

        coll1_id = coll1.getId();
    }
View Full Code Here

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

        assert Arrays.asList(1).equals(getAuditReader().getRevisions(StrTestEntity.class, str2_id));
    }

    @Test
    public void testHistoryOfColl1() {
        StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
        StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);

        SetJoinColumnRefCollEntity rev1 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 1);
        SetJoinColumnRefCollEntity rev2 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 2);
        SetJoinColumnRefCollEntity rev3 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 3);
        SetJoinColumnRefCollEntity rev4 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 4);
View Full Code Here

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

        IdMapKeyEntity imke = new IdMapKeyEntity();

        // Revision 1 (intialy 1 mapping)
        em.getTransaction().begin();

        StrTestEntity ste1 = new StrTestEntity("x");
        StrTestEntity ste2 = new StrTestEntity("y");

        em.persist(ste1);
        em.persist(ste2);

        imke.getIdmap().put(ste1.getId(), ste1);

        em.persist(imke);

        em.getTransaction().commit();

        // Revision 2 (sse1: adding 1 mapping)
        em.getTransaction().begin();

        ste2 = em.find(StrTestEntity.class, ste2.getId());
        imke = em.find(IdMapKeyEntity.class, imke.getId());

        imke.getIdmap().put(ste2.getId(), ste2);

        em.getTransaction().commit();

        //

        imke_id = imke.getId();

        ste1_id = ste1.getId();
        ste2_id = ste2.getId();
    }
View Full Code Here

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

        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(IdMapKeyEntity.class, imke_id));
    }

    @Test
    public void testHistoryOfImke() {
        StrTestEntity ste1 = getEntityManager().find(StrTestEntity.class, ste1_id);
        StrTestEntity ste2 = getEntityManager().find(StrTestEntity.class, ste2_id);

        IdMapKeyEntity rev1 = getAuditReader().find(IdMapKeyEntity.class, imke_id, 1);
        IdMapKeyEntity rev2 = getAuditReader().find(IdMapKeyEntity.class, imke_id, 2);

        assert rev1.getIdmap().equals(TestTools.makeMap(ste1.getId(), ste1));
        assert rev2.getIdmap().equals(TestTools.makeMap(ste1.getId(), ste1, ste2.getId(), ste2));
    }
View Full Code Here

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

    public void initData() throws InterruptedException {       
        EntityManager em = getEntityManager();

    // Revision 1
        em.getTransaction().begin();
        StrTestEntity te = new StrTestEntity("x");
        em.persist(te);
        id = te.getId();

    // Setting the data on the revision entity
    CustomDataRevEntity custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
    custom.setData("data1");

        em.getTransaction().commit();

        // Revision 2
        em.getTransaction().begin();
        te = em.find(StrTestEntity.class, id);
        te.setStr("y");

    // Setting the data on the revision entity
    custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
    custom.setData("data2");

        em.getTransaction().commit();

    // Revision 3 - no changes, but rev entity should be persisted
        em.getTransaction().begin();

    // Setting the data on the revision entity
    custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, true);
    custom.setData("data3");

        em.getTransaction().commit();

    // No changes, rev entity won't be persisted
        em.getTransaction().begin();

    // Setting the data on the revision entity
    custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
    custom.setData("data4");

        em.getTransaction().commit();

    // Revision 4
        em.getTransaction().begin();
        te = em.find(StrTestEntity.class, id);
        te.setStr("z");

    // Setting the data on the revision entity
    custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
    custom.setData("data5");
View Full Code Here

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

        assert Arrays.asList(1, 2, 4).equals(getAuditReader().getRevisions(StrTestEntity.class, id));
    }

    @Test
    public void testHistoryOfId1() {
        StrTestEntity ver1 = new StrTestEntity("x", id);
        StrTestEntity ver2 = new StrTestEntity("y", id);
        StrTestEntity ver3 = new StrTestEntity("z", id);

        assert getAuditReader().find(StrTestEntity.class, id, 1).equals(ver1);
        assert getAuditReader().find(StrTestEntity.class, id, 2).equals(ver2);
        assert getAuditReader().find(StrTestEntity.class, id, 3).equals(ver2);
        assert getAuditReader().find(StrTestEntity.class, id, 4).equals(ver3);
View Full Code Here

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

        Thread.sleep(100);

        // Revision 1
        EntityManager em = getEntityManager();
        em.getTransaction().begin();
        StrTestEntity te = new StrTestEntity("x");
        em.persist(te);
        id = te.getId();
        em.getTransaction().commit();

        timestamp2 = System.currentTimeMillis();

        Thread.sleep(100);

        // Revision 2
        em.getTransaction().begin();
        te = em.find(StrTestEntity.class, id);
        te.setStr("y");
        em.getTransaction().commit();

        timestamp3 = System.currentTimeMillis();
    }
View Full Code Here

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

        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(StrTestEntity.class, id));
    }

    @Test
    public void testHistoryOfId1() {
        StrTestEntity ver1 = new StrTestEntity("x", id);
        StrTestEntity ver2 = new StrTestEntity("y", id);

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

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

    @BeforeClass(dependsOnMethods = "init")
    public void initData() {
        // Revision 1
        newSessionFactory();
        getSession().getTransaction().begin();
        StrTestEntity ste = new StrTestEntity("data");
        getSession().persist(ste);
        getSession().getTransaction().commit();
        id = ste.getId();
    }
View Full Code Here

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

    }

    @Test
    @SuppressWarnings("unchecked")
    public void testQueryingWithProxyObject() {
        StrTestEntity originalSte = new StrTestEntity("data", id);
        // Load the proxy instance
        StrTestEntity proxySte = (StrTestEntity) getSession().load(StrTestEntity.class, id);

        Assert.assertTrue(getAuditReader().isEntityClassAudited(proxySte.getClass()));

        StrTestEntity ste = getAuditReader().find(proxySte.getClass(), proxySte.getId(), 1);
        Assert.assertEquals(originalSte, ste);

        List<Number> revisions = getAuditReader().getRevisions(proxySte.getClass(), proxySte.getId());
        Assert.assertEquals(Arrays.asList(1), revisions);
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.