Package org.hibernate.envers.synchronization

Examples of org.hibernate.envers.synchronization.AuditSync


    public void onPostInsert(PostInsertEvent event) {
        String entityName = event.getPersister().getEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            AuditWorkUnit workUnit = new AddWorkUnit(event.getSession(), event.getPersister().getEntityName(), verCfg,
                    event.getId(), event.getPersister(), event.getState());
            verSync.addWorkUnit(workUnit);

            if (workUnit.containsWork()) {
                generateBidirectionalCollectionChangeWorkUnits(verSync, event.getPersister(), entityName, event.getState(),
                        null, event.getSession());
            }
View Full Code Here


    public void onPostUpdate(PostUpdateEvent event) {
        String entityName = event.getPersister().getEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            AuditWorkUnit workUnit = new ModWorkUnit(event.getSession(), event.getPersister().getEntityName(), verCfg,
                    event.getId(), event.getPersister(), event.getState(), event.getOldState());
            verSync.addWorkUnit(workUnit);

            if (workUnit.containsWork()) {
                generateBidirectionalCollectionChangeWorkUnits(verSync, event.getPersister(), entityName, event.getState(),
                        event.getOldState(), event.getSession());
            }
View Full Code Here

    if (!(session instanceof EventSource)) {
      throw new IllegalArgumentException("The provided session is not an EventSource!");
    }

    // Obtaining the current audit sync
    AuditSync auditSync = verCfg.getSyncManager().get((EventSource) session);

    // And getting the current revision data
    return (T) auditSync.getCurrentRevisionData(session, persist);
  }
View Full Code Here

    public void onPostDelete(PostDeleteEvent event) {
        String entityName = event.getPersister().getEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            AuditWorkUnit workUnit = new DelWorkUnit(event.getSession(), event.getPersister().getEntityName(), verCfg,
                    event.getId(), event.getPersister(), event.getDeletedState());
            verSync.addWorkUnit(workUnit);

            if (workUnit.containsWork()) {
                generateBidirectionalCollectionChangeWorkUnits(verSync, event.getPersister(), entityName, null,
                        event.getDeletedState(), event.getSession());
            }
View Full Code Here

    private void onCollectionAction(AbstractCollectionEvent event, PersistentCollection newColl, Serializable oldColl,
                                    CollectionEntry collectionEntry) {
        String entityName = event.getAffectedOwnerEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            String ownerEntityName = ((AbstractCollectionPersister) collectionEntry.getLoadedPersister()).getOwnerEntityName();
            String referencingPropertyName = collectionEntry.getRole().substring(ownerEntityName.length() + 1);

            // Checking if this is not a "fake" many-to-one bidirectional relation. The relation description may be
            // null in case of collections of non-entities.
            RelationDescription rd = searchForRelationDescription(entityName, referencingPropertyName);
            if (rd != null && rd.getMappedByPropertyName() != null) {
                generateFakeBidirecationalRelationWorkUnits(verSync, newColl, oldColl, entityName,
                        referencingPropertyName, event, rd);
            } else {
                PersistentCollectionChangeWorkUnit workUnit = new PersistentCollectionChangeWorkUnit(event.getSession(),
                        entityName, verCfg, newColl, collectionEntry, oldColl, event.getAffectedOwnerIdOrNull(),
                        referencingPropertyName);
                verSync.addWorkUnit(workUnit);

                if (workUnit.containsWork()) {
                    // There are some changes: a revision needs also be generated for the collection owner
                    verSync.addWorkUnit(new CollectionChangeWorkUnit(event.getSession(), event.getAffectedOwnerEntityName(),
                            verCfg, event.getAffectedOwnerIdOrNull(), event.getAffectedOwnerOrNull()));

                    generateBidirectionalCollectionChangeWorkUnits(verSync, event, workUnit, rd);
                }
            }
View Full Code Here

    if (!(session instanceof EventSource)) {
      throw new IllegalArgumentException("The provided session is not an EventSource!");
    }

    // Obtaining the current audit sync
    AuditSync auditSync = verCfg.getSyncManager().get((EventSource) session);

    // And getting the current revision data
    return (T) auditSync.getCurrentRevisionData(session, persist);
  }
View Full Code Here

    public void onPostInsert(PostInsertEvent event) {
        String entityName = event.getPersister().getEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            AuditWorkUnit workUnit = new AddWorkUnit(event.getSession(), event.getPersister().getEntityName(), verCfg,
                    event.getId(), event.getPersister(), event.getState());
            verSync.addWorkUnit(workUnit);

            if (workUnit.containsWork()) {
                generateBidirectionalCollectionChangeWorkUnits(verSync, event.getPersister(), entityName, event.getState(),
                        null, event.getSession());
            }
View Full Code Here

    public void onPostUpdate(PostUpdateEvent event) {
        String entityName = event.getPersister().getEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            AuditWorkUnit workUnit = new ModWorkUnit(event.getSession(), event.getPersister().getEntityName(), verCfg,
                    event.getId(), event.getPersister(), event.getState(), event.getOldState());
            verSync.addWorkUnit(workUnit);

            if (workUnit.containsWork()) {
                generateBidirectionalCollectionChangeWorkUnits(verSync, event.getPersister(), entityName, event.getState(),
                        event.getOldState(), event.getSession());
            }
View Full Code Here

    public void onPostDelete(PostDeleteEvent event) {
        String entityName = event.getPersister().getEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            AuditWorkUnit workUnit = new DelWorkUnit(event.getSession(), event.getPersister().getEntityName(), verCfg,
                    event.getId(), event.getPersister(), event.getDeletedState());
            verSync.addWorkUnit(workUnit);

            if (workUnit.containsWork()) {
                generateBidirectionalCollectionChangeWorkUnits(verSync, event.getPersister(), entityName, null,
                        event.getDeletedState(), event.getSession());
            }
View Full Code Here

    private void onCollectionAction(AbstractCollectionEvent event, PersistentCollection newColl, Serializable oldColl,
                                    CollectionEntry collectionEntry) {
        String entityName = event.getAffectedOwnerEntityName();

        if (verCfg.getEntCfg().isVersioned(entityName)) {
            AuditSync verSync = verCfg.getSyncManager().get(event.getSession());

            String ownerEntityName = ((AbstractCollectionPersister) collectionEntry.getLoadedPersister()).getOwnerEntityName();
            String referencingPropertyName = collectionEntry.getRole().substring(ownerEntityName.length() + 1);

            // Checking if this is not a "fake" many-to-one bidirectional relation. The relation description may be
            // null in case of collections of non-entities.
            RelationDescription rd = verCfg.getEntCfg().get(entityName).getRelationDescription(referencingPropertyName);
            if (rd != null && rd.getMappedByPropertyName() != null) {
                generateFakeBidirecationalRelationWorkUnits(verSync, newColl, oldColl, entityName,
                        referencingPropertyName, event, rd);
            } else {
                PersistentCollectionChangeWorkUnit workUnit = new PersistentCollectionChangeWorkUnit(event.getSession(),
                        entityName, verCfg, newColl, collectionEntry, oldColl, event.getAffectedOwnerIdOrNull(),
                        referencingPropertyName);
                verSync.addWorkUnit(workUnit);

                if (workUnit.containsWork()) {
                    // There are some changes: a revision needs also be generated for the collection owner
                    verSync.addWorkUnit(new CollectionChangeWorkUnit(event.getSession(), event.getAffectedOwnerEntityName(),
                            verCfg, event.getAffectedOwnerIdOrNull(), event.getAffectedOwnerOrNull()));

                    generateBidirectionalCollectionChangeWorkUnits(verSync, event, workUnit, rd);
                }
            }
View Full Code Here

TOP

Related Classes of org.hibernate.envers.synchronization.AuditSync

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.