Package org.hibernate.envers.internal.entities

Examples of org.hibernate.envers.internal.entities.RelationDescription


  }

  public static RelationDescription getRelatedEntity(
      AuditConfiguration verCfg, String entityName,
      String propertyName) throws AuditException {
    RelationDescription relationDesc = verCfg.getEntCfg().getRelationDescription( entityName, propertyName );

    if ( relationDesc == null ) {
      return null;
    }

    if ( relationDesc.getRelationType() == RelationType.TO_ONE ) {
      return relationDesc;
    }

    throw new AuditException(
        "This type of relation (" + entityName + "." + propertyName +
View Full Code Here


  }

  public static RelationDescription getRelatedEntity(
      AuditConfiguration verCfg, String entityName,
      String propertyName) throws AuditException {
    RelationDescription relationDesc = verCfg.getEntCfg().getRelationDescription( entityName, propertyName );

    if ( relationDesc == null ) {
      return null;
    }

    if ( relationDesc.getRelationType() == RelationType.TO_ONE ) {
      return relationDesc;
    }

    throw new AuditException(
        "This type of relation (" + entityName + "." + propertyName +
View Full Code Here

        versionsReader,
        entityName,
        propertyNameGetter
    );

    RelationDescription relatedEntity = CriteriaTools.getRelatedEntity( auditCfg, entityName, propertyName );

    if ( relatedEntity == null ) {
      throw new AuditException(
          "This criterion can only be used on a property that is " +
              "a relation to another property."
      );
    }
    else {
      relatedEntity.getIdMapper().addIdEqualsToQuery( parameters, id, null, equals );
    }
  }
View Full Code Here

        versionsReader,
        entityName,
        propertyNameGetter
    );

    RelationDescription relatedEntity = CriteriaTools.getRelatedEntity( auditCfg, entityName, propertyName );

    if ( relatedEntity == null ) {
      parameters.addWhereWithParam( propertyName, op, value );
    }
    else {
      if ( !"=".equals( op ) && !"<>".equals( op ) ) {
        throw new AuditException(
            "This type of operation: " + op + " (" + entityName + "." + propertyName +
                ") isn't supported and can't be used in queries."
        );
      }

      Object id = relatedEntity.getIdMapper().mapToIdFromEntity( value );

      relatedEntity.getIdMapper().addIdEqualsToQuery( parameters, id, null, "=".equals( op ) );
    }
  }
View Full Code Here

        auditCfg,
        versionsReader,
        entityName,
        propertyNameGetter
    );
    RelationDescription relatedEntity = CriteriaTools.getRelatedEntity( auditCfg, entityName, propertyName );

    if ( relatedEntity == null ) {
      parameters.addNotNullRestriction( propertyName, true );
    }
    else {
      relatedEntity.getIdMapper().addIdEqualsToQuery( parameters, null, null, false );
    }
  }
View Full Code Here

        auditCfg,
        versionsReader,
        entityName,
        propertyNameGetter
    );
    RelationDescription relatedEntity = CriteriaTools.getRelatedEntity( auditCfg, entityName, propertyName );

    if ( relatedEntity == null ) {
      parameters.addNullRestriction( propertyName, true );
    }
    else {
      relatedEntity.getIdMapper().addIdEqualsToQuery( parameters, null, null, true );
    }
  }
View Full Code Here

    // for the related entity is generated.
    final String[] propertyNames = entityPersister.getPropertyNames();

    for ( int i = 0; i < propertyNames.length; i++ ) {
      final String propertyName = propertyNames[i];
      final RelationDescription relDesc = enversConfiguration.getEntCfg().getRelationDescription(
          entityName,
          propertyName
      );
      if ( relDesc != null && relDesc.isBidirectional() && relDesc.getRelationType() == RelationType.TO_ONE &&
          relDesc.isInsertable() ) {
        // Checking for changes
        final Object oldValue = oldState == null ? null : oldState[i];
        final Object newValue = newState == null ? null : newState[i];

        if ( !EntityTools.entitiesEqual( session, relDesc.getToEntityName(), oldValue, newValue ) ) {
          // We have to generate changes both in the old collection (size decreses) and new collection
          // (size increases).
          if ( newValue != null ) {
            addCollectionChangeWorkUnit( auditProcess, session, entityName, relDesc, newValue );
          }
View Full Code Here

      final String ownerEntityName = ((AbstractCollectionPersister) collectionEntry.getLoadedPersister()).getOwnerEntityName();
      final 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.
      final RelationDescription rd = searchForRelationDescription( entityName, referencingPropertyName );
      if ( rd != null && rd.getMappedByPropertyName() != null ) {
        generateFakeBidirecationalRelationWorkUnits(
            auditProcess,
            newColl,
            oldColl,
            entityName,
View Full Code Here

   * @return A found relation description corresponding to the given entity or {@code null}, if no description can
   *         be found.
   */
  private RelationDescription searchForRelationDescription(String entityName, String referencingPropertyName) {
    final EntityConfiguration configuration = getAuditConfiguration().getEntCfg().get( entityName );
    final RelationDescription rd = configuration.getRelationDescription( referencingPropertyName );
    if ( rd == null && configuration.getParentEntityName() != null ) {
      return searchForRelationDescription( configuration.getParentEntityName(), referencingPropertyName );
    }

    return rd;
View Full Code Here

        versionsReader,
        entityName,
        propertyNameGetter
    );

    RelationDescription relatedEntity = CriteriaTools.getRelatedEntity( auditCfg, entityName, propertyName );

    if ( relatedEntity == null ) {
      throw new AuditException(
          "This criterion can only be used on a property that is " +
              "a relation to another property."
      );
    }
    else {
      relatedEntity.getIdMapper().addIdEqualsToQuery( parameters, id, null, equals );
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.envers.internal.entities.RelationDescription

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.