Search in sources :

Example 1 with VersionValue

use of org.hibernate.engine.spi.VersionValue in project hibernate-orm by hibernate.

the class PropertyFactory method buildVersionProperty.

/**
	 * Generates a VersionProperty representation for an entity mapping given its
	 * version mapping Property.
	 *
	 * @param property The version mapping Property.
	 * @param lazyAvailable Is property lazy loading currently available.
	 *
	 * @return The appropriate VersionProperty definition.
	 */
public static VersionProperty buildVersionProperty(EntityPersister persister, SessionFactoryImplementor sessionFactory, int attributeNumber, Property property, boolean lazyAvailable) {
    String mappedUnsavedValue = ((KeyValue) property.getValue()).getNullValue();
    VersionValue unsavedValue = UnsavedValueFactory.getUnsavedVersionValue(mappedUnsavedValue, getGetter(property), (VersionType) property.getType(), getConstructor(property.getPersistentClass()));
    boolean lazy = lazyAvailable && property.isLazy();
    return new VersionProperty(persister, sessionFactory, attributeNumber, property.getName(), property.getValue().getType(), new BaselineAttributeInformation.Builder().setLazy(lazy).setInsertable(property.isInsertable()).setUpdateable(property.isUpdateable()).setValueGenerationStrategy(property.getValueGenerationStrategy()).setNullable(property.isOptional()).setDirtyCheckable(property.isUpdateable() && !lazy).setVersionable(property.isOptimisticLocked()).setCascadeStyle(property.getCascadeStyle()).createInformation(), unsavedValue);
}
Also used : VersionValue(org.hibernate.engine.spi.VersionValue) KeyValue(org.hibernate.mapping.KeyValue) VersionProperty(org.hibernate.tuple.entity.VersionProperty)

Aggregations

VersionValue (org.hibernate.engine.spi.VersionValue)1 KeyValue (org.hibernate.mapping.KeyValue)1 VersionProperty (org.hibernate.tuple.entity.VersionProperty)1