Refine search
AtomicInteger index, Property referencedProperty ) { Property property = new Property(); property.setName( referencedProperty.getName() ); property.setPersistentClass( component.getOwner() ); property.setPropertyAccessorName( referencedProperty.getPropertyAccessorName() ); Component value = new Component( buildingContext, component.getOwner() ); property.setValue( value ); final Component referencedValue = (Component) referencedProperty.getValue(); value.setTypeName( referencedValue.getTypeName() ); value.setTypeParameters( referencedValue.getTypeParameters() ); value.setComponentClassName( referencedValue.getComponentClassName() ); Iterator<Property> propertyIterator = referencedValue.getPropertyIterator(); while(propertyIterator.hasNext()) { Property referencedComponentProperty = propertyIterator.next(); if ( referencedComponentProperty.isComposite() ) { Property componentProperty = createComponentProperty( referencedValue.getOwner(), isExplicitReference, columnByReferencedName, index, referencedComponentProperty ); value.addProperty( componentProperty ); Property componentProperty = createSimpleProperty( referencedValue.getOwner(), isExplicitReference, columnByReferencedName, index, referencedComponentProperty ); value.addProperty( componentProperty );
Property idProperty = associatedClass.getIdentifierProperty(); String idName = idProperty != null ? idProperty.getName() : null; try { if ( propertyName == null String element = (String) st.nextElement(); if ( property == null ) { property = associatedClass.getProperty( element ); if ( !property.isComposite() ) { return null; property = ( (Component) property.getValue() ).getProperty( element ); try { if ( associatedClass.getIdentifierMapper() == null ) { return null; String element = (String) st.nextElement(); if ( property == null ) { property = associatedClass.getIdentifierMapper().getProperty( element ); return null; property = ( (Component) property.getValue() ).getProperty( element );
public static Component createComponent( PropertyHolder propertyHolder, PropertyData inferredData, boolean isComponentEmbedded, boolean isIdentifierMapper, MetadataBuildingContext context) { Component comp = new Component( context, propertyHolder.getPersistentClass() ); comp.setEmbedded( isComponentEmbedded ); //yuk comp.setTable( propertyHolder.getTable() ); //FIXME shouldn't identifier mapper use getClassOrElementName? Need to be checked. if ( isIdentifierMapper || ( isComponentEmbedded && inferredData.getPropertyName() == null ) ) { comp.setComponentClassName( comp.getOwner().getClassName() ); } else { comp.setComponentClassName( inferredData.getClassOrElementName() ); } return comp; }
@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 ); }
referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator(); Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName ); referencedEntityColumns = referencedProperty.getColumnIterator(); .append( associatedClass.getTable().getName() ) Iterator properties = component.getPropertyIterator(); Component indexComponent = new Component( collection ); indexComponent.setComponentClassName( component.getComponentClassName() ); indexComponent.setNodeName( "index" ); while ( properties.hasNext() ) { Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setGeneration( current.getGeneration() ); newProperty.setInsertable( false ); associatedClass ) ); indexComponent.addProperty( newProperty ); targetValue = new SimpleValue( collection.getCollectionTable() ); targetValue.setTypeName( sourceValue.getTypeName() ); targetValue.setTypeParameters( sourceValue.getTypeParameters() );
referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator(); Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName ); referencedEntityColumns = referencedProperty.getColumnIterator(); associatedClass.getTable().getName(), element.getColumnIterator(), referencedEntityColumns Iterator properties = component.getPropertyIterator(); Component indexComponent = new Component( getBuildingContext(), collection ); indexComponent.setComponentClassName( component.getComponentClassName() ); while ( properties.hasNext() ) { Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); newProperty.setValueGenerationStrategy( current.getValueGenerationStrategy() ); newProperty.setInsertable( false ); indexComponent.addProperty( newProperty ); targetValue = new SimpleValue( getBuildingContext(), collection.getCollectionTable() ); targetValue.copyTypeFrom( sourceValue ); Iterator columns = sourceValue.getColumnIterator(); Random random = new Random(); while ( columns.hasNext() ) {
Component referencedComponent = (Component) referencedPersistentClass.getIdentifier(); Iterator<Property> properties = referencedComponent.getPropertyIterator(); if ( referencedProperty.isComposite() ) { throw new AssertionFailure( "Unexpected nested component on the referenced entity when mapping a @MapsId: " + referencedEntityName); Property property = new Property(); property.setName( referencedProperty.getName() ); property.setNodeName( referencedProperty.getNodeName() ); property.setPersistentClass( component.getOwner() ); property.setPropertyAccessorName( referencedProperty.getPropertyAccessorName() ); SimpleValue value = new SimpleValue( component.getTable() ); property.setValue( value ); final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue(); value.setTypeName( referencedValue.getTypeName() ); value.setTypeParameters( referencedValue.getTypeParameters() ); final Iterator<Column> columns = referencedValue.getColumnIterator(); if ( isExplicitReference ) { final String columnName = column.getName(); logicalColumnName = mappings.getLogicalColumnName( columnName, referencedPersistentClass.getTable() ); component.addProperty( property );
AtomicInteger index, Property referencedProperty ) { Property property = new Property(); property.setName( referencedProperty.getName() ); property.setPersistentClass( component.getOwner() ); property.setPropertyAccessorName( referencedProperty.getPropertyAccessorName() ); SimpleValue value = new SimpleValue( buildingContext, component.getTable() ); property.setValue( value ); final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue(); value.setTypeName( referencedValue.getTypeName() ); value.setTypeParameters( referencedValue.getTypeParameters() ); final Iterator<Selectable> columns = referencedValue.getColumnIterator(); final String columnName = column.getName(); logicalColumnName = buildingContext.getMetadataCollector().getLogicalColumnName( referencedPersistentClass.getTable(), columnName );
String syntheticPropertyName = DatabaseLogic.getUniquePropertyName(oneMDTable, propertyNameBuffer.toString()); PersistentClass referencedClass = mappings.getClass(oneMDQualifiedTableName); Component embeddedComp = new Component(mappings, referencedClass); embeddedComp.setEmbedded(true); embeddedComp.setNodeName(syntheticPropertyName); embeddedComp.setComponentClassName(embeddedComp.getOwner().getClassName()); for(Reference ref : relationship.getReferences()) { String propertyName = ref.getActualToColumn().getActualPropertyName(); Property property; if(referencedClass.getIdentifier() instanceof Component) { property = ((Component) referencedClass.getIdentifier()).getProperty(propertyName); } else { property = referencedClass.getProperty(propertyName); clone.setInsertable(false); clone.setUpdateable(false); clone.setNaturalIdentifier(false); clone.setValueGenerationStrategy(property.getValueGenerationStrategy()); embeddedComp.addProperty(clone);
propertyNameBuffer.append( associatedClass.getEntityName().replace( '.', '_' ) ); propertyNameBuffer.append( "_" ).append( columns[0].getPropertyName().replace( '.', '_' ) ); String syntheticPropertyName = propertyNameBuffer.toString(); new Component( context, (PersistentClass) columnOwner ) : new Component( context, (Join) columnOwner ); embeddedComp.setEmbedded( true ); embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassName() ); for (Property property : properties) { Property clone = BinderHelper.shallowCopy( property ); clone.setInsertable( false ); clone.setUpdateable( false ); clone.setNaturalIdentifier( false ); clone.setValueGenerationStrategy( property.getValueGenerationStrategy() ); embeddedComp.addProperty( clone ); synthProp.setValue( embeddedComp ); synthProp.setPropertyAccessorName( "embedded" ); ownerEntity.addProperty( synthProp );
propertyNameBuffer.append( associatedClass.getEntityName().replace( '.', '_' ) ); propertyNameBuffer.append( "_" ).append( columns[0].getPropertyName() ); String syntheticPropertyName = propertyNameBuffer.toString(); new Component( (PersistentClass) columnOwner ) : new Component( (Join) columnOwner ); embeddedComp.setEmbedded( true ); embeddedComp.setNodeName( syntheticPropertyName ); embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassName() ); for (Property property : properties) { Property clone = BinderHelper.shallowCopy( property ); clone.setInsertable( false ); clone.setUpdateable( false ); clone.setNaturalIdentifier( false ); clone.setGeneration( property.getGeneration() ); embeddedComp.addProperty( clone ); synthProp.setValue( embeddedComp ); synthProp.setPropertyAccessorName( "embedded" ); ownerEntity.addProperty( synthProp );
final String element = (String) st.nextElement(); if ( property == null ) { Property identifierProperty = getIdentifierProperty(); if ( identifierProperty != null && identifierProperty.getName().equals( element ) ) { else if ( identifierProperty == null && getIdentifierMapper() != null ) { identifierProperty = getProperty( element, getIdentifierMapper().getPropertyIterator() ); if ( identifierProperty != null ) { property = ( (Component) property.getValue() ).getProperty( element );
componentBinding.setMetaAttributes( embeddableSource.getToolingHintContext().getMetaAttributeMap() ); componentBinding.setRoleName( role ); componentBinding.setEmbedded( isVirtual ); componentBinding.setDynamic( true ); if ( componentBinding.getOwner().hasPojoRepresentation() ) { log.debugf( "Binding virtual component [%s] to owner class [%s]", role, componentBinding.getOwner().getClassName() ); componentBinding.setComponentClassName( componentBinding.getOwner().getClassName() ); componentBinding.setDynamic( true ); if ( StringHelper.isNotEmpty( explicitComponentClassName ) ) { log.debugf( "Binding component [%s] to explicitly specified class", role, explicitComponentClassName ); componentBinding.setComponentClassName( explicitComponentClassName ); else if ( componentBinding.getOwner().hasPojoRepresentation() ) { log.tracef( "Attempting to determine component class by reflection %s", role ); final Class reflectedComponentClass; componentBinding.setComponentClassName( reflectedComponentClass.getName() ); componentBinding.setDynamic( true ); componentBinding.setParentProperty( embeddableSource.getParentReferenceAttributeName() ); final Iterator itr = componentBinding.getColumnIterator();
PersistentClass entityDescriptor) { final EntityTableXref entityTableXref = mappingDocument.getMetadataCollector().getEntityTableXref( entityDescriptor.getEntityName() ); if ( entityTableXref == null ) { Locale.ENGLISH, "Unable to locate EntityTableXref for entity [%s] : %s", entityDescriptor.getEntityName(), mappingDocument.getOrigin() entityTableXref ); entityDescriptor.addJoin( secondaryTableJoin ); attribute.setOptional( secondaryTableJoin.isOptional() ); mappingDocument, (SingularAttributeSourceEmbedded) attributeSource, new Component( mappingDocument, table, entityDescriptor ), entityDescriptor.getClassName() ); attribute.setOptional( secondaryTableJoin.isOptional() ); attribute.setOptional( secondaryTableJoin.isOptional() );
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() ); } } } }
if ( propComponent.isDynamic() ) { componentClass = ReflectionTools.loadClass( Map.class.getCanonicalName(), propComponent.getComponentClassName(), mainGenerator.getClassLoaderService() ); final Iterator<Property> properties = (Iterator<Property>) propComponent.getPropertyIterator(); while ( properties.hasNext() ) { final Property property = properties.next(); componentAuditingData.getPropertyAuditingData( property.getName() ); parent, property.getValue(), componentMapper, entityName, xmlMappingData, componentPropertyAuditingData, property.isInsertable(), firstPass, false );
component.setEmbedded(true); Class<?> type = property.getType(); String role = qualify(type.getName(), property.getName()); component.setRoleName(role); component.setComponentClassName(type.getName()); Table table = component.getOwner().getTable(); PersistentClass persistentClass = component.getOwner(); String path = property.getName(); Class<?> propertyType = property.getOwner().getJavaClass(); component.setParentProperty(currentGrailsProp.getName()); continue;
@Test public void testMetaInheritance() { PersistentClass cm = metadata.getEntityBinding( "org.hibernate.test.legacy.Wicked" ); Map m = cm.getMetaAttributes(); assertNotNull(m); assertNotNull(cm.getMetaAttribute("global")); assertNull(cm.getMetaAttribute("globalnoinherit")); MetaAttribute metaAttribute = cm.getMetaAttribute("implements"); Property element = (Property) propertyIterator.next(); System.out.println(element); Map ma = element.getMetaAttributes(); assertNotNull(ma); assertNotNull(element.getMetaAttribute("global")); MetaAttribute metaAttribute2 = element.getMetaAttribute("implements"); assertNotNull(metaAttribute2); assertNull(element.getMetaAttribute("globalnoinherit")); assertEquals(compimplements.getValue(), "AnotherInterface"); Property xp = ((Component)element.getValue()).getProperty( "x" ); MetaAttribute propximplements = xp.getMetaAttribute( "implements" ); assertNotNull(propximplements);
SimpleValue sv = (SimpleValue) classMapping.getIdentifier(); Assert.assertEquals("CustomOID", ((Component)sv).getComponentClassName()); Assert.assertEquals(2,classMapping.getIdentifierProperty().getColumnSpan()); Property identifierProperty = classMapping.getIdentifierProperty(); Assert.assertEquals("customOrderId", identifierProperty.getName()); sv = (SimpleValue) classMapping.getIdentifier(); Assert.assertEquals("sequence", sv.getIdentifierGeneratorStrategy()); // will fail if default schema is not set since then there is no match in the override binder Assert.assertNotNull(sv.getIdentifierGeneratorProperties()); Assert.assertEquals("seq_table", sv.getIdentifierGeneratorProperties().getProperty("table"));