public boolean isNaturalIdentifierInsertGenerated() {
   // the intention is for this call to replace the usage of the old ValueInclusion stuff (as
   // exposed from
   // persister) in SelectGenerator to determine if it is safe to use the natural identifier to
   // find the
   // insert-generated identifier.  That wont work if the natural-id is also insert-generated.
   //
   // Assumptions:
   //		* That code checks that there is a natural identifier before making this call, so we assume
   // the same here
   // 		* That code assumes a non-composite natural-id, so we assume the same here
   final InDatabaseValueGenerationStrategy strategy =
       inDatabaseValueGenerationStrategies[naturalIdPropertyNumbers[0]];
   return strategy != null && strategy.getGenerationTiming() != GenerationTiming.NEVER;
 }
    private void add(InDatabaseValueGenerationStrategy inDatabaseStrategy) {
      if (inDatabaseStrategies == null) {
        inDatabaseStrategies = new ArrayList<InDatabaseValueGenerationStrategy>();
      }
      inDatabaseStrategies.add(inDatabaseStrategy);

      if (inDatabaseStrategy.getGenerationTiming() != GenerationTiming.NEVER) {
        hadInDatabaseGeneration = true;
      }
    }
    public GenerationStrategyPair(
        InMemoryValueGenerationStrategy inMemoryStrategy,
        InDatabaseValueGenerationStrategy inDatabaseStrategy) {
      // perform some normalization.  Also check that only one (if any) strategy is specified
      if (inMemoryStrategy == null) {
        inMemoryStrategy = NoInMemoryValueGenerationStrategy.INSTANCE;
      }
      if (inDatabaseStrategy == null) {
        inDatabaseStrategy = NoInDatabaseValueGenerationStrategy.INSTANCE;
      }

      if (inMemoryStrategy.getGenerationTiming() != GenerationTiming.NEVER
          && inDatabaseStrategy.getGenerationTiming() != GenerationTiming.NEVER) {
        throw new ValueGenerationStrategyException(
            "in-memory and in-database value generation are mutually exclusive");
      }

      this.inMemoryStrategy = inMemoryStrategy;
      this.inDatabaseStrategy = inDatabaseStrategy;
    }
 public boolean isVersionGenerated() {
   final InDatabaseValueGenerationStrategy strategy =
       inDatabaseValueGenerationStrategies[versionPropertyIndex];
   return strategy != null && strategy.getGenerationTiming() != GenerationTiming.NEVER;
 }
    public GenerationStrategyPair buildPair() {
      if (hadInMemoryGeneration && hadInDatabaseGeneration) {
        throw new ValueGenerationStrategyException(
            "Composite attribute ["
                + mappingProperty.getName()
                + "] contained both in-memory"
                + " and in-database value generation");
      } else if (hadInMemoryGeneration) {
        throw new NotYetImplementedException(
            "Still need to wire in composite in-memory value generation");

      } else if (hadInDatabaseGeneration) {
        final Component composite = (Component) mappingProperty.getValue();

        // we need the numbers to match up so we can properly handle 'referenced sql column values'
        if (inDatabaseStrategies.size() != composite.getPropertySpan()) {
          throw new ValueGenerationStrategyException(
              "Internal error : mismatch between number of collected in-db generation strategies"
                  + " 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;
        int columnIndex = 0;
        Iterator subProperties = composite.getPropertyIterator();
        while (subProperties.hasNext()) {
          propertyIndex++;
          final Property subProperty = (Property) subProperties.next();
          final InDatabaseValueGenerationStrategy subStrategy =
              inDatabaseStrategies.get(propertyIndex);

          if (subStrategy.getGenerationTiming() == GenerationTiming.ALWAYS) {
            // override the base-line to the more often "ALWAYS"...
            timing = GenerationTiming.ALWAYS;
          }
          if (subStrategy.referenceColumnsInSql()) {
            // override base-line value
            referenceColumns = true;
          }
          if (subStrategy.getReferencedColumnValues() != null) {
            if (subStrategy.getReferencedColumnValues().length != subProperty.getColumnSpan()) {
              throw new ValueGenerationStrategyException(
                  "Internal error : mismatch between number of collected 'referenced column values'"
                      + " and number of columns for composite attribute : "
                      + mappingProperty.getName()
                      + '.'
                      + subProperty.getName());
            }
            System.arraycopy(
                subStrategy.getReferencedColumnValues(),
                0,
                columnValues,
                columnIndex,
                subProperty.getColumnSpan());
          }
        }

        // then use the aggregated values to build the InDatabaseValueGenerationStrategy
        return new GenerationStrategyPair(
            new InDatabaseValueGenerationStrategyImpl(timing, referenceColumns, columnValues));
      } else {
        return NO_GEN_PAIR;
      }
    }