Package org.hibernate.envers.entities.mapper.id

Examples of org.hibernate.envers.entities.mapper.id.IdMapper


              // We've got to initialize the object from the proxy to later read its state.  
              newValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
                      } else {
                        toEntityName =  session.guessEntityName(newValue);

              IdMapper idMapper = verCfg.getEntCfg().get(toEntityName).getIdMapper();
                           id = (Serializable) idMapper.mapToIdFromEntity(newValue);
                      }

                        verSync.addWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, verCfg, id, newValue));
                    }

                    if (oldValue != null) {
                      String toEntityName;
            Serializable id;

                      if(oldValue instanceof HibernateProxy) {
                          HibernateProxy hibernateProxy = (HibernateProxy) oldValue;
                          toEntityName = session.bestGuessEntityName(oldValue);
                          id = hibernateProxy.getHibernateLazyInitializer().getIdentifier();
              // We've got to initialize the object as we'll read it's state anyway.
              oldValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
                      } else {
                        toEntityName =  session.guessEntityName(oldValue);

              IdMapper idMapper = verCfg.getEntCfg().get(toEntityName).getIdMapper();
              id = (Serializable) idMapper.mapToIdFromEntity(oldValue);
                      }
           
                        verSync.addWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, verCfg, id, oldValue));
                    }
                }
View Full Code Here


        // Checking if this is not a bidirectional relation - then, a revision needs also be generated for
        // the other side of the relation.
        // relDesc can be null if this is a collection of simple values (not a relation).
        if (rd != null && rd.isBidirectional()) {
            String relatedEntityName = rd.getToEntityName();
            IdMapper relatedIdMapper = verCfg.getEntCfg().get(relatedEntityName).getIdMapper();
           
            for (PersistentCollectionChangeData changeData : workUnit.getCollectionChanges()) {
                Object relatedObj = changeData.getChangedElement();
                Serializable relatedId = (Serializable) relatedIdMapper.mapToIdFromEntity(relatedObj);

                verSync.addWorkUnit(new CollectionChangeWorkUnit(event.getSession(), relatedEntityName, verCfg,
            relatedId, relatedObj));
            }
        }
View Full Code Here

                .mapCollectionChanges(referencingPropertyName, newColl, oldColl, event.getAffectedOwnerIdOrNull());

        // Getting the id mapper for the related entity, as the work units generated will corrspond to the related
        // entities.
        String relatedEntityName = rd.getToEntityName();
        IdMapper relatedIdMapper = verCfg.getEntCfg().get(relatedEntityName).getIdMapper();

        // For each collection change, generating the bidirectional work unit.
        for (PersistentCollectionChangeData changeData : collectionChanges) {
            Object relatedObj = changeData.getChangedElement();
            Serializable relatedId = (Serializable) relatedIdMapper.mapToIdFromEntity(relatedObj);
            RevisionType revType = (RevisionType) changeData.getData().get(verCfg.getAuditEntCfg().getRevisionTypePropName());

            // This can be different from relatedEntityName, in case of inheritance (the real entity may be a subclass
            // of relatedEntityName).
            String realRelatedEntityName = event.getSession().bestGuessEntityName(relatedObj);
View Full Code Here

                .mapCollectionChanges(referencingPropertyName, newColl, oldColl, event.getAffectedOwnerIdOrNull());

        // Getting the id mapper for the related entity, as the work units generated will corrspond to the related
        // entities.
        String relatedEntityName = rd.getToEntityName();
        IdMapper relatedIdMapper = verCfg.getEntCfg().get(relatedEntityName).getIdMapper();

        // For each collection change, generating the bidirectional work unit.
        for (PersistentCollectionChangeData changeData : collectionChanges) {
            Object relatedObj = changeData.getChangedElement();
            Serializable relatedId = (Serializable) relatedIdMapper.mapToIdFromEntity(relatedObj);
            RevisionType revType = (RevisionType) changeData.getData().get(verCfg.getAuditEntCfg().getRevisionTypePropName());

            // This can be different from relatedEntityName, in case of inheritance (the real entity may be a subclass
            // of relatedEntityName).
            String realRelatedEntityName = event.getSession().bestGuessEntityName(relatedObj);
View Full Code Here

              // We've got to initialize the object from the proxy to later read its state.  
              newValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
                      } else {
                        toEntityName =  session.guessEntityName(newValue);

              IdMapper idMapper = verCfg.getEntCfg().get(toEntityName).getIdMapper();
                           id = (Serializable) idMapper.mapToIdFromEntity(newValue);
                      }

                        auditProcess.addWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, verCfg, id, newValue));
                    }

                    if (oldValue != null) {
                      String toEntityName;
            Serializable id;

                      if(oldValue instanceof HibernateProxy) {
                          HibernateProxy hibernateProxy = (HibernateProxy) oldValue;
                          toEntityName = session.bestGuessEntityName(oldValue);
                          id = hibernateProxy.getHibernateLazyInitializer().getIdentifier();
              // We've got to initialize the object as we'll read it's state anyway.
              oldValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
                      } else {
                        toEntityName =  session.guessEntityName(oldValue);

              IdMapper idMapper = verCfg.getEntCfg().get(toEntityName).getIdMapper();
              id = (Serializable) idMapper.mapToIdFromEntity(oldValue);
                      }
           
                        auditProcess.addWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, verCfg, id, oldValue));
                    }
                }
