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

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


    );

    final String lastPropertyPrefix = MappingTools.createToOneRelationPrefix( propertyAuditingData.getName() );

    // Generating the id mapper for the relation
    final IdMapper relMapper = idMapping.getIdMapper().prefixMappedProperties( lastPropertyPrefix );

    // Storing information about this relation
    mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneRelation(
        propertyAuditingData.getName(),
        referencedEntityName,
View Full Code Here


    final String lastPropertyPrefix = MappingTools.createToOneRelationPrefix( owningReferencePropertyName );
    final String referencedEntityName = propertyValue.getReferencedEntityName();

    // Generating the id mapper for the relation
    final IdMapper ownedIdMapper = ownedIdMapping.getIdMapper().prefixMappedProperties( lastPropertyPrefix );

    // Storing information about this relation
    mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneNotOwningRelation(
        propertyAuditingData.getName(),
        owningReferencePropertyName,
View Full Code Here

    );

    final String lastPropertyPrefix = MappingTools.createToOneRelationPrefix( propertyAuditingData.getName() );

    // Generating the id mapper for the relation
    final IdMapper relMapper = idMapping.getIdMapper().prefixMappedProperties( lastPropertyPrefix );

    // Storing information about this relation
    mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneRelation(
        propertyAuditingData.getName(),
        referencedEntityName,
View Full Code Here

      value = EntityTools.getTargetFromProxy( session.getFactory(), hibernateProxy );
    }
    else {
      toEntityName = session.guessEntityName( value );

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

    final Set<String> toPropertyNames = enversConfiguration.getEntCfg().getToPropertyNames(
        fromEntityName,
        relDesc.getFromPropertyName(),
View Full Code Here

        );

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

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

      // This can be different from relatedEntityName, in case of inheritance (the real entity may be a subclass
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() ) {
      final String relatedEntityName = rd.getToEntityName();
      final IdMapper relatedIdMapper = getAuditConfiguration().getEntCfg().get( relatedEntityName ).getIdMapper();

      final Set<String> toPropertyNames = getAuditConfiguration().getEntCfg().getToPropertyNames(
          event.getAffectedOwnerEntityName(),
          rd.getFromPropertyName(),
          relatedEntityName
      );
      final String toPropertyName = toPropertyNames.iterator().next();

      for ( PersistentCollectionChangeData changeData : workUnit.getCollectionChanges() ) {
        final Object relatedObj = changeData.getChangedElement();
        final Serializable relatedId = (Serializable) relatedIdMapper.mapToIdFromEntity( relatedObj );

        auditProcess.addWorkUnit(
            new CollectionChangeWorkUnit(
                event.getSession(),
                event.getSession().bestGuessEntityName( relatedObj ),
View Full Code Here

    if ( type != null ) {
      entityName = type;
    }

    // First mapping the primary key
    final IdMapper idMapper = verCfg.getEntCfg().get( entityName ).getIdMapper();
    final Map originalId = (Map) versionsEntity.get( verCfg.getAuditEntCfg().getOriginalIdPropName() );

    // Fixes HHH-4751 issue (@IdClass with @ManyToOne relation mapping inside)
    // Note that identifiers are always audited
    // Replace identifier proxies if do not point to audit tables
    replaceNonAuditIdProxies( versionsEntity, revision );

    final Object primaryKey = idMapper.mapToIdFromMap( originalId );

    // Checking if the entity is in cache
    if ( versionsReader.getFirstLevelCache().contains( entityName, revision, primaryKey ) ) {
      return versionsReader.getFirstLevelCache().get( entityName, revision, primaryKey );
    }

    // If it is not in the cache, creating a new entity instance
    Object ret;
    try {
      EntityConfiguration entCfg = verCfg.getEntCfg().get( entityName );
      if ( entCfg == null ) {
        // a relation marked as RelationTargetAuditMode.NOT_AUDITED
        entCfg = verCfg.getEntCfg().getNotVersionEntityConfiguration( entityName );
      }

      final Class<?> cls = ReflectionTools.loadClass( entCfg.getEntityClassName(), verCfg.getClassLoaderService() );
      ret = ReflectHelper.getDefaultConstructor( cls ).newInstance();
    }
    catch (Exception e) {
      throw new AuditException( e );
    }

    // Putting the newly created entity instance into the first level cache, in case a one-to-one bidirectional
    // relation is present (which is eagerly loaded).
    versionsReader.getFirstLevelCache().put( entityName, revision, primaryKey, ret );

    verCfg.getEntCfg().get( entityName ).getPropertyMapper().mapToEntityFromMap(
        verCfg,
        ret,
        versionsEntity,
        primaryKey,
        versionsReader,
        revision
    );
    idMapper.mapToEntityFromMap( ret, originalId );

    // Put entity on entityName cache after mapping it from the map representation
    versionsReader.getFirstLevelCache().putOnEntityNameCache( primaryKey, revision, ret, entityName );

    return ret;
View Full Code Here

    );

    final String lastPropertyPrefix = MappingTools.createToOneRelationPrefix( propertyAuditingData.getName() );

    // Generating the id mapper for the relation
    final IdMapper relMapper = idMapping.getIdMapper().prefixMappedProperties( lastPropertyPrefix );

    // Storing information about this relation
    mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneRelation(
        propertyAuditingData.getName(), referencedEntityName, relMapper,
        insertable, MappingTools.ignoreNotFound( value )
View Full Code Here

    final String lastPropertyPrefix = MappingTools.createToOneRelationPrefix( owningReferencePropertyName );
    final String referencedEntityName = propertyValue.getReferencedEntityName();

    // Generating the id mapper for the relation
    final IdMapper ownedIdMapper = ownedIdMapping.getIdMapper().prefixMappedProperties( lastPropertyPrefix );

    // Storing information about this relation
    mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneNotOwningRelation(
        propertyAuditingData.getName(), owningReferencePropertyName, referencedEntityName,
        ownedIdMapper, MappingTools.ignoreNotFound( value )
View Full Code Here

    );

    final String lastPropertyPrefix = MappingTools.createToOneRelationPrefix( propertyAuditingData.getName() );

    // Generating the id mapper for the relation
    final IdMapper relMapper = idMapping.getIdMapper().prefixMappedProperties( lastPropertyPrefix );

    // Storing information about this relation
    mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneRelation(
        propertyAuditingData.getName(), referencedEntityName, relMapper, insertable,
        MappingTools.ignoreNotFound( value )
View Full Code Here

TOP

Related Classes of org.hibernate.envers.internal.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.