Package org.hibernate.mapping

Examples of org.hibernate.mapping.KeyValue


    final String propertyName = inferredData.getPropertyName();
    LOG.tracev( "Fetching {0} with {1}", propertyName, fetchMode );
    boolean mapToPK = true;
    if ( !trueOneToOne ) {
      //try to find a hidden true one to one (FK == PK columns)
      KeyValue identifier = propertyHolder.getIdentifier();
      if ( identifier == null ) {
        //this is a @OneToOne in a @EmbeddedId (the persistentClass.identifier is not set yet, it's being built)
        //by definition the PK cannot refers to itself so it cannot map to itself
        mapToPK = false;
      }
      else {
        Iterator idColumns = identifier.getColumnIterator();
        List<String> idColumnNames = new ArrayList<String>();
        org.hibernate.mapping.Column currentColumn;
        if ( identifier.getColumnSpan() != joinColumns.length ) {
          mapToPK = false;
        }
        else {
          while ( idColumns.hasNext() ) {
            currentColumn = ( org.hibernate.mapping.Column ) idColumns.next();
View Full Code Here


    ArrayList cascadeDeletes = new ArrayList();
    Iterator titer = persistentClass.getTableClosureIterator();
    Iterator kiter = persistentClass.getKeyClosureIterator();
    while ( titer.hasNext() ) {
      Table tab = (Table) titer.next();
      KeyValue key = (KeyValue) kiter.next();
      String tabname = tab.getQualifiedName(
          factory.getDialect(),
          factory.getSettings().getDefaultCatalogName(),
          factory.getSettings().getDefaultSchemaName()
      );
      tables.add( tabname );
      String[] keyCols = new String[idColumnSpan];
      String[] keyColReaders = new String[idColumnSpan];
      String[] keyColReaderTemplates = new String[idColumnSpan];
      Iterator citer = key.getColumnIterator();
      for ( int k = 0; k < idColumnSpan; k++ ) {
        Column column = (Column) citer.next();
        keyCols[k] = column.getQuotedName( factory.getDialect() );
        keyColReaders[k] = column.getReadExpr( factory.getDialect() );
        keyColReaderTemplates[k] = column.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
      }
      keyColumns.add( keyCols );
      keyColumnReaders.add( keyColReaders );
      keyColumnReaderTemplates.add( keyColReaderTemplates );
      cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete() );
    }

    //Span of the tables directly mapped by this entity and super-classes, if any
    coreTableSpan = tables.size();

    isNullableTable = new boolean[persistentClass.getJoinClosureSpan()];

    int tableIndex = 0;
    Iterator joinIter = persistentClass.getJoinClosureIterator();
    while ( joinIter.hasNext() ) {
      Join join = (Join) joinIter.next();

      isNullableTable[tableIndex++] = join.isOptional();

      Table table = join.getTable();

      String tableName = table.getQualifiedName(
          factory.getDialect(),
          factory.getSettings().getDefaultCatalogName(),
          factory.getSettings().getDefaultSchemaName()
      );
      tables.add( tableName );

      KeyValue key = join.getKey();
      int joinIdColumnSpan = key.getColumnSpan();

      String[] keyCols = new String[joinIdColumnSpan];
      String[] keyColReaders = new String[joinIdColumnSpan];
      String[] keyColReaderTemplates = new String[joinIdColumnSpan];

      Iterator citer = key.getColumnIterator();

      for ( int k = 0; k < joinIdColumnSpan; k++ ) {
        Column column = (Column) citer.next();
        keyCols[k] = column.getQuotedName( factory.getDialect() );
        keyColReaders[k] = column.getReadExpr( factory.getDialect() );
        keyColReaderTemplates[k] = column.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
      }
      keyColumns.add( keyCols );
      keyColumnReaders.add( keyColReaders );
      keyColumnReaderTemplates.add( keyColReaderTemplates );
      cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete() );
    }

    naturalOrderTableNames = ArrayHelper.toStringArray( tables );
    naturalOrderTableKeyColumns = ArrayHelper.to2DStringArray( keyColumns );
    naturalOrderTableKeyColumnReaders = ArrayHelper.to2DStringArray( keyColumnReaders );
View Full Code Here

    }
    else {
      //try the embedded property
      //embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationBinder
      if ( path.startsWith( "id." ) ) {
        KeyValue valueIdentifier = persistentClass.getIdentifier();
        String localPath = path.substring( 3 );
        if ( valueIdentifier instanceof Component ) {
          Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
          while ( it.hasNext() ) {
            Property idProperty = (Property) it.next();
View Full Code Here

    }
    else if ( persistentClass.hasIdentifierMapper() ) {
      jpaEntityType.getBuilder().applyIdClassAttributes( buildIdClassAttributes( jpaEntityType, persistentClass ) );
    }
    else {
      final KeyValue value = persistentClass.getIdentifier();
      if (value instanceof Component ) {
        final Component component = ( Component ) value;
        if ( component.getPropertySpan() > 1 ) {
          //FIXME we are an Hibernate embedded id (ie not type)
        }
View Full Code Here

      Iterator<Property> propertyIterator = persistentClass.getIdentifierMapper().getPropertyIterator();
      Set<SingularAttribute<? super X, ?>> attributes = buildIdClassAttributes( jpaEntityType, propertyIterator );
      jpaEntityType.getBuilder().applyIdClassAttributes( attributes );
    }
    else {
      final KeyValue value = persistentClass.getIdentifier();
      if (value instanceof Component ) {
        final Component component = ( Component ) value;
        if ( component.getPropertySpan() > 1 ) {
          //FIXME we are an Hibernate embedded id (ie not type)
        }
View Full Code Here

    ArrayList cascadeDeletes = new ArrayList();
    Iterator titer = persistentClass.getTableClosureIterator();
    Iterator kiter = persistentClass.getKeyClosureIterator();
    while ( titer.hasNext() ) {
      Table tab = (Table) titer.next();
      KeyValue key = (KeyValue) kiter.next();
      String tabname = tab.getQualifiedName(
          factory.getDialect(),
          factory.getSettings().getDefaultCatalogName(),
          factory.getSettings().getDefaultSchemaName()
      );
      tables.add(tabname);
      String[] keyCols = new String[idColumnSpan];
      Iterator citer = key.getColumnIterator();
      for ( int k=0; k<idColumnSpan; k++ ) {
        keyCols[k] = ( (Column) citer.next() ).getQuotedName( factory.getDialect() );
      }
      keyColumns.add(keyCols);
      cascadeDeletes.add( new Boolean( key.isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete() ) );
    }
    naturalOrderTableNames = ArrayHelper.toStringArray(tables);
    naturalOrderTableKeyColumns = ArrayHelper.to2DStringArray(keyColumns);
    naturalOrderCascadeDeleteEnabled = ArrayHelper.toBooleanArray(cascadeDeletes);
View Full Code Here

    final String propertyName = inferredData.getPropertyName();
    log.debug( "Fetching {} with {}", propertyName, fetchMode );
    boolean mapToPK = true;
    if ( !trueOneToOne ) {
      //try to find a hidden true one to one (FK == PK columns)
      KeyValue identifier = propertyHolder.getIdentifier();
      if ( identifier == null ) {
        //this is a @OneToOne in a @EmbeddedId (the persistentClass.identifier is not set yet, it's being built)
        //by definition the PK cannot refers to itself so it cannot map to itself
        mapToPK = false;
      }
      else {
        Iterator idColumns = identifier.getColumnIterator();
        List<String> idColumnNames = new ArrayList<String>();
        org.hibernate.mapping.Column currentColumn;
        while ( idColumns.hasNext() ) {
          currentColumn = (org.hibernate.mapping.Column) idColumns.next();
          idColumnNames.add( currentColumn.getName() );
View Full Code Here

  private static SimpleValue buildCollectionKey(
      Collection collValue, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled,
      XProperty property, ExtendedMappings mappings
  ) {
    //binding key reference using column
    KeyValue keyVal;
    //give a chance to override the referenced property name
    //has to do that here because the referencedProperty creation happens in a FKSecondPass for Many to one yuk!
    if ( joinColumns.length > 0 && StringHelper.isNotEmpty( joinColumns[0].getMappedBy() ) ) {
      String entityName = joinColumns[0].getManyToManyOwnerSideEntityName() != null ?
          "inverse__" + joinColumns[0].getManyToManyOwnerSideEntityName() :
View Full Code Here

        mappedByColumns = ( (Collection) property.getValue() ).getKey().getColumnIterator();
      }
      else {
        //find the appropriate reference key, can be in a join
        Iterator joinsIt = referencedEntity.getJoinIterator();
        KeyValue key = null;
        while ( joinsIt.hasNext() ) {
          Join join = (Join) joinsIt.next();
          if ( join.containsProperty( property ) ) {
            key = join.getKey();
            break;
          }
        }
        if ( key == null ) key = property.getPersistentClass().getIdentifier();
        mappedByColumns = key.getColumnIterator();
      }
      while ( mappedByColumns.hasNext() ) {
        Column column = (Column) mappedByColumns.next();
        columns[0].linkValueUsingAColumnCopy( column, value );
      }
View Full Code Here

    }
    else {
      //try the embedded property
      //embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationBinder
      if ( path.startsWith( "id." ) ) {
        KeyValue valueIdentifier = persistentClass.getIdentifier();
        String localPath = path.substring( 3 );
        if ( valueIdentifier instanceof Component ) {
          Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
          while ( it.hasNext() ) {
            Property idProperty = (Property) it.next();
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.KeyValue

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.