View Full Code Here

        // Checking if this is not a bidirectional relation - then, a revision needs also be generated for
        // the other side of the relation.
        // relDesc can be null if this is a collection of simple values (not a relation).
        if (rd != null && rd.isBidirectional()) {
            String relatedEntityName = rd.getToEntityName();
            IdMapper relatedIdMapper = verCfg.getEntCfg().get(relatedEntityName).getIdMapper();
           
            for (PersistentCollectionChangeData changeData : workUnit.getCollectionChanges()) {
                Object relatedObj = changeData.getChangedElement();
                Serializable relatedId = (Serializable) relatedIdMapper.mapToIdFromEntity(relatedObj);

                auditProcess.addWorkUnit(new CollectionChangeWorkUnit(event.getSession(), relatedEntityName, verCfg,
            relatedId, relatedObj));
            }
        }
View Full Code Here

             */

            QueryBuilder qb = new QueryBuilder(auditedEntityName, "e");

            // e.id = :id
            IdMapper idMapper = auditCfg.getEntCfg().get(entityName).getIdMapper();
            idMapper.addIdEqualsToQuery(qb.getRootParameters(), id, auditCfg.getAuditEntCfg().getOriginalIdPropName(), true);

            addEndRevisionNulLRestriction(auditCfg, qb);

            @SuppressWarnings({"unchecked"})
            List<Object> l = qb.toQuery(session).list();
View Full Code Here

            // In case of a fake many-to-one bidirectional relation, we have to generate a mapper which maps
            // the mapped-by property name to the id of the related entity (which is the owner of the collection).
            String auditMappedBy = propertyAuditingData.getAuditMappedBy();

            // Creating a prefixed relation mapper.
            IdMapper relMapper = referencingIdMapping.getIdMapper().prefixMappedProperties(
                    MappingTools.createToOneRelationPrefix(auditMappedBy));

            fakeBidirectionalRelationMapper = new ToOneIdMapper(
                    relMapper,
                    // The mapper will only be used to map from entity to map, so no need to provide other details
View Full Code Here

              // We've got to initialize the object from the proxy to later read its state.
              newValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
            } else {
              toEntityName =  session.guessEntityName(newValue);

              IdMapper idMapper = enversConfiguration.getEntCfg().get(toEntityName).getIdMapper();
               id = (Serializable) idMapper.mapToIdFromEntity(newValue);
            }

            auditProcess.addWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, enversConfiguration, id, newValue));
          }

          if (oldValue != null) {
            String toEntityName;
            Serializable id;

            if(oldValue instanceof HibernateProxy) {
              HibernateProxy hibernateProxy = (HibernateProxy) oldValue;
              toEntityName = session.bestGuessEntityName(oldValue);
              id = hibernateProxy.getHibernateLazyInitializer().getIdentifier();
              // We've got to initialize the object as we'll read it's state anyway.
              oldValue = Tools.getTargetFromProxy(session.getFactory(), hibernateProxy);
            } else {
              toEntityName =  session.guessEntityName(oldValue);

              IdMapper idMapper = enversConfiguration.getEntCfg().get(toEntityName).getIdMapper();
              id = (Serializable) idMapper.mapToIdFromEntity(oldValue);
            }

            auditProcess.addWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, enversConfiguration, id, oldValue));
          }
        }
View Full Code Here

            // In case of a fake many-to-one bidirectional relation, we have to generate a mapper which maps
            // the mapped-by property name to the id of the related entity (which is the owner of the collection).
            String auditMappedBy = propertyAuditingData.getAuditMappedBy();

            // Creating a prefixed relation mapper.
            IdMapper relMapper = referencingIdMapping.getIdMapper().prefixMappedProperties(
                    MappingTools.createToOneRelationPrefix(auditMappedBy));

            fakeBidirectionalRelationMapper = new ToOneIdMapper(
                    relMapper,
                    // The mapper will only be used to map from entity to map, so no need to provide other details
View Full Code Here

TOP

Related Classes of org.hibernate.envers.entities.mapper.id.IdMapper

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.