@Override @SuppressWarnings({ "unchecked" }) public Iterator<Property> getPropertyIterator() { return component.getPropertyIterator(); }
@Override public int getColumnSpan() { int n=0; Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property p = (Property) iter.next(); n+= p.getColumnSpan(); } return n; }
public Property getProperty(String propertyName) throws MappingException { Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property prop = (Property) iter.next(); if ( prop.getName().equals(propertyName) ) { return prop; } } throw new MappingException("component property not found: " + propertyName); }
private static void interpretPartialCompositeValueGeneration( SessionFactoryImplementor sessionFactory, Component composite, CompositeGenerationStrategyPairBuilder builder) { Iterator subProperties = composite.getPropertyIterator(); while ( subProperties.hasNext() ) { final Property subProperty = (Property) subProperties.next(); builder.addPair( buildGenerationStrategyPair( sessionFactory, subProperty ) ); } }
@SuppressWarnings("unchecked") private void createPropertiesGroupMapping(Property property) { final Component component = (Component) property.getValue(); final Iterator<Property> componentProperties = component.getPropertyIterator(); while ( componentProperties.hasNext() ) { final Property componentProperty = componentProperties.next(); propertiesGroupMapping.put( componentProperty.getName(), property.getName() ); } }
@Override @SuppressWarnings("unchecked") public Iterator<Selectable> getColumnIterator() { Iterator[] iters = new Iterator[ getPropertySpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { iters[i++] = ( (Property) iter.next() ).getColumnIterator(); } return new JoinedIterator( iters ); }
@Override public boolean[] getColumnUpdateability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); boolean[] chunk = prop.getValue().getColumnUpdateability(); if ( prop.isUpdateable() ) { System.arraycopy(chunk, 0, result, i, chunk.length); } i+=chunk.length; } return result; }
private void mapPropertyToIndex(Property prop, int i) { propertyIndexes.put( prop.getName(), i ); if ( prop.getValue() instanceof Component ) { Iterator iter = ( (Component) prop.getValue() ).getPropertyIterator(); while ( iter.hasNext() ) { Property subprop = (Property) iter.next(); propertyIndexes.put( prop.getName() + '.' + subprop.getName(), i ); } } }
@Override public boolean[] getColumnInsertability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); boolean[] chunk = prop.getValue().getColumnInsertability(); if ( prop.isInsertable() ) { System.arraycopy(chunk, 0, result, i, chunk.length); } i+=chunk.length; } return result; }
boolean key, boolean audited) { final Iterator properties = component.getPropertyIterator(); while ( properties.hasNext() ) { final Property property = (Property) properties.next();
@Override public boolean isInPrimaryKey() { if ( entityClassName == null ) return false; final PersistentClass persistentClass = buildingContext.getMetadataCollector().getEntityBinding( entityClassName ); Property property = persistentClass.getIdentifierProperty(); if ( path == null ) { return false; } else if ( property != null) { //try explicit identifier property return path.startsWith( property.getName() + "." ); } else { //try the embedded property //embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor if ( path.startsWith( "id." ) ) { KeyValue valueIdentifier = persistentClass.getIdentifier(); String localPath = path.substring( 3 ); if ( valueIdentifier instanceof Component ) { Iterator it = ( (Component) valueIdentifier ).getPropertyIterator(); while ( it.hasNext() ) { Property idProperty = (Property) it.next(); if ( localPath.startsWith( idProperty.getName() ) ) return true; } } } } return false; }
@SuppressWarnings({"unchecked"}) private String searchMappedByKey(PersistentClass referencedClass, Collection collectionValue) { final Iterator<Value> assocIdClassProps = referencedClass.getKeyClosureIterator(); while ( assocIdClassProps.hasNext() ) { final Value value = assocIdClassProps.next(); // make sure its a 'Component' because IdClass is registered as this type. if ( value instanceof Component ) { final Component component = (Component) value; final Iterator<Property> componentPropertyIterator = component.getPropertyIterator(); while ( componentPropertyIterator.hasNext() ) { final Property property = componentPropertyIterator.next(); final Iterator<Selectable> propertySelectables = property.getValue().getColumnIterator(); final Iterator<Selectable> collectionSelectables = collectionValue.getKey().getColumnIterator(); if ( Tools.iteratorsContentEqual( propertySelectables, collectionSelectables ) ) { return property.getName(); } } } } return null; }
protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties) throws MappingException { while ( properties.hasNext() ) { Property prop = (Property) properties.next(); if ( prop.getValue() instanceof Component ) { //TODO: remove use of instanceof! Component component = (Component) prop.getValue(); checkPropertyColumnDuplication( distinctColumns, component.getPropertyIterator() ); } else { if ( prop.isUpdateable() || prop.isInsertable() ) { checkColumnDuplication( distinctColumns, prop.getColumnIterator() ); } } } }
protected AbstractComponentTuplizer(Component component) { setComponentClass( component ); propertySpan = component.getPropertySpan(); getters = new Getter[propertySpan]; setters = new Setter[propertySpan]; Iterator iter = component.getPropertyIterator(); boolean foundCustomAccessor=false; int i = 0; while ( iter.hasNext() ) { Property prop = ( Property ) iter.next(); getters[i] = buildGetter( component, prop ); setters[i] = buildSetter( component, prop ); if ( !prop.isBasicPropertyAccessor() ) { foundCustomAccessor = true; } i++; } hasCustomAccessors = foundCustomAccessor; instantiator = buildInstantiator( component ); }
@SuppressWarnings("unchecked") private String searchMappedBy(Iterator<Property> properties, Table collectionTable) { while ( properties.hasNext() ) { final Property property = properties.next(); if ( property.getValue() instanceof Collection ) { // The equality is intentional. We want to find a collection property with the same collection table. //noinspection ObjectEquality if ( ( (Collection) property.getValue() ).getCollectionTable() == collectionTable ) { return property.getName(); } } else if ( property.getValue() instanceof Component ) { // HHH-12240 // Should we find an embeddable, we should traverse it as well to see if the collection table // happens to be an attribute inside the embeddable rather than directly on the entity. final Component component = (Component) property.getValue(); final String mappedBy = searchMappedBy( component.getPropertyIterator(), collectionTable ); if ( mappedBy != null ) { return property.getName() + "_" + mappedBy; } } } return null; }
private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) { while ( propertyIterator.hasNext() ) { Property prop = (Property) propertyIterator.next(); String propname = path == null ? prop.getName() : path + "." + prop.getName(); if ( prop.isComposite() ) { Component component = (Component) prop.getValue(); Iterator compProps = component.getPropertyIterator(); internalInitSubclassPropertyAliasesMap( propname, compProps ); } else { String[] aliases = new String[prop.getColumnSpan()]; String[] cols = new String[prop.getColumnSpan()]; Iterator colIter = prop.getColumnIterator(); int l = 0; while ( colIter.hasNext() ) { Selectable thing = (Selectable) colIter.next(); aliases[l] = thing.getAlias( getFactory().getDialect(), prop.getValue().getTable() ); cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas? l++; } subclassPropertyAliases.put( propname, aliases ); subclassPropertyColumnNames.put( propname, cols ); } } }
private void generateSecondPass(String entityName, Component component) { Iterator properties = component.getPropertyIterator(); while ( properties.hasNext() ) { final Property property = (Property) properties.next(); if ( property.getValue() instanceof ToOne ) { final PropertyAuditingData propertyData = getIdPersistentPropertyAuditingData( property ); final String referencedEntityName = ( (ToOne) property.getValue() ).getReferencedEntityName(); final String prefix = mainGenerator.getVerEntCfg().getOriginalIdPropName() + "." + propertyData.getName(); final IdMapper relMapper; if ( mainGenerator.getEntitiesConfigurations().containsKey( referencedEntityName ) ) { relMapper = mainGenerator.getEntitiesConfigurations().get( referencedEntityName ).getIdMapper(); } else if ( mainGenerator.getNotAuditedEntitiesConfigurations().containsKey( referencedEntityName ) ) { relMapper = mainGenerator.getNotAuditedEntitiesConfigurations().get( referencedEntityName ).getIdMapper(); } else { throw new MappingException( "Unable to locate entity configuration for [" + referencedEntityName + "]" ); } final IdMapper prefixedMapper = relMapper.prefixMappedProperties( prefix + "." ); mainGenerator.getEntitiesConfigurations().get( entityName ).addToOneRelation( prefix, referencedEntityName, prefixedMapper, true, false ); } } }
private ComponentMetamodel(Component component, ComponentTuplizerFactory componentTuplizerFactory){ 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 String tuplizerClassName = component.getTuplizerImplClassName( entityMode ); this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer( entityMode, component ) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component ); final ConfigurationService cs = component.getMetadata().getMetadataBuildingOptions().getServiceRegistry() .getService(ConfigurationService.class); this.createEmptyCompositesEnabled = ConfigurationHelper.getBoolean( Environment.CREATE_EMPTY_COMPOSITES_ENABLED, cs.getSettings(), false ); }
private <X> void applyIdMetadata(MappedSuperclass mappingType, MappedSuperclassTypeDescriptor<X> jpaMappingType) { if ( mappingType.hasIdentifierProperty() ) { final Property declaredIdentifierProperty = mappingType.getDeclaredIdentifierProperty(); if ( declaredIdentifierProperty != null ) { jpaMappingType.getInFlightAccess().applyIdAttribute( attributeFactory.buildIdAttribute( jpaMappingType, declaredIdentifierProperty ) ); } } //a MappedSuperclass can have no identifier if the id is set below in the hierarchy else if ( mappingType.getIdentifierMapper() != null ) { @SuppressWarnings("unchecked") Iterator<Property> propertyIterator = mappingType.getIdentifierMapper().getPropertyIterator(); Set<SingularPersistentAttribute<? super X, ?>> attributes = buildIdClassAttributes( jpaMappingType, propertyIterator ); jpaMappingType.getInFlightAccess().applyIdClassAttributes( attributes ); } }
Iterator<Property> propertyIterator = referencedValue.getPropertyIterator(); while(propertyIterator.hasNext()) { Property referencedComponentProperty = propertyIterator.next();