public ComponentMetamodel(Component component) { // this.sessionFactory = sessionFactory; this.role = component.getRoleName(); this.isKey = component.isKey(); propertySpan = component.getPropertySpan(); properties = new StandardProperty[propertySpan]; Iterator itr = component.getPropertyIterator(); int i = 0; while ( itr.hasNext() ) { Property property = ( Property ) itr.next(); properties[i] = PropertyFactory.buildStandardProperty( property, false ); propertyIndexes.put( property.getName(), i ); i++; } entityMode = component.hasPojoRepresentation() ? EntityMode.POJO : EntityMode.MAP; // todo : move this to SF per HHH-3517; also see HHH-1907 and ComponentMetamodel final ComponentTuplizerFactory componentTuplizerFactory = new ComponentTuplizerFactory(); final String tuplizerClassName = component.getTuplizerImplClassName( entityMode ); this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer( entityMode, component ) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component ); }
public ComponentType(TypeFactory.TypeScope typeScope, ComponentMetamodel metamodel) { this.typeScope = typeScope; // for now, just "re-flatten" the metamodel since this is temporary stuff anyway (HHH-1907) this.isKey = metamodel.isKey(); this.propertySpan = metamodel.getPropertySpan(); this.propertyNames = new String[ propertySpan ]; this.propertyTypes = new Type[ propertySpan ]; this.propertyNullability = new boolean[ propertySpan ]; this.cascade = new CascadeStyle[ propertySpan ]; this.joinedFetch = new FetchMode[ propertySpan ]; for ( int i = 0; i < propertySpan; i++ ) { StandardProperty prop = metamodel.getProperty( i ); this.propertyNames[i] = prop.getName(); this.propertyTypes[i] = prop.getType(); this.propertyNullability[i] = prop.isNullable(); this.cascade[i] = prop.getCascadeStyle(); this.joinedFetch[i] = prop.getFetchMode(); if (!prop.isNullable()) { hasNotNullProperty = true; } } this.entityMode = metamodel.getEntityMode(); this.componentTuplizer = metamodel.getComponentTuplizer(); }
public Object[] getPropertyValues(Object entity) throws HibernateException { boolean getAll = shouldGetAllProperties( entity ); final int span = entityMetamodel.getPropertySpan(); final Object[] result = new Object[span]; for ( int j = 0; j < span; j++ ) { StandardProperty property = entityMetamodel.getProperties()[j]; if ( getAll || !property.isLazy() ) { result[j] = getters[j].get( entity ); } else { result[j] = LazyPropertyInitializer.UNFETCHED_PROPERTY; } } return result; }
public ComponentMetamodel(Component component) { // this.sessionFactory = sessionFactory; this.role = component.getRoleName(); this.isKey = component.isKey(); propertySpan = component.getPropertySpan(); properties = new StandardProperty[propertySpan]; Iterator itr = component.getPropertyIterator(); int i = 0; while ( itr.hasNext() ) { Property property = ( Property ) itr.next(); properties[i] = PropertyFactory.buildStandardProperty( property, false ); propertyIndexes.put( property.getName(), new Integer( i ) ); i++; } tuplizerMapping = new ComponentEntityModeToTuplizerMapping( component ); }
public ComponentType(ComponentMetamodel metamodel) { // for now, just "re-flatten" the metamodel since this is temporary stuff anyway (HHH-1907) this.isKey = metamodel.isKey(); this.propertySpan = metamodel.getPropertySpan(); this.propertyNames = new String[ propertySpan ]; this.propertyTypes = new Type[ propertySpan ]; this.propertyNullability = new boolean[ propertySpan ]; this.cascade = new CascadeStyle[ propertySpan ]; this.joinedFetch = new FetchMode[ propertySpan ]; for ( int i = 0; i < propertySpan; i++ ) { StandardProperty prop = metamodel.getProperty( i ); this.propertyNames[i] = prop.getName(); this.propertyTypes[i] = prop.getType(); this.propertyNullability[i] = prop.isNullable(); this.cascade[i] = prop.getCascadeStyle(); this.joinedFetch[i] = prop.getFetchMode(); } this.tuplizerMapping = metamodel.getTuplizerMapping(); }
private ValueInclusion determineInsertValueGenerationType(Property mappingProperty, StandardProperty runtimeProperty) { if ( runtimeProperty.isInsertGenerated() ) { return ValueInclusion.FULL; } else if ( mappingProperty.getValue() instanceof Component ) { if ( hasPartialInsertComponentGeneration( ( Component ) mappingProperty.getValue() ) ) { return ValueInclusion.PARTIAL; } } return ValueInclusion.NONE; }
private ValueInclusion determineUpdateValueGenerationType(Property mappingProperty, StandardProperty runtimeProperty) { if ( runtimeProperty.isUpdateGenerated() ) { return ValueInclusion.FULL; } else if ( mappingProperty.getValue() instanceof Component ) { if ( hasPartialUpdateComponentGeneration( ( Component ) mappingProperty.getValue() ) ) { return ValueInclusion.PARTIAL; } } return ValueInclusion.NONE; }
/** * Determine if any of the given field values are dirty, returning an array containing * indices of the dirty fields. * <p/> * If it is determined that no fields are dirty, null is returned. * * @param properties The property definitions * @param currentState The current state of the entity * @param previousState The baseline state of the entity * @param includeColumns Columns to be included in the dirty checking, per property * @param anyUninitializedProperties Does the entity currently hold any uninitialized property values? * @param session The session from which the dirty check request originated. * @return Array containing indices of the dirty properties, or null if no properties considered dirty. */ public static int[] findDirty( final StandardProperty[] properties, final Object[] currentState, final Object[] previousState, final boolean[][] includeColumns, final boolean anyUninitializedProperties, final SessionImplementor session) { int[] results = null; int count = 0; int span = properties.length; for ( int i = 0; i < span; i++ ) { final boolean dirty = currentState[i] != LazyPropertyInitializer.UNFETCHED_PROPERTY && properties[i].isDirtyCheckable( anyUninitializedProperties ) && properties[i].getType().isDirty( previousState[i], currentState[i], includeColumns[i], session ); if ( dirty ) { if ( results == null ) { results = new int[span]; } results[count++] = i; } } if ( count == 0 ) { return null; } else { int[] trimmed = new int[count]; System.arraycopy( results, 0, trimmed, 0, count ); return trimmed; } }
/** * Determine if any of the given field values are modified, returning an array containing * indices of the modified fields. * <p/> * If it is determined that no fields are dirty, null is returned. * * @param properties The property definitions * @param currentState The current state of the entity * @param previousState The baseline state of the entity * @param includeColumns Columns to be included in the mod checking, per property * @param anyUninitializedProperties Does the entity currently hold any uninitialized property values? * @param session The session from which the dirty check request originated. * @return Array containing indices of the modified properties, or null if no properties considered modified. */ public static int[] findModified( final StandardProperty[] properties, final Object[] currentState, final Object[] previousState, final boolean[][] includeColumns, final boolean anyUninitializedProperties, final SessionImplementor session) { int[] results = null; int count = 0; int span = properties.length; for ( int i = 0; i < span; i++ ) { final boolean modified = currentState[i]!=LazyPropertyInitializer.UNFETCHED_PROPERTY && properties[i].isDirtyCheckable(anyUninitializedProperties) && properties[i].getType().isModified( previousState[i], currentState[i], includeColumns[i], session ); if ( modified ) { if ( results == null ) { results = new int[span]; } results[count++] = i; } } if ( count == 0 ) { return null; } else { int[] trimmed = new int[count]; System.arraycopy( results, 0, trimmed, 0, count ); return trimmed; } }
public StandardProperty[] getProperties() { return properties; }
public StandardProperty getProperty(int index) { if ( index < 0 || index >= propertySpan ) { throw new IllegalArgumentException( "illegal index value for component property access [request=" + index + ", span=" + propertySpan + "]" ); } return properties[index]; }
public StandardProperty getProperty(String propertyName) { return getProperty( getPropertyIndex( propertyName ) ); }