Java Code Examples for org.hibernate.mapping.Property#isLazy()
The following examples show how to use
org.hibernate.mapping.Property#isLazy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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 ); }
Example 2
Source File: PropertyFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * @deprecated See mainly {@link #buildEntityBasedAttribute} */ @Deprecated public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) { final Type type = property.getValue().getType(); // we need to dirty check collections, since they can cause an owner // version number increment // we need to dirty check many-to-ones with not-found="ignore" in order // to update the cache (not the database), since in this case a null // entity reference can lose information boolean alwaysDirtyCheck = type.isAssociationType() && ( (AssociationType) type ).isAlwaysDirtyChecked(); return new StandardProperty( property.getName(), type, lazyAvailable && property.isLazy(), property.isInsertable(), property.isUpdateable(), property.getValueGenerationStrategy(), property.isOptional(), alwaysDirtyCheck || property.isUpdateable(), property.isOptimisticLocked(), property.getCascadeStyle(), property.getValue().getFetchMode() ); }
Example 3
Source File: LazyAttributesMetadata.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build a LazyFetchGroupMetadata based on the attributes defined for the * PersistentClass * * @param mappedEntity The entity definition * * @return The built LazyFetchGroupMetadata */ public static LazyAttributesMetadata from(PersistentClass mappedEntity) { final Map<String, LazyAttributeDescriptor> lazyAttributeDescriptorMap = new LinkedHashMap<>(); final Map<String, Set<String>> fetchGroupToAttributesMap = new HashMap<>(); int i = -1; int x = 0; final Iterator itr = mappedEntity.getPropertyClosureIterator(); while ( itr.hasNext() ) { i++; final Property property = (Property) itr.next(); if ( property.isLazy() ) { final LazyAttributeDescriptor lazyAttributeDescriptor = LazyAttributeDescriptor.from( property, i, x++ ); lazyAttributeDescriptorMap.put( lazyAttributeDescriptor.getName(), lazyAttributeDescriptor ); final Set<String> attributeSet = fetchGroupToAttributesMap.computeIfAbsent( lazyAttributeDescriptor.getFetchGroupName(), k -> new LinkedHashSet<>() ); attributeSet.add( lazyAttributeDescriptor.getName() ); } } if ( lazyAttributeDescriptorMap.isEmpty() ) { return new LazyAttributesMetadata( mappedEntity.getEntityName() ); } for ( Map.Entry<String, Set<String>> entry : fetchGroupToAttributesMap.entrySet() ) { entry.setValue( Collections.unmodifiableSet( entry.getValue() ) ); } return new LazyAttributesMetadata( mappedEntity.getEntityName(), Collections.unmodifiableMap( lazyAttributeDescriptorMap ), Collections.unmodifiableMap( fetchGroupToAttributesMap ) ); }
Example 4
Source File: PojoEntityTuplizer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public PojoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super( entityMetamodel, mappedEntity ); this.mappedClass = mappedEntity.getMappedClass(); this.proxyInterface = mappedEntity.getProxyInterface(); this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass ); this.validatableImplementor = Validatable.class.isAssignableFrom( mappedClass ); Iterator iter = mappedEntity.getPropertyClosureIterator(); while ( iter.hasNext() ) { Property property = (Property) iter.next(); if ( property.isLazy() ) { lazyPropertyNames.add( property.getName() ); } } String[] getterNames = new String[propertySpan]; String[] setterNames = new String[propertySpan]; Class[] propTypes = new Class[propertySpan]; for ( int i = 0; i < propertySpan; i++ ) { getterNames[i] = getters[i].getMethodName(); setterNames[i] = setters[i].getMethodName(); propTypes[i] = getters[i].getReturnType(); } if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) { optimizer = null; } else { // todo : YUCK!!! optimizer = Environment.getBytecodeProvider().getReflectionOptimizer( mappedClass, getterNames, setterNames, propTypes ); // optimizer = getFactory().getSettings().getBytecodeProvider().getReflectionOptimizer( // mappedClass, getterNames, setterNames, propTypes // ); } }
Example 5
Source File: PropertyFactory.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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(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( property.getName(), property.getNodeName(), property.getValue().getType(), lazy, property.isInsertable(), property.isUpdateable(), property.getGeneration() == PropertyGeneration.INSERT || property.getGeneration() == PropertyGeneration.ALWAYS, property.getGeneration() == PropertyGeneration.ALWAYS, property.isOptional(), property.isUpdateable() && !lazy, property.isOptimisticLocked(), property.getCascadeStyle(), unsavedValue ); }
Example 6
Source File: PropertyFactory.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Generate a "standard" (i.e., non-identifier and non-version) based on the given * mapped property. * * @param property The mapped property. * @param lazyAvailable Is property lazy loading currently available. * @return The appropriate StandardProperty definition. */ public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) { final Type type = property.getValue().getType(); // we need to dirty check collections, since they can cause an owner // version number increment // we need to dirty check many-to-ones with not-found="ignore" in order // to update the cache (not the database), since in this case a null // entity reference can lose information boolean alwaysDirtyCheck = type.isAssociationType() && ( (AssociationType) type ).isAlwaysDirtyChecked(); return new StandardProperty( property.getName(), property.getNodeName(), type, lazyAvailable && property.isLazy(), property.isInsertable(), property.isUpdateable(), property.getGeneration() == PropertyGeneration.INSERT || property.getGeneration() == PropertyGeneration.ALWAYS, property.getGeneration() == PropertyGeneration.ALWAYS, property.isOptional(), alwaysDirtyCheck || property.isUpdateable(), property.isOptimisticLocked(), property.getCascadeStyle(), property.getValue().getFetchMode() ); }