Package org.hibernate.annotations.common

Examples of org.hibernate.annotations.common.AssertionFailure


          );
          ownerEntityKey = entityKey;
          collectionRole = getCollectionRoleFromToOne( associatedPersister );
        }
        else {
          throw new AssertionFailure( "Cannot detect associated entity metadata. propertyType is of unexpected type: " + propertyType.getClass() );
        }
      }
      else {
        throw new AssertionFailure( "Cannot detect associated entity metadata: collectionPersister and propertyType are both null" );
      }

      associationKey = new AssociationKey( associationKeyMetadata, columnValues, collectionRole, ownerEntityKey, associationKind );
    }
View Full Code Here


  private final AssociationKind associationKind;

  public AssociationKey(AssociationKeyMetadata metadata, Object[] columnValues, String collectionRole, EntityKey entityKey, AssociationKind associationKind) {
    this.metadata = metadata;
    if ( metadata.getColumnNames().length != columnValues.length ) {
      throw new AssertionFailure( "Column names do not match column values" );
    }
    this.columnValues = columnValues;
    this.collectionRole = collectionRole;
    this.entityKey = entityKey;
    this.associationKind = associationKind;
View Full Code Here

      if ( name.equals( columnName ) ) {
        return getColumnValues()[i];
      }
    }

    throw new AssertionFailure(
        String.format( "Given column %s is not part of this key: %s", columnName, this.toString() )
    );
  }
View Full Code Here

          .getIdentifierOrUniqueKeyType( factory );
      gridTypeOfAssociatedId = typeTranslator.getType( identifierOrUniqueKeyType );
    }
    else if ( collection.isOneToMany() ) {
      // one to many but not what we expected
      throw new AssertionFailure( "Association marked as one to many but has no ManyToOneType: " + collection.getRole() );
    }
    else if ( getElementType().isAssociationType() && getElementType().isEntityType() ) {
      associationType = AssociationType.ASSOCIATION_TABLE_TO_ENTITY;
      final Type identifierOrUniqueKeyType = ( (EntityType) getElementType() ).getIdentifierOrUniqueKeyType( factory );
      gridTypeOfAssociatedId = typeTranslator.getType( identifierOrUniqueKeyType );
View Full Code Here

      if ( collection.needsUpdating( entry, i, elementType ) ) {
        // find the matching element
        RowKey assocEntryKey = getTupleKeyForUpdate( key, collection, session, i, entry, associationPersister );
        Tuple assocEntryTuple = associationPersister.getAssociation().get( assocEntryKey );
        if ( assocEntryTuple == null ) {
          throw new AssertionFailure( "Updating a collection tuple that is not present: " + "table {" + getTableName() + "} collectionKey {" + key + "} entry {" + entry + "}" );
        }
        // update the matching element
        // FIXME update the associated entity key data
        updateInverseSideOfAssociationNavigation( session, entry, assocEntryTuple, Action.REMOVE, assocEntryKey );
View Full Code Here

        indexGridType.nullSafeSet( tuple, incrementIndexByBase( index ), getIndexColumnNames(), session );
      }
      else {
        final Object snapshotElement = collection.getSnapshotElement( entry, i );
        if ( elementIsPureFormula ) {
          throw new AssertionFailure( "cannot use a formula-based element in the where condition" );
        }
        getElementGridType().nullSafeSet( tuple, snapshotElement, getElementColumnNames(), session );
      }
    }
    rowKeyBuilder.values( tuple );
View Full Code Here

        indexGridType.nullSafeSet( tuple, incrementIndexByBase( index ), getIndexColumnNames(), session );
      }
      else {
        final Object snapshotElement = entry;
        if ( elementIsPureFormula ) {
          throw new AssertionFailure( "cannot use a formula-based element in the where condition" );
        }
        getElementGridType().nullSafeSet( tuple, snapshotElement, getElementColumnNames(), session );
      }
    }
    rowKeyBuilder.values( tuple );
