Search in sources :

Example 6 with KeyValue

use of org.hibernate.mapping.KeyValue 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

KeyValue (org.hibernate.mapping.KeyValue)6 Iterator (java.util.Iterator)3 JoinColumn (javax.persistence.JoinColumn)2 Ejb3JoinColumn (org.hibernate.cfg.Ejb3JoinColumn)2 Property (org.hibernate.mapping.Property)2 ArrayList (java.util.ArrayList)1 CollectionTable (javax.persistence.CollectionTable)1 ConstraintMode (javax.persistence.ConstraintMode)1 ElementCollection (javax.persistence.ElementCollection)1 JoinTable (javax.persistence.JoinTable)1 MapKeyColumn (javax.persistence.MapKeyColumn)1 Session (org.hibernate.Session)1 FilterJoinTable (org.hibernate.annotations.FilterJoinTable)1 ForeignKey (org.hibernate.annotations.ForeignKey)1 LazyCollection (org.hibernate.annotations.LazyCollection)1 WhereJoinTable (org.hibernate.annotations.WhereJoinTable)1 XProperty (org.hibernate.annotations.common.reflection.XProperty)1 Metadata (org.hibernate.boot.Metadata)1 MetadataBuilder (org.hibernate.boot.MetadataBuilder)1 MetadataSources (org.hibernate.boot.MetadataSources)1