Package org.hibernate

Examples of org.hibernate.AssertionFailure


   * Return the property name or propertyTableName
   */
  public String foreignKeyColumnName(String propertyName, String propertyEntityName,
      String propertyTableName, String referencedColumnName) {
    String header = null == propertyName ? propertyTableName : unqualify(propertyName);
    if (header == null) { throw new AssertionFailure("NamingStrategy not properly filled"); }
    // workground annotation collection foreignKey.
    if (header.endsWith("s")) {
      header = addUnderscores(propertyTableName);
    } else {
      header = addUnderscores(header);
View Full Code Here


   */
  public String foreignKeyColumnName(
      String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
  ) {
    String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
    if (header == null) throw new AssertionFailure("NamingStrategy not properly filled");
    return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
  }
View Full Code Here

  public EmbeddedCacheManager getCacheManager(final int expectedGroupSize) {
    if ( ! started ) {
      throw new IllegalStateException( "The before() method of this Rule was not triggered (or did not complete succesfully)" );
    }
    if ( manager == null ) {
      throw new AssertionFailure( "Unexpected state: the CacheManager not created?" );
    }
    if ( ! groupFormed && expectedGroupSize != 1 ) {
      verifyNetworkStackEnabled();
      verifyConfiguredAsClustered( manager );
      TestingUtil.blockUntilViewReceived( manager.getCache(), expectedGroupSize, joinTimeoutMilliseconds, true );
View Full Code Here

      case EMBEDDED_COLLECTION:
        return createRelationshipWithEmbeddedNode( associationKey, associationRow, associatedEntityKeyMetadata );
      case ASSOCIATION:
        return findOrCreateRelationshipWithEntityNode( associationKey, associationRow, associatedEntityKeyMetadata );
      default:
        throw new AssertionFailure( "Unrecognized associationKind: " + associationKey.getMetadata().getAssociationKind() );
    }
  }
View Full Code Here

        return binding;
      }
      binding = binding.getSuperEntityBinding();
    } while ( binding != null );

    throw new AssertionFailure( "Entity binding has no root: " + entityName );
  }
View Full Code Here

  }

  @Override
  public Object forceVersionIncrement(Serializable id, Object currentVersion, SessionImplementor session) {
    if ( !isVersioned() ) {
      throw new AssertionFailure( "cannot force version increment on non-versioned entity" );
    }

    if ( isVersionPropertyGenerated() ) {
      // the difficulty here is exactly what do we update in order to
      // force the version to be incremented in the db...
View Full Code Here

    final GridType gridUniqueKeyType = getUniqueKeyTypeFromAssociatedEntity( propertyIndex, propertyName );
    //get the associated property index (to get its column names)
    //find the ids per unique property name
    AssociationKeyMetadata associationKeyMetadata = inverseOneToOneAssociationKeyMetadata.get( propertyName );
    if ( associationKeyMetadata == null ) {
      throw new AssertionFailure( "loadByUniqueKey on a non EntityType:" + propertyName );
    }

    OgmEntityPersister inversePersister = (OgmEntityPersister) ((EntityType) getPropertyTypes()[propertyIndex]).getAssociatedJoinable( session.getFactory() );

    OptionsServiceContext serviceContext = session.getFactory()
        .getServiceRegistry()
        .getService( OptionsService.class )
        .context();

    AssociationTypeContext associationTypeContext = new AssociationTypeContextImpl(
        serviceContext.getPropertyOptions( inversePersister.getMappedClass(), associationKeyMetadata.getCollectionRole() ),
        associationKeyMetadata.getAssociatedEntityKeyMetadata(),
        getPropertyNames()[propertyIndex]
    );

    AssociationPersister associationPersister = new AssociationPersister(
        inversePersister.getMappedClass()
        )
        .gridDialect( gridDialect )
        .key( uniqueKey, gridUniqueKeyType )
        .associationKeyMetadata( associationKeyMetadata )
        .session( session )
        .associationTypeContext( associationTypeContext )
        .hostingEntity( session.getPersistenceContext().getEntity( new org.hibernate.engine.spi.EntityKey( (Serializable) uniqueKey, inversePersister ) ) );

    final Association ids = associationPersister.getAssociationOrNull();

    if (ids == null || ids.size() == 0 ) {
      return null;
    }
    else if (ids.size() == 1) {
      //EntityLoader#loadByUniqueKey uses a null object and LockMode.NONE
      //there is only one element in the list, so get the first
      Tuple tuple = ids.get( ids.getKeys().iterator().next() );
      final Serializable id = (Serializable) getGridIdentifierType().nullSafeGet( tuple, getIdentifierColumnNames(), session, null );
      return load( id, null, LockMode.NONE, session );
    }
    else {
      throw new AssertionFailure(
          "Loading by unique key but finding several matches: table:" + getTableName()
              + " property: " + propertyName
              + " value: " + uniqueKey );
    }
  }
View Full Code Here

      EntityType entityType = (EntityType) uniqueKeyType;
      final OgmEntityPersister entityPersister = (OgmEntityPersister) entityType.getAssociatedJoinable( getFactory() );
      gridUniqueKeyType = entityPersister.getGridIdentifierType();
    }
    else {
      throw new AssertionFailure( "loadByUniqueKey on a non EntityType:" + propertyName );
    }
    return gridUniqueKeyType;
  }
View Full Code Here

  }

  @Override
  public String getSubclassTableName(int j) {
    if ( j != 0 ) {
      throw new AssertionFailure( "only one table" );
    }
    return tableName;
  }
View Full Code Here

  }

  @Override
  protected String[] getSubclassTableKeyColumns(int j) {
    if ( j != 0 ) {
      throw new AssertionFailure( "only one table" );
    }
    return getIdentifierColumnNames();
  }
View Full Code Here

TOP

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