View Full Code Here

          Object entry = deletes.next();
          // find the matching element
          RowKey assocEntryKey = getTupleKeyForDelete( id, collection, session, entry, deleteByIndex, associationPersister );
          Tuple assocEntryTuple = associationPersister.getAssociation().get( assocEntryKey );
          if ( assocEntryTuple == null ) {
            throw new AssertionFailure( "Deleting a collection tuple that is not present: " + "table {" + getTableName() + "} collectionKey {" + id + "} entry {" + entry + "}" );
          }
          // delete the tuple
          updateInverseSideOfAssociationNavigation( session, entry, assocEntryTuple, Action.REMOVE, assocEntryKey );
          associationPersister.getAssociation().remove( assocEntryKey );
View Full Code Here

          entityTuple.put( columnName, tuple.get( columnName ) );
        }
      }
      else if ( action == Action.REMOVE ) {
        if ( hasIdentifier ) {
          throw new AssertionFailure( "A true OneToMany with an identifier for the collection: " + getRole() );
        }
        if ( hasIndex ) {
          // nullify the index
          indexGridType.nullSafeSet( entityTuple, null, getIndexColumnNames(), session );
        }
        keyGridType.nullSafeSet( entityTuple, null, getKeyColumnNames(), session );
      }
      else {
        throw new AssertionFailure( "Unknown action type: " + action );
      }
      gridDialect.updateTuple( entityTuple, entityKey, persister.getTupleContext() ); // update cache
    }
    else if ( associationType == AssociationType.ASSOCIATION_TABLE_TO_ENTITY ) {
      String[] elementColumnNames = getElementColumnNames();
      Object[] elementColumnValues = LogicalPhysicalConverterHelper.getColumnValuesFromResultset( tuple, elementColumnNames );
      Serializable entityId = (Serializable) gridTypeOfAssociatedId.nullSafeGet( tuple, getElementColumnNames(), session, null );

      AssociationPersister associationPersister = new AssociationPersister(
            getElementPersister().getMappedClass()
          )
          .gridDialect( gridDialect )
          .keyColumnValues( elementColumnValues )
          .session( session )
          .associationKeyMetadata( associationKeyMetadataFromElement )
          .collectionPersister( this )
          .key( entityId )
          .inverse();

      // TODO what happens when a row should be *updated* ?: I suspect ADD works OK as it's a put()
      if ( action == Action.ADD ) {
        RowKey inverseRowKey = updateRowKeyEntityKey( rowKey, associationPersister );
        Tuple assocTuple = associationPersister.createAndPutAssociationTuple( inverseRowKey );
        for ( String columnName : tuple.getColumnNames() ) {
          assocTuple.put( columnName, tuple.get( columnName ) );
        }
        associationPersister.getAssociation().put( inverseRowKey, assocTuple );
      }
      else if ( action == Action.REMOVE ) {
        // we try and match the whole tuple as it should be on both sides of the navigation
        if ( rowKey == null ) {
          throw new AssertionFailure( "Deleting a collection tuple that is not present: " + "table {"
              + getTableName() + "} key column names {" + Arrays.toString( elementColumnNames )
              + "} key column values {" + Arrays.toString( elementColumnValues ) + "}" );
        }
        RowKey inverseRowKey = updateRowKeyEntityKey( rowKey, associationPersister );
        associationPersister.getAssociation().remove( inverseRowKey );
      }
      else {
        throw new AssertionFailure( "Unknown action type: " + action );
      }

      if ( associationPersister.hostingEntityRequiresReadAfterUpdate() && entity == null ) {
        entity = session.getPersistenceContext().getEntity( session.generateEntityKey( entityId, getElementPersister() ) );
      }
View Full Code Here

        finally {
                    LOG.trace("Completed mapped superclass [" + safeMapping.getMappedClass().getName() + "]");
        }
      }
      else {
        throw new AssertionFailure( "Unexpected mapping type: " + mapping.getClass() );
      }
    }

    for ( EmbeddableTypeImpl embeddable : embeddables.values() ) {
      populateStaticMetamodel( embeddable );
View Full Code Here

TOP

Related Classes of org.hibernate.annotations.common.AssertionFailure

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.