Search in sources :

Example 1 with ValueGeneration

use of org.hibernate.tuple.ValueGeneration in project hibernate-orm by hibernate.

the class AbstractEntityPersister method isValueGenerationRequired.

private boolean isValueGenerationRequired(NonIdentifierAttribute attribute, GenerationTiming matchTiming) {
    if (attribute.getType() instanceof ComponentType) {
        final ComponentType type = (ComponentType) attribute.getType();
        final ValueGeneration[] propertyValueGenerationStrategies = type.getPropertyValueGenerationStrategies();
        for (int i = 0; i < propertyValueGenerationStrategies.length; i++) {
            if (isReadRequired(propertyValueGenerationStrategies[i], matchTiming)) {
                return true;
            }
        }
        return false;
    } else {
        return isReadRequired(attribute.getValueGenerationStrategy(), matchTiming);
    }
}
Also used : ComponentType(org.hibernate.type.ComponentType) ValueGeneration(org.hibernate.tuple.ValueGeneration)

Example 2 with ValueGeneration

use of org.hibernate.tuple.ValueGeneration in project hibernate-orm by hibernate.

the class PropertyBinder method determineValueGenerationStrategy.

private ValueGeneration determineValueGenerationStrategy(XProperty property) {
    ValueGeneration valueGeneration = getValueGenerationFromAnnotations(property);
    if (valueGeneration == null) {
        return NoValueGeneration.INSTANCE;
    }
    final GenerationTiming when = valueGeneration.getGenerationTiming();
    if (valueGeneration.getValueGenerator() == null) {
        insertable = false;
        if (when == GenerationTiming.ALWAYS) {
            updatable = false;
        }
    }
    return valueGeneration;
}
Also used : AnnotationValueGeneration(org.hibernate.tuple.AnnotationValueGeneration) ValueGeneration(org.hibernate.tuple.ValueGeneration) GenerationTiming(org.hibernate.tuple.GenerationTiming)

Aggregations

ValueGeneration (org.hibernate.tuple.ValueGeneration)2 AnnotationValueGeneration (org.hibernate.tuple.AnnotationValueGeneration)1 GenerationTiming (org.hibernate.tuple.GenerationTiming)1 ComponentType (org.hibernate.type.ComponentType)1