Package org.hibernate.envers

Examples of org.hibernate.envers.AuditReader


        assert getAuditReader().getRevisionNumberForDate(new Date(timestamp4)).intValue() == 3;
    }

    @Test
    public void testDatesForRevisions() {
        AuditReader vr = getAuditReader();
        assert vr.getRevisionNumberForDate(vr.getRevisionDate(1)).intValue() == 1;
        assert vr.getRevisionNumberForDate(vr.getRevisionDate(2)).intValue() == 2;
        assert vr.getRevisionNumberForDate(vr.getRevisionDate(3)).intValue() == 3;
    }
View Full Code Here


        assert vr.getRevisionNumberForDate(vr.getRevisionDate(3)).intValue() == 3;
    }

    @Test
    public void testRevisionsForDates() {
        AuditReader vr = getAuditReader();

        assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(timestamp2))).getTime() <= timestamp2;
        assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(timestamp2)).intValue()+1).getTime() > timestamp2;

        assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(timestamp3))).getTime() <= timestamp3;
        assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(timestamp3)).intValue()+1).getTime() > timestamp3;

        assert vr.getRevisionDate(vr.getRevisionNumberForDate(new Date(timestamp4))).getTime() <= timestamp4;
    }
View Full Code Here

            sb.append("\n");
        }
    }

    private void printPersonHistory(StringBuilder sb, int personId) {
        AuditReader reader = AuditReaderFactory.get(entityManager);

        List personHistory = reader.createQuery()
                .forRevisionsOfEntity(Person.class, false, true)
                .add(AuditEntity.id().eq(personId))
                .getResultList();

        if (personHistory.size() == 0) {
View Full Code Here

            }
        }
    }

    private void printPersonAtRevision(StringBuilder sb, int personId, int revision) {
        AuditReader reader = AuditReaderFactory.get(entityManager);

        Person p = reader.find(Person.class, personId, revision);
        if (p == null) {
            sb.append("This person does not exist at that revision.");
        } else {
            printPerson(sb, p);
        }
View Full Code Here

            sb.append("\n");
        }
    }

    private void printAddressHistory(StringBuilder sb, int addressId) {
        AuditReader reader = AuditReaderFactory.get(entityManager);

        List addressHistory = reader.createQuery()
                .forRevisionsOfEntity(Address.class, false, true)
                .add(AuditEntity.id().eq(addressId))
                .getResultList();

        if (addressHistory.size() == 0) {
View Full Code Here

            }
        }
    }

    private void printAddressAtRevision(StringBuilder sb, int addressId, int revision) {
        AuditReader reader = AuditReaderFactory.get(entityManager);

        Address a = reader.find(Address.class, addressId, revision);
        if (a == null) {
            sb.append("This address does not exist at that revision.");
        } else {
            printAddress(sb, a);
        }
View Full Code Here

  public Address updateAddress(Address a) {
    return em.merge( a );
  }

  public int retrieveOldPersonVersionFromAddress(int id) {
    AuditReader reader = AuditReaderFactory.get( em );
    Address address1_rev = reader.find( Address.class, id, 1 );
    return address1_rev.getPersons().size();
  }
View Full Code Here

  public Address updateAddress(Address a) {
    return em.merge( a );
  }

  public int retrieveOldPersonVersionFromAddress(int id) {
    AuditReader reader = AuditReaderFactory.get( em );
    Address address1_rev = reader.find( Address.class, id, 1 );
    return address1_rev.getPersons().size();
  }
View Full Code Here

    public void deletePhone(Phone p) {
        em.remove(em.merge(p));
    }

    public int retrieveOldPhoneListSizeFromCustomer(int id, int revnumber) {
        AuditReader reader = AuditReaderFactory.get(em);
        Customer cust_rev = reader.find(Customer.class, id, revnumber);
        return cust_rev.getPhones().size();
    }
View Full Code Here

        Customer cust_rev = reader.find(Customer.class, id, revnumber);
        return cust_rev.getPhones().size();
    }

    public String retrieveOldPhoneListVersionFromCustomer(int id) {
        AuditReader reader = AuditReaderFactory.get(em);
        Customer cust_rev = reader.find(Customer.class, id, 2);
        return cust_rev.getPhones().get(1).getType();
    }
View Full Code Here

TOP

Related Classes of org.hibernate.envers.AuditReader

Copyright © 2018 www.massapicom. 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.