Package org.hibernate.mapping

Examples of org.hibernate.mapping.SimpleValue$ParameterTypeImpl


      java.util.Map inheritedMetas) throws MappingException {

    bindCollectionSecondPass( node, collection, persistentClasses, mappings, inheritedMetas );

    Element subnode = node.element( "collection-id" );
    SimpleValue id = new SimpleValue( collection.getCollectionTable() );
    bindSimpleValue(
        subnode,
        id,
        false,
        IdentifierCollection.DEFAULT_IDENTIFIER_COLUMN_NAME,
View Full Code Here


    while ( iter.hasNext() ) {
      Element subnode = (Element) iter.next();
      String name = subnode.getName();

      if ( "index".equals( name ) || "map-key".equals( name ) ) {
        SimpleValue value = new SimpleValue( map.getCollectionTable() );
        bindSimpleValue(
            subnode,
            value,
            map.isOneToMany(),
            IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
            mappings
          );
        if ( !value.isTypeSpecified() ) {
          throw new MappingException( "map index element must specify a type: "
            + map.getRole() );
        }
        map.setIndex( value );
        map.setIndexNodeName( subnode.attributeValue("node") );
View Full Code Here

          keyVal = collection.getOwner().getIdentifier();
        }
        else {
          keyVal = (KeyValue) collection.getOwner().getRecursiveProperty( propRef ).getValue();
        }
        SimpleValue key = new DependantValue( collection.getCollectionTable(), keyVal );
        key.setCascadeDeleteEnabled( "cascade"
          .equals( subnode.attributeValue( "on-delete" ) ) );
        bindSimpleValue(
            subnode,
            key,
            collection.isOneToMany(),
            Collection.DEFAULT_KEY_COLUMN_NAME,
            mappings
          );
        collection.setKey( key );

        Attribute notNull = subnode.attribute( "not-null" );
        ( (DependantValue) key ).setNullable( notNull == null
          || notNull.getValue().equals( "false" ) );
        Attribute updateable = subnode.attribute( "update" );
        ( (DependantValue) key ).setUpdateable( updateable == null
          || updateable.getValue().equals( "true" ) );

      }
      else if ( "element".equals( name ) ) {
        SimpleValue elt = new SimpleValue( collection.getCollectionTable() );
        collection.setElement( elt );
        bindSimpleValue(
            subnode,
            elt,
            true,
View Full Code Here

    }
    bindJoinToPersistentClass( join, ejb3JoinColumns, mappings );
  }

  private void bindJoinToPersistentClass(Join join, Ejb3JoinColumn[] ejb3JoinColumns, Mappings mappings) {
    SimpleValue key = new DependantValue( mappings, join.getTable(), persistentClass.getIdentifier() );
    join.setKey( key );
    setFKNameIfDefined( join );
    key.setCascadeDeleteEnabled( false );
    TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, mappings );
    join.createPrimaryKey();
    join.createForeignKey();
    persistentClass.addJoin( join );
  }
View Full Code Here

        holder.resolveAttributeConverterDefinition( property )
    );
    simpleValueBinder.setMappings( mappings );
    simpleValueBinder.setReferencedEntityName( referencedEntityName );
    simpleValueBinder.setAccessType( accessType );
    SimpleValue propertyValue = simpleValueBinder.make();
    setValue( propertyValue );
    return makeProperty();
  }
View Full Code Here

      indexColumn.setPropertyHolder( valueHolder );
      SimpleValueBinder value = new SimpleValueBinder();
      value.setColumns( new Ejb3Column[] { indexColumn } );
      value.setExplicitType( "integer" );
      value.setMappings( mappings );
      SimpleValue indexValue = value.make();
      indexColumn.linkWithValue( indexValue );
      list.setIndex( indexValue );
      list.setBaseIndex( indexColumn.getBase() );
      if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
        String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
View Full Code Here

    join.setPersistentClass( persistentClass );

    //no check constraints available on joins
    join.setTable( originalJoin.getTable() );
    join.setInverse( true );
    SimpleValue key = new DependantValue( mappings, join.getTable(), persistentClass.getIdentifier() );
    //TODO support @ForeignKey
    join.setKey( key );
    join.setSequentialSelect( false );
    //TODO support for inverse and optional
    join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway
    key.setCascadeDeleteEnabled( false );
    Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator();
    while ( mappedByColumns.hasNext() ) {
      Column column = (Column) mappedByColumns.next();
      Column copy = new Column();
      copy.setLength( column.getLength() );
      copy.setScale( column.getScale() );
      copy.setValue( key );
      copy.setName( column.getQuotedName() );
      copy.setNullable( column.isNullable() );
      copy.setPrecision( column.getPrecision() );
      copy.setUnique( column.isUnique() );
      copy.setSqlType( column.getSqlType() );
      copy.setCheckConstraint( column.getCheckConstraint() );
      copy.setComment( column.getComment() );
      copy.setDefaultValue( column.getDefaultValue() );
      key.addColumn( copy );
    }
    persistentClass.addJoin( join );
    return join;
  }
View Full Code Here

        indexComponent.addProperty( newProperty );
      }
      return indexComponent;
    }
    else if ( value instanceof SimpleValue ) {
      SimpleValue sourceValue = (SimpleValue) value;
      SimpleValue targetValue;
      if ( value instanceof ManyToOne ) {
        ManyToOne sourceManyToOne = (ManyToOne) sourceValue;
        ManyToOne targetManyToOne = new ManyToOne( mappings, collection.getCollectionTable() );
        targetManyToOne.setFetchMode( FetchMode.DEFAULT );
        targetManyToOne.setLazy( true );
        //targetValue.setIgnoreNotFound( ); does not make sense for a map key
        targetManyToOne.setReferencedEntityName( sourceManyToOne.getReferencedEntityName() );
        targetValue = targetManyToOne;
      }
      else {
        targetValue = new SimpleValue( mappings, collection.getCollectionTable() );
        targetValue.setTypeName( sourceValue.getTypeName() );
        targetValue.setTypeParameters( sourceValue.getTypeParameters() );
      }
      Iterator columns = sourceValue.getColumnIterator();
      Random random = new Random();
      while ( columns.hasNext() ) {
        Object current = columns.next();
        Formula formula = new Formula();
        String formulaString;
        if ( current instanceof Column ) {
          formulaString = ( (Column) current ).getQuotedName();
        }
        else if ( current instanceof Formula ) {
          formulaString = ( (Formula) current ).getFormula();
        }
        else {
          throw new AssertionFailure( "Unknown element in column iterator: " + current.getClass() );
        }
        if ( fromAndWhere != null ) {
          formulaString = Template.renderWhereStringTemplate( formulaString, "$alias$", new HSQLDialect() );
          formulaString = "(select " + formulaString + fromAndWhere + ")";
          formulaString = StringHelper.replace(
              formulaString,
              "$alias$",
              "a" + random.nextInt( 16 )
          );
        }
        formula.setFormula( formulaString );
        targetValue.addFormula( formula );

      }
      return targetValue;
    }
    else {
View Full Code Here

      );
    }
    catch (AnnotationException ex) {
      throw new AnnotationException( "Unable to map collection " + collectionEntity.getClassName() + "." + property.getName(), ex );
    }
    SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, mappings );
    if ( property.isAnnotationPresent( ElementCollection.class ) && joinColumns.length > 0 ) {
      joinColumns[0].setJPA2ElementCollection( true );
    }
    TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, mappings );
  }
View Full Code Here

    simpleValueBinder.setColumns( columns );
    simpleValueBinder.setPersistentClassName( containerClassName );
    simpleValueBinder.setType( property, returnedClass );
    simpleValueBinder.setMappings( mappings );
    simpleValueBinder.setReferencedEntityName( referencedEntityName );
    SimpleValue propertyValue = simpleValueBinder.make();
    setValue( propertyValue );
    return makeProperty();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.SimpleValue$ParameterTypeImpl

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.