Package org.hibernate.tuple

Examples of org.hibernate.tuple.GenerationTiming


    Attribute generatedNode = node.attribute( "generated" );
        String generationName = generatedNode == null ? null : generatedNode.getValue();

    // Handle generated properties.
    GenerationTiming generationTiming = GenerationTiming.parseFromName( generationName );
    if ( generationTiming == GenerationTiming.ALWAYS || generationTiming == GenerationTiming.INSERT ) {
      // we had generation specified...
      //     HBM only supports "database generated values"
      property.setValueGenerationStrategy( new GeneratedValueGeneration( generationTiming ) );

      // generated properties can *never* be insertable...
      if ( property.isInsertable() ) {
        if ( insertNode == null ) {
          // insertable simply because that is the user did not specify
          // anything; just override it
          property.setInsertable( false );
        }
        else {
          // the user specifically supplied insert="true",
          // which constitutes an illegal combo
          throw new MappingException(
              "cannot specify both insert=\"true\" and generated=\"" + generationTiming.name().toLowerCase() +
                  "\" for property: " +
                  propName
          );
        }
      }

      // properties generated on update can never be updateable...
      if ( property.isUpdateable() && generationTiming == GenerationTiming.ALWAYS ) {
        if ( updateNode == null ) {
          // updateable only because the user did not specify
          // anything; just override it
          property.setUpdateable( false );
        }
        else {
          // the user specifically supplied update="true",
          // which constitutes an illegal combo
          throw new MappingException(
              "cannot specify both update=\"true\" and generated=\"" + generationTiming.name().toLowerCase() +
                  "\" for property: " +
                  propName
          );
        }
      }
View Full Code Here


      GenerationStrategyPair pair = buildGenerationStrategyPair( sessionFactory, prop );
      inMemoryValueGenerationStrategies[i] = pair.getInMemoryStrategy();
      inDatabaseValueGenerationStrategies[i] = pair.getInDatabaseStrategy();

      if ( pair.getInMemoryStrategy() != null ) {
        final GenerationTiming timing = pair.getInMemoryStrategy().getGenerationTiming();
        if ( timing != GenerationTiming.NEVER ) {
          final ValueGenerator generator = pair.getInMemoryStrategy().getValueGenerator();
          if ( generator != null ) {
            // we have some level of generation indicated
            if ( timing == GenerationTiming.INSERT ) {
              foundPreInsertGeneratedValues = true;
            }
            else if ( timing == GenerationTiming.ALWAYS ) {
              foundPreInsertGeneratedValues = true;
              foundPreUpdateGeneratedValues = true;
            }
          }
        }
      }
      if pair.getInDatabaseStrategy() != null ) {
        final GenerationTiming timing =  pair.getInDatabaseStrategy().getGenerationTiming();
        if ( timing == GenerationTiming.INSERT ) {
          foundPostInsertGeneratedValues = true;
        }
        else if ( timing == GenerationTiming.ALWAYS ) {
          foundPostInsertGeneratedValues = true;
View Full Code Here

                  " and number of attributes for composite attribute : " + mappingProperty.getName()
          );
        }

        // the base-line values for the aggregated InDatabaseValueGenerationStrategy we will build here.
        GenerationTiming timing = GenerationTiming.INSERT;
        boolean referenceColumns = false;
        String[] columnValues = new String[ composite.getColumnSpan() ];

        // start building the aggregate values
        int propertyIndex = -1;
View Full Code Here

    if ( valueGeneration == null ) {
      return NoValueGeneration.INSTANCE;
    }

    final GenerationTiming when = valueGeneration.getGenerationTiming();

    if ( valueGeneration.getValueGenerator() == null ) {
      insertable = false;
      if ( when == GenerationTiming.ALWAYS ) {
        updatable = false;
View Full Code Here

    if ( valueGeneration == null ) {
      return NoValueGeneration.INSTANCE;
    }

    final GenerationTiming when = valueGeneration.getGenerationTiming();

    if ( valueGeneration.getValueGenerator() == null ) {
      insertable = false;
      if ( when == GenerationTiming.ALWAYS ) {
        updatable = false;
View Full Code Here

      GenerationStrategyPair pair = buildGenerationStrategyPair( sessionFactory, prop );
      inMemoryValueGenerationStrategies[i] = pair.getInMemoryStrategy();
      inDatabaseValueGenerationStrategies[i] = pair.getInDatabaseStrategy();

      if ( pair.getInMemoryStrategy() != null ) {
        final GenerationTiming timing = pair.getInMemoryStrategy().getGenerationTiming();
        if ( timing != GenerationTiming.NEVER ) {
          final ValueGenerator generator = pair.getInMemoryStrategy().getValueGenerator();
          if ( generator != null ) {
            // we have some level of generation indicated
            if ( timing == GenerationTiming.INSERT ) {
              foundPreInsertGeneratedValues = true;
            }
            else if ( timing == GenerationTiming.ALWAYS ) {
              foundPreInsertGeneratedValues = true;
              foundPreUpdateGeneratedValues = true;
            }
          }
        }
      }
      if pair.getInDatabaseStrategy() != null ) {
        final GenerationTiming timing =  pair.getInDatabaseStrategy().getGenerationTiming();
        if ( timing == GenerationTiming.INSERT ) {
          foundPostInsertGeneratedValues = true;
        }
        else if ( timing == GenerationTiming.ALWAYS ) {
          foundPostInsertGeneratedValues = true;
View Full Code Here

                  " and number of attributes for composite attribute : " + mappingProperty.getName()
          );
        }

        // the base-line values for the aggregated InDatabaseValueGenerationStrategy we will build here.
        GenerationTiming timing = GenerationTiming.INSERT;
        boolean referenceColumns = false;
        String[] columnValues = new String[ composite.getColumnSpan() ];

        // start building the aggregate values
        int propertyIndex = -1;
View Full Code Here

    Attribute generatedNode = node.attribute( "generated" );
        String generationName = generatedNode == null ? null : generatedNode.getValue();

    // Handle generated properties.
    GenerationTiming generationTiming = GenerationTiming.parseFromName( generationName );
    if ( generationTiming == GenerationTiming.ALWAYS || generationTiming == GenerationTiming.INSERT ) {
      // we had generation specified...
      //     HBM only supports "database generated values"
      property.setValueGenerationStrategy( new GeneratedValueGeneration( generationTiming ) );

      // generated properties can *never* be insertable...
      if ( property.isInsertable() ) {
        if ( insertNode == null ) {
          // insertable simply because that is the user did not specify
          // anything; just override it
          property.setInsertable( false );
        }
        else {
          // the user specifically supplied insert="true",
          // which constitutes an illegal combo
          throw new MappingException(
              "cannot specify both insert=\"true\" and generated=\"" + generationTiming.name().toLowerCase() +
                  "\" for property: " +
                  propName
          );
        }
      }

      // properties generated on update can never be updateable...
      if ( property.isUpdateable() && generationTiming == GenerationTiming.ALWAYS ) {
        if ( updateNode == null ) {
          // updateable only because the user did not specify
          // anything; just override it
          property.setUpdateable( false );
        }
        else {
          // the user specifically supplied update="true",
          // which constitutes an illegal combo
          throw new MappingException(
              "cannot specify both update=\"true\" and generated=\"" + generationTiming.name().toLowerCase() +
                  "\" for property: " +
                  propName
          );
        }
      }
View Full Code Here

TOP

Related Classes of org.hibernate.tuple.GenerationTiming

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.