Package org.hibernate.mapping

Examples of org.hibernate.mapping.SimpleValue


      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


      onDeleteAppropriate = true;
      final JoinedSubclass jsc = (JoinedSubclass) persistentClass;
      if ( persistentClass.getEntityPersisterClass() == null ) {
        persistentClass.getRootClass().setEntityPersisterClass( JoinedSubclassEntityPersister.class );
      }
      SimpleValue key = new DependantValue( jsc.getTable(), jsc.getIdentifier() );
      jsc.setKey( key );
      ForeignKey fk = annotatedClass.getAnnotation( ForeignKey.class );
      if ( fk != null && !BinderHelper.isDefault( fk.name() ) ) {
        key.setForeignKeyName( fk.name() );
      }
      if ( onDeleteAnn != null ) {
        key.setCascadeDeleteEnabled( OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ) );
      }
      else {
        key.setCascadeDeleteEnabled( false );
      }
      //we are never in a second pass at that stage, so queue it
      SecondPass sp = new JoinedSubclassFkSecondPass( jsc, inheritanceJoinedColumns, key, mappings );
      mappings.addSecondPass( sp );
      mappings.addSecondPass( new CreateKeySecondPass( jsc ) );
View Full Code Here

      if ( discriminatorColumn == null ) {
        throw new AssertionFailure( "discriminator column should have been built" );
      }
      discriminatorColumn.setJoins( secondaryTables );
      discriminatorColumn.setPropertyHolder( propertyHolder );
      SimpleValue discrim = new SimpleValue( rootClass.getTable() );
      rootClass.setDiscriminator( discrim );
      discriminatorColumn.linkWithValue( discrim );
      discrim.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );
      rootClass.setPolymorphic( true );
      log.debug( "Setting discriminator for entity {}", rootClass.getEntityName() );
    }
  }
View Full Code Here

      propBinder.setReturnedClass( inferredData.getPropertyClass() );

      propBinder.setMappings( mappings );
      Property prop = propBinder.bind();
      rootClass.setVersion( prop );
      SimpleValue simpleValue = (SimpleValue) prop.getValue();
      if ( !simpleValue.isTypeSpecified() ) simpleValue.setTypeName( "integer" );
      simpleValue.setNullValue( "undefined" );
      rootClass.setOptimisticLockMode( Versioning.OPTIMISTIC_LOCK_VERSION );
      log.debug(
          "Version name: {}, unsavedValue: {}", rootClass.getVersion().getName(),
          ( (SimpleValue) rootClass.getVersion().getValue() ).getNullValue()
      );
View Full Code Here

    }
    RootClass rootClass = (RootClass) persistentClass;
    String persistentClassName = rootClass == null ?
        null :
        rootClass.getClassName();
    SimpleValue id;
    if ( isComposite ) {
      id = fillComponent(
          propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor,
          false, entityBinder, isEmbedded, isIdentifierMapper, false, mappings
      );
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( 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( 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

    value.setReturnedClassName( returnedClassName );
    value.setColumns( columns );
    value.setPersistentClassName( containerClassName );
    value.setType( property, returnedClass );
    value.setMappings( mappings );
    SimpleValue propertyValue = value.make();
    setValue( propertyValue );
    Property prop = make();
    holder.addProperty( prop, columns );
    return prop;
  }
View Full Code Here

    join.setPersistentClass( persistentClass );

    //no check constraints available on joins
    join.setTable( originalJoin.getTable() );
    join.setInverse( true );
    SimpleValue key = new DependantValue( 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

    validate();
    log.debug( "building SimpleValue for {}", propertyName );
    if ( table == null ) {
      table = columns[0].getTable();
    }
    SimpleValue simpleValue = new SimpleValue( table );
    return fillSimpleValue( simpleValue );
  }
View Full Code Here

      ExtendedMappings mappings
  ) {
    BinderHelper.createSyntheticPropertyReference(
        joinColumns, collValue.getOwner(), collectionEntity, collValue, false, mappings
    );
    SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, mappings );
    TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, mappings );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.SimpleValue

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.