Package org.hibernate.type

Examples of org.hibernate.type.EntityType


          e,
          "Could not read entity row-id from ResultSet : " + entityKey
      );
    }

    final EntityType entityType = EntityFetch.class.isInstance( entityReference )
        ? ( (EntityFetch) entityReference ).getFetchedType()
        : entityReference.getEntityPersister().getEntityMetamodel().getEntityType();

    if ( entityType != null ) {
      String ukName = entityType.getRHSUniqueKeyPropertyName();
      if ( ukName != null ) {
        final int index = ( (UniqueKeyLoadable) concreteEntityPersister ).getPropertyIndex( ukName );
        final Type type = concreteEntityPersister.getPropertyTypes()[index];

        // polymorphism not really handled completely correctly,
View Full Code Here


        throw new QueryException( me );
      }
    }
    join.addCondition( collectionName, keyColumnNames, " = ?" );
    //if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(collectionName) );
    EntityType elemType = ( EntityType ) collectionElementType;
    addFrom( elementName, elemType.getAssociatedEntityName(), join );

  }
View Full Code Here

  private void determineKeySelectExpressions(QueryableCollection collectionPersister, List selections) {
    AliasGenerator aliasGenerator = new LocalAliasGenerator( 0 );
    appendSelectExpressions( collectionPersister.getIndexColumnNames(), selections, aliasGenerator );
    Type keyType = collectionPersister.getIndexType();
    if ( keyType.isAssociationType() ) {
      EntityType entityType = (EntityType) keyType;
      Queryable keyEntityPersister = (Queryable) sfi().getEntityPersister(
          entityType.getAssociatedEntityName( sfi() )
      );
      SelectFragment fragment = keyEntityPersister.propertySelectFragmentFragment(
          collectionTableAlias(),
          null,
          false
View Full Code Here

  private void determineValueSelectExpressions(QueryableCollection collectionPersister, List selections) {
    AliasGenerator aliasGenerator = new LocalAliasGenerator( 1 );
    appendSelectExpressions( collectionPersister.getElementColumnNames(), selections, aliasGenerator );
    Type valueType = collectionPersister.getElementType();
    if ( valueType.isAssociationType() ) {
      EntityType valueEntityType = (EntityType) valueType;
      Queryable valueEntityPersister = (Queryable) sfi().getEntityPersister(
          valueEntityType.getAssociatedEntityName( sfi() )
      );
      SelectFragment fragment = valueEntityPersister.propertySelectFragmentFragment(
          elementTableAlias(),
          null,
          false
View Full Code Here

      try {
        FromElement fromElement = null;
        if ( !explicitFetches.containsKey( role ) ) {
          if ( propertyType.isEntityType() ) {
            final EntityType entityType = (EntityType) propertyType;

            final String[] columns = origin.toColumns( originTableAlias, attributeName, false );
            final String tableAlias = walker.getAliasGenerator().createName(
                entityType.getAssociatedEntityName()
            );

            final FromElementFactory fromElementFactory = new FromElementFactory(
                fromClause, origin,
                attributeName, classAlias, columns, false
            );
            final JoinSequence joinSequence = walker.getSessionFactoryHelper().createJoinSequence(
                false, entityType, tableAlias, JoinType.LEFT_OUTER_JOIN, columns
            );
            fromElement = fromElementFactory.createEntityJoin(
                entityType.getAssociatedEntityName(),
                tableAlias,
                joinSequence,
                true,
                walker.isInFrom(),
                entityType,
View Full Code Here

    if ( value == null ) {
      return;
    }

    if ( type.isEntityType() ) {
      final EntityType entityType = (EntityType) type;
      if ( !isNullable
          && !entityType.isOneToOne()
          && nullifier.isNullifiable( entityType.getAssociatedEntityName(), value ) ) {
        nonNullableTransientEntities.add( propertyName, value );
      }
    }
    else if ( type.isAnyType() ) {
      if ( !isNullable && nullifier.isNullifiable( null, value ) ) {
View Full Code Here

    private Object nullifyTransientReferences(final Object value, final Type type) {
      if ( value == null ) {
        return null;
      }
      else if ( type.isEntityType() ) {
        final EntityType entityType = (EntityType) type;
        if ( entityType.isOneToOne() ) {
          return value;
        }
        else {
          final String entityName = entityType.getAssociatedEntityName();
          return isNullifiable( entityName, value ) ? null : value;
        }
      }
      else if ( type.isAnyType() ) {
        return isNullifiable( null, value ) ? null : value;
View Full Code Here

      throw new IdentifierGenerationException(
          "attempted to assign id from null one-to-one property [" + getRole() + "]"
      );
    }

    final EntityType foreignValueSourceType;
    final Type propertyType = persister.getPropertyType( propertyName );
    if ( propertyType.isEntityType() ) {
      // the normal case
      foreignValueSourceType = (EntityType) propertyType;
    }
    else {
      // try identifier mapper
      foreignValueSourceType = (EntityType) persister.getPropertyType( PropertyPath.IDENTIFIER_MAPPER_PROPERTY + "." + propertyName );
    }

    Serializable id;
    try {
      id = ForeignKeys.getEntityIdentifierIfNotUnsaved(
          foreignValueSourceType.getAssociatedEntityName(),
          associatedObject,
          sessionImplementor
      );
    }
    catch (TransientObjectException toe) {
      id = session.save( foreignValueSourceType.getAssociatedEntityName(), associatedObject );
    }

    if ( session.contains(object) ) {
      //abort the save (the object is already saved by a circular cascade)
      return IdentifierGeneratorHelper.SHORT_CIRCUIT_INDICATOR;
View Full Code Here

        final EmbeddedComponentType dependentIdType =
            (EmbeddedComponentType) persister.getEntityMetamodel().getIdentifierProperty().getType();
        if ( dependentIdType.getSubtypes().length == 1 ) {
          final Type singleSubType = dependentIdType.getSubtypes()[0];
          if ( singleSubType.isEntityType() ) {
            final EntityType dependentParentType = (EntityType) singleSubType;
            final Type dependentParentIdType = dependentParentType.getIdentifierOrUniqueKeyType( source.getFactory() );
            if ( dependentParentIdType.getReturnedClass().isInstance( event.getEntityId() ) ) {
              // yep that's what we have...
              loadByDerivedIdentitySimplePkValue(
                  event,
                  loadType,
                  persister,
                  dependentIdType,
                  source.getFactory().getEntityPersister( dependentParentType.getAssociatedEntityName() )
              );
              return;
            }
          }
        }
View Full Code Here

        NonScalarReturn ownerDescriptor = fetchRtn.getOwner();
        int ownerIndex = nonScalarReturnList.indexOf( ownerDescriptor );
        entityOwners.add( new Integer( ownerIndex ) );
        lockModes.add( fetchRtn.getLockMode() );
        Queryable ownerPersister = determineAppropriateOwnerPersister( ownerDescriptor );
        EntityType fetchedType = ( EntityType ) ownerPersister.getPropertyType( fetchRtn.getOwnerProperty() );
        String entityName = fetchedType.getAssociatedEntityName( getFactory() );
        Queryable persister = ( Queryable ) factory.getEntityPersister( entityName );
        entityPersisters.add( persister );
        nonScalarReturnList.add( rtn );
        specifiedAliases.add( fetchRtn.getAlias() );
        entityAliases.add( fetchRtn.getEntityAliases() );
View Full Code Here

TOP

Related Classes of org.hibernate.type.EntityType

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.