Refine search
referencedPropertyName = collection.getReferencedPropertyName(); referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator(); Property referencedProperty = associatedClass.getRecursiveProperty( referencedPropertyName ); referencedEntityColumns = referencedProperty.getColumnIterator(); associatedClass.getTable().getName(), element.getColumnIterator(), referencedEntityColumns ); .getQualifiedTableName() .toString(), element.getColumnIterator(), associatedClass.getIdentifier().getColumnIterator() ); while ( properties.hasNext() ) { Property current = (Property) properties.next(); Property newProperty = new Property(); newProperty.setCascade( current.getCascade() ); String formulaString; if ( current instanceof Column ) { formulaString = ( (Column) current ).getQuotedName();
PersistentClass mappedEntity, IdentifierGenerator generator) { String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue(); Type type = mappedEntity.getIdentifier().getType(); Property property = mappedEntity.getIdentifierProperty(); property.getName(), type, mappedEntity.hasEmbeddedIdentifier(),
this.navigableRole = new NavigableRole( persistentClass.getEntityName() ); final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect(); identifierColumnSpan = persistentClass.getIdentifier().getColumnSpan(); rootTableKeyColumnNames = new String[identifierColumnSpan]; rootTableKeyColumnReaders = new String[identifierColumnSpan]; identifierAliases = new String[identifierColumnSpan]; rowIdName = persistentClass.getRootTable().getRowId(); Iterator iter = persistentClass.getIdentifier().getColumnIterator(); int i = 0; while ( iter.hasNext() ) { Column col = (Column) iter.next(); rootTableKeyColumnNames[i] = col.getQuotedName( dialect ); rootTableKeyColumnReaders[i] = col.getReadExpr( dialect ); rootTableKeyColumnReaderTemplates[i] = col.getTemplate( dialect, factory.getSqlFunctionRegistry() versionColumnName = ( (Column) persistentClass.getVersion().getColumnIterator().next() ).getQuotedName( dialect ); thisClassProperties.add( prop ); propertyColumnUpdateable[i] = prop.getValue().getColumnUpdateability();
public OneToManyPersister( Collection collectionBinding, CollectionDataAccess cacheAccessStrategy, PersisterCreationContext creationContext) throws MappingException, CacheException { super( collectionBinding, cacheAccessStrategy, creationContext ); cascadeDeleteEnabled = collectionBinding.getKey().isCascadeDeleteEnabled() && creationContext.getSessionFactory().getDialect().supportsCascadeDelete(); keyIsNullable = collectionBinding.getKey().isNullable(); keyIsUpdateable = collectionBinding.getKey().isUpdateable(); }
public void validate(Mapping mapping) throws MappingException { assert getKey() != null : "Collection key not bound : " + getRole(); assert getElement() != null : "Collection element not bound : " + getRole(); if ( !getKey().isValid( mapping ) ) { throw new MappingException( "collection foreign key mapping has wrong number of columns: " + getRole() + " type: " + getKey().getType().getName() ); } if ( !getElement().isValid( mapping ) ) { throw new MappingException( "collection element mapping has wrong number of columns: " + getRole() + " type: " + getElement().getType().getName() ); } checkColumnDuplication(); }
explicitDiscriminatorColumnName = column.getQuotedName( factory.getDialect() ); discriminatorAlias = column.getAlias( factory.getDialect(), persistentClass.getRootTable() ); discriminatorType = (DiscriminatorType) persistentClass.getDiscriminator().getType(); String[] keyColReaders = new String[idColumnSpan]; String[] keyColReaderTemplates = new String[idColumnSpan]; Iterator cItr = key.getColumnIterator(); for ( int k = 0; k < idColumnSpan; k++ ) { Column column = (Column) cItr.next(); keyCols[k] = column.getQuotedName( factory.getDialect() ); keyColumnReaders.add( keyColReaders ); keyColumnReaderTemplates.add( keyColReaderTemplates ); cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete() ); int joinIdColumnSpan = key.getColumnSpan(); String[] keyColReaderTemplates = new String[joinIdColumnSpan]; Iterator cItr = key.getColumnIterator(); keyColumnReaders.add( keyColReaders ); keyColumnReaderTemplates.add( keyColReaderTemplates ); cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete() ); propTableNumbers.add( tabnum );
public String sqlCreateString(Dialect dialect, Mapping p, String defaultCatalog, String defaultSchema) { StringBuilder buf = new StringBuilder( hasPrimaryKey() ? dialect.getCreateTableString() : dialect.getCreateMultisetTableString() ) .append( ' ' ) .append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) ) .append( " (" ); boolean identityColumn = idValue != null && idValue.isIdentityColumn( p.getIdentifierGeneratorFactory(), dialect ); if ( hasPrimaryKey() && identityColumn ) { pkname = ( (Column) getPrimaryKey().getColumnIterator().next() ).getQuotedName( dialect ); Column col = (Column) iter.next(); buf.append( col.getQuotedName( dialect ) ) .append( ' ' ); if ( identityColumn && col.getQuotedName( dialect ).equals( pkname ) ) {
LOG.debugf( "Retrieving property %s.%s", associatedClass.getEntityName(), mappedByProperty ); mappedByColumns = element.getColumnIterator(); mappedByColumns = property.getValue().getColumnIterator(); idColumns = referencedEntity.getKey().getColumnIterator(); idColumns = referencedEntity.getIdentifier().getColumnIterator(); referencedPropertyName = collection.getReferencedPropertyName(); if ( Ejb3JoinColumn.NO_REFERENCE == fkEnum ) { if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) { .getColumnSpan() ); referencedEntity.getIdentifier().getColumnIterator(), columns, value Iterator idColItr = referencedEntity.getKey().getColumnIterator(); org.hibernate.mapping.Column col; );
deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[joinSpan]; customSQLInsert[0] = persistentClass.getCustomSQLInsert(); .getJpaCompliance() .isJpaCacheComplianceEnabled(); cascadeDeleteEnabled[j] = join.getKey().isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete(); : join.getCustomSQLDeleteCheckStyle(); Iterator iter = join.getKey().getColumnIterator(); keyColumnNames[j] = new String[join.getKey().getColumnSpan()]; int i = 0; while ( iter.hasNext() ) { Column col = (Column) iter.next(); keyColumnNames[j][i++] = col.getQuotedName( factory.getDialect() ); subclassTables.add( joinTableName ); Iterator iter = join.getKey().getColumnIterator(); String[] keyCols = new String[join.getKey().getColumnSpan()]; int i = 0; while ( iter.hasNext() ) { Column col = (Column) iter.next(); keyCols[i++] = col.getQuotedName( factory.getDialect() ); discriminatorColumnName = column.getQuotedName( factory.getDialect() );
protected void validateZipCode(Metadata metadata) { final PersistentClass zipCodeBinding = metadata.getEntityBinding( ZipCode.class.getName() ); assertNotNull( zipCodeBinding ); validateZipCodePrimaryTableName( zipCodeBinding.getTable().getQuotedName() ); assertEquals( 1, zipCodeBinding.getIdentifier().getColumnSpan() ); validateZipCodePrimaryKeyColumn( (Column) zipCodeBinding.getIdentifier().getColumnIterator().next() ); final Property codeBinding = zipCodeBinding.getProperty( "code" ); assertNotNull( codeBinding ); assertEquals( 1, codeBinding.getColumnSpan() ); validateZipCodeCodeColumn( (Column) codeBinding.getColumnIterator().next() ); final Property cityBinding = zipCodeBinding.getProperty( "city" ); assertNotNull( cityBinding ); assertEquals( 1, cityBinding.getColumnSpan() ); validateZipCodeCityColumn( (Column) cityBinding.getColumnIterator().next() ); final Property stateBinding = zipCodeBinding.getProperty( "state" ); assertNotNull( stateBinding ); assertEquals( 1, stateBinding.getColumnSpan() ); validateZipCodeStateColumn( (Column) stateBinding.getColumnIterator().next() ); }
String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue(); (VersionType) property.getType(), getConstructor( property.getPersistentClass() ) ); property.getName(), property.getNodeName(), property.getValue().getType(), lazy, property.isInsertable(),
); org.hibernate.mapping.OneToMany oneToMany = new org.hibernate.mapping.OneToMany( buildingContext, collection.getOwner() ); collection.setElement( oneToMany ); oneToMany.setReferencedEntityName( collectionType.getName() ); oneToMany.setIgnoreNotFound( ignoreNotFound ); jpaOrderBy.value(), associatedClass, collection.getRole() ); if ( StringHelper.isNotEmpty( orderByFragment ) ) { LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() ); if ( !collection.isInverse() && !collection.getKey().isNullable() ) { prop.setSelectable( false ); prop.setCollectionRole( collection.getRole() ); prop.setEntityName( collection.getOwner().getEntityName() ); prop.setValue( collection.getKey() ); referenced.addProperty( prop );
); assertEquals ( 1, ownerCollection.getOwner().getKey().getColumnSpan() ); assertEquals( ownerForeignKeyNameExpected, ownerCollection.getKey().getColumnIterator().next().getText() ); final EntityType associatedEntityType = (EntityType) ownerCollection.getElement().getType(); final PersistentClass associatedPersistentClass = metadata().getEntityBinding( associatedEntityType.getAssociatedEntityName() ); assertEquals( 1, associatedPersistentClass.getKey().getColumnSpan() ); if ( inverseCollectionPropertyName != null ) { final org.hibernate.mapping.Collection inverseCollection = metadata().getCollectionBinding( associatedPersistentClass.getEntityName() + '.' + inverseCollectionPropertyName ); assertEquals( inverseForeignKeyNameExpected, inverseCollection.getKey().getColumnIterator().next().getText() ); for ( Iterator it=ownerCollection.getCollectionTable().getForeignKeyIterator(); it.hasNext(); ) { final ForeignKey fk = (ForeignKey) it.next(); assertSame( ownerCollection.getCollectionTable(), fk.getTable() ); continue; if ( fk.getColumn( 0 ).getText().equals( ownerForeignKeyNameExpected ) ) { assertSame( ownerCollection.getOwner().getTable(), fk.getReferencedTable() ); hasOwnerFK = true;
@Override public String[] getSqlCreateStrings(Table table, Metadata metadata) { final QualifiedName tableName = new QualifiedNameParser.NameParts( Identifier.toIdentifier( table.getCatalog(), table.isCatalogQuoted() ), Identifier.toIdentifier( table.getSchema(), table.isSchemaQuoted() ), table.getNameIdentifier() ); boolean isPrimaryKeyIdentity = table.hasPrimaryKey() && table.getIdentifierValue() != null && table.getIdentifierValue().isIdentityColumn( metadata.getIdentifierGeneratorFactory(), dialect ); if ( table.hasPrimaryKey() ) { Column pkColumn = (Column) table.getPrimaryKey().getColumns().iterator().next(); pkColName = pkColumn.getQuotedName( dialect ); buf.append( ", " ); String colName = col.getQuotedName( dialect ); buf.append( col.getSqlType( dialect, metadata ) );
protected void validateCustomerIndustries(Metadata metadata) { final Collection collectionBinding = metadata.getCollectionBinding( Customer.class.getName() + ".industries" ); assertNotNull( collectionBinding ); validateCustomerIndustriesTableName( collectionBinding.getCollectionTable().getQuotedName() ); assertEquals( 1, collectionBinding.getKey().getColumnSpan() ); validateCustomerIndustriesKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() ); assertEquals( 1, collectionBinding.getElement().getColumnSpan() ); validateCustomerIndustriesElementColumn( (Column) collectionBinding.getElement().getColumnIterator().next() ); }
@Override public void doTestWork(StandardServiceRegistry ssr) { MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) .addAnnotatedClass( E1.class ) .buildMetadata(); metadata.validate(); PersistentClass entityBinding = metadata.getEntityBinding( E1.class.getName() ); org.hibernate.mapping.Column idColumn = extractColumn( entityBinding.getIdentifier().getColumnIterator() ); assertTrue( isQuoted( idColumn.getSqlType(), ssr ) ); org.hibernate.mapping.Column otherColumn = extractColumn( entityBinding.getProperty( "other" ).getColumnIterator() ); assertTrue( isQuoted( otherColumn.getSqlType(), ssr ) ); } }
protected void checkDefaultJoinTableAndAllColumnNames( Metadata metadata, Class<?> ownerEntityClass, String ownerCollectionPropertyName, String expectedCollectionTableName, String ownerForeignKeyNameExpected, String[] columnNames) { final org.hibernate.mapping.Collection collection = metadata.getCollectionBinding( ownerEntityClass.getName() + '.' + ownerCollectionPropertyName ); final org.hibernate.mapping.Table table = collection.getCollectionTable(); assertEquals( expectedCollectionTableName, table.getName() ); // The default owner and inverse join columns can only be computed if they have PK with 1 column. assertEquals( 1, collection.getOwner().getKey().getColumnSpan() ); assertEquals( ownerForeignKeyNameExpected, collection.getKey().getColumnIterator().next().getText() ); int columnNumber = table.getColumnSpan(); for ( int i = 0; i < columnNumber; i++ ) { assertEquals( columnNames[i], table.getColumn( i + 1 ).getName()); } }
Property property, boolean lazyAvailable) { String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue(); (VersionType) property.getType(), getConstructor( property.getPersistentClass() ) ); attributeNumber, property.getName(), property.getValue().getType(), new BaselineAttributeInformation.Builder() .setLazy( lazy )
private void createForeignKeys() throws MappingException { // if ( !isInverse() ) { // for inverse collections, let the "other end" handle it if ( referencedPropertyName == null ) { getElement().createForeignKey(); key.createForeignKeyOfEntity( getOwner().getEntityName() ); } // } }