while ( joinIter.hasNext() ) { Join join = (Join) joinIter.next(); qualifiedTableNames[j] = determineTableName( join.getTable(), jdbcEnvironment ); isInverseTable[j] = join.isInverse(); isNullableTable[j] = join.isOptional() || creationContext.getSessionFactory() .getSessionFactoryOptions() .getJpaCompliance() .isJpaCacheComplianceEnabled(); cascadeDeleteEnabled[j] = join.getKey().isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete(); customSQLInsert[j] = join.getCustomSQLInsert(); insertCallable[j] = customSQLInsert[j] != null && join.isCustomInsertCallable(); insertResultCheckStyles[j] = join.getCustomSQLInsertCheckStyle() == null ? ExecuteUpdateResultCheckStyle.determineDefault( customSQLInsert[j], insertCallable[j] ) : join.getCustomSQLInsertCheckStyle(); customSQLUpdate[j] = join.getCustomSQLUpdate(); updateCallable[j] = customSQLUpdate[j] != null && join.isCustomUpdateCallable(); updateResultCheckStyles[j] = join.getCustomSQLUpdateCheckStyle() == null ? ExecuteUpdateResultCheckStyle.determineDefault( customSQLUpdate[j], updateCallable[j] ) : join.getCustomSQLUpdateCheckStyle(); customSQLDelete[j] = join.getCustomSQLDelete(); deleteCallable[j] = customSQLDelete[j] != null && join.isCustomDeleteCallable(); deleteResultCheckStyles[j] = join.getCustomSQLDeleteCheckStyle() == null ? ExecuteUpdateResultCheckStyle.determineDefault( customSQLDelete[j], deleteCallable[j] ) : join.getCustomSQLDeleteCheckStyle(); Iterator iter = join.getKey().getColumnIterator();
if ( !checkPropertiesAudited( join.getPropertyIterator(), auditingData ) ) { continue; final String originalTableName = join.getTable().getName(); String auditTableName = auditingData.getSecondaryTableDictionary().get( originalTableName ); if ( auditTableName == null ) { final String schema = getSchema( auditingData.getAuditTable().schema(), join.getTable() ); final String catalog = getCatalog( auditingData.getAuditTable().catalog(), join.getTable() ); if ( join.isOptional() ) { joinElement.addAttribute( "optional", "true" ); if ( join.isInverse() ) { joinElement.addAttribute( "inverse", "true" ); MetadataTools.addColumns( joinKey, join.getKey().getColumnIterator() ); MetadataTools.addColumn( joinKey, verEntCfg.getRevisionFieldName(), null, null, null, null, null, null );
Join join = new Join(); join.setPersistentClass( persistentClass ); join.setTable( originalJoin.getTable() ); join.setInverse( true ); SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() ); join.setKey( key ); join.setSequentialSelect( false ); join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway key.setCascadeDeleteEnabled( false ); Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator();
public Component(MetadataBuildingContext metadata, Join join) throws MappingException { this( metadata, join.getTable(), join.getPersistentClass() ); }
private void bindJoinToPersistentClass(Join join, Ejb3JoinColumn[] ejb3JoinColumns, MetadataBuildingContext buildingContext) { SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() ); join.setKey( key ); setFKNameIfDefined( join ); key.setCascadeDeleteEnabled( false ); TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, buildingContext ); join.createPrimaryKey(); join.createForeignKey(); persistentClass.addJoin( join ); }
private void addPropertyToJoin(Property prop, XClass declaringClass, Join join) { if ( declaringClass != null ) { final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); if ( inheritanceState == null ) { throw new AssertionFailure( "Declaring class is not found in the inheritance state hierarchy: " + declaringClass ); } if ( inheritanceState.isEmbeddableSuperclass() ) { join.addMappedsuperclassProperty(prop); addPropertyToMappedSuperclass( prop, declaringClass ); } else { join.addProperty( prop ); } } else { join.addProperty( prop ); } }
Join join = new Join(); join.setPersistentClass( persistentClass ); join.setTable( table ); LOG.debugf( "Adding secondary table to entity %s -> %s", persistentClass.getEntityName(), join.getTable().getName() ); org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join ); if ( matchingTable != null ) { join.setSequentialSelect( FetchMode.JOIN != matchingTable.fetch() ); join.setInverse( matchingTable.inverse() ); join.setOptional( matchingTable.optional() ); if ( !BinderHelper.isEmptyAnnotationValue( matchingTable.sqlInsert().sql() ) ) { join.setCustomSQLInsert( matchingTable.sqlInsert().sql().trim(), matchingTable.sqlInsert().callable(), ExecuteUpdateResultCheckStyle.fromExternalName( join.setCustomSQLUpdate( matchingTable.sqlUpdate().sql().trim(), matchingTable.sqlUpdate().callable(), ExecuteUpdateResultCheckStyle.fromExternalName( join.setCustomSQLDelete( matchingTable.sqlDelete().sql().trim(), matchingTable.sqlDelete().callable(), ExecuteUpdateResultCheckStyle.fromExternalName( join.setSequentialSelect( false ); join.setInverse( false ); join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway
PersistentClass persistentClass = join.getPersistentClass(); String path = persistentClass.getEntityName(); getSubselect( node ), false ); join.setTable( table ); bindComment(table, node); join.setSequentialSelect( "select".equals( fetchNode.getValue() ) ); if ( invNode != null ) join.setInverse( "true".equals( invNode.getValue() ) ); if ( nullNode != null ) join.setOptional( "true".equals( nullNode.getValue() ) ); + join.getTable().getName() ); join.setKey( key ); key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) ); bindSimpleValue( keyNode, key, false, persistentClass.getEntityName(), mappings ); join.createPrimaryKey(); join.createForeignKey(); subnode, (Component) value, join.getPersistentClass().getClassName(), propertyName, subpath,
Join secondaryTableJoin, final EntityTableXref entityTableXref) { final PersistentClass persistentClass = secondaryTableJoin.getPersistentClass(); secondaryTableJoin.setTable( secondaryTable ); entityTableXref.addSecondaryTable( mappingDocument, logicalTableName, secondaryTableJoin ); ); secondaryTableJoin.setSequentialSelect( secondaryTableSource.getFetchStyle() == FetchStyle.SELECT ); secondaryTableJoin.setInverse( secondaryTableSource.isInverse() ); secondaryTableJoin.setOptional( secondaryTableSource.isOptional() ); keyBinding.makeNationalized(); secondaryTableJoin.setKey( keyBinding ); secondaryTableJoin.createPrimaryKey(); secondaryTableJoin.createForeignKey();
while ( it.hasNext() ) { Join otherSideJoinValue = (Join) it.next(); if ( otherSideJoinValue.containsProperty( otherSideProperty ) ) { otherSideJoin = otherSideJoinValue; break; (PersistentClass) persistentClasses.get( ownerEntity ), otherSideProperty, otherSideJoin ); ManyToOne manyToOne = new ManyToOne( buildingContext, mappedByJoin.getTable() ); manyToOne.setUnwrapProxy( value.isUnwrapProxy() ); prop.setValue( manyToOne ); Iterator otherSideJoinKeyColumns = otherSideJoin.getKey().getColumnIterator(); while ( otherSideJoinKeyColumns.hasNext() ) { Column column = (Column) otherSideJoinKeyColumns.next(); manyToOne.addColumn( copy ); mappedByJoin.addProperty( prop );
Join join = new Join(); join.setPersistentClass( persistentClass ); join.setTable( originalJoin.getMappedTable() ); join.setInverse( true ); SimpleValue key = new DependantValue( buildingContext, join.getMappedTable(), persistentClass.getIdentifier() ); join.setKey( key ); join.setSequentialSelect( false ); join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway key.setCascadeDeleteEnabled( false ); otherSideProperty.getValue() .forEach( column -> key.addColumn( ( (Column) column ).clone() ) ); persistentClass.addJoin( join ); join.createForeignKey(); return join;
private static void bindCustomSql( MappingDocument sourceDocument, SecondaryTableSource secondaryTableSource, Join secondaryTable) { if ( secondaryTableSource.getCustomSqlInsert() != null ) { secondaryTable.setCustomSQLInsert( secondaryTableSource.getCustomSqlInsert().getSql(), secondaryTableSource.getCustomSqlInsert().isCallable(), secondaryTableSource.getCustomSqlInsert().getCheckStyle() ); } if ( secondaryTableSource.getCustomSqlUpdate() != null ) { secondaryTable.setCustomSQLUpdate( secondaryTableSource.getCustomSqlUpdate().getSql(), secondaryTableSource.getCustomSqlUpdate().isCallable(), secondaryTableSource.getCustomSqlUpdate().getCheckStyle() ); } if ( secondaryTableSource.getCustomSqlDelete() != null ) { secondaryTable.setCustomSQLDelete( secondaryTableSource.getCustomSqlDelete().getSql(), secondaryTableSource.getCustomSqlDelete().isCallable(), secondaryTableSource.getCustomSqlDelete().getCheckStyle() ); } }
/** * Needed for proper compliance with naming strategy, the property table * can be overriden if the properties are part of secondary tables */ private Map<String, Join> getJoinsPerRealTableName() { if ( joinsPerRealTableName == null ) { joinsPerRealTableName = new HashMap<String, Join>( joins.size() ); for (Join join : joins.values()) { joinsPerRealTableName.put( join.getTable().getName(), join ); } } return joinsPerRealTableName; }
final Join secondaryTableJoin = new Join(); secondaryTableJoin.setPersistentClass( entityDescriptor ); bindSecondaryTable( mappingDocument, table = secondaryTableJoin.getTable(); attributeContainer = secondaryTableJoin; attribute.setOptional( secondaryTableJoin.isOptional() ); table = secondaryTableJoin.getTable(); attributeContainer = secondaryTableJoin; attribute.setOptional( secondaryTableJoin.isOptional() ); table = secondaryTableJoin.getTable(); attributeContainer = secondaryTableJoin; attribute.setOptional( secondaryTableJoin.isOptional() ); table = secondaryTableJoin.getTable(); attributeContainer = secondaryTableJoin; attribute.setOptional( secondaryTableJoin.isOptional() );
public static void bindJoinToPersistentClass( Join join, Ejb3JoinColumn[] ejb3JoinColumns, PersistentClass persistentClass, ExtendedMappings mappings ) { SimpleValue key = new DependantValue( join.getTable(), persistentClass.getIdentifier() ); join.setKey( key ); join.setSequentialSelect( false ); join.setInverse( false ); join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway key.setCascadeDeleteEnabled( false ); TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, mappings ); join.createPrimaryKey(); join.createForeignKey(); persistentClass.addJoin( join ); }
public boolean isLazy() { Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property prop = (Property) iter.next(); if ( !prop.isLazy() ) { return false; } } return true; }
public void createForeignKey() { getKey().createForeignKeyOfEntity( persistentClass.getEntityName() ); }
referencedTable = ( (Join) columnOwner ).getTable(); Iterator it = isPersistentClass ? ( (PersistentClass) columnOwner ).getPropertyIterator() : ( (Join) columnOwner ).getPropertyIterator(); while ( it.hasNext() ) { matchColumnsByProperty( (Property) it.next(), columnsToProperty );
boolean noDelayInPkColumnCreation ) { Join join = new Join(); join.setPersistentClass( persistentClass ); String schema; String catalog;
protected void checkColumnDuplication() { HashSet cols = new HashSet(); if ( getIdentifierMapper() == null ) { //an identifier mapper => getKey will be included in the getNonDuplicatedPropertyIterator() //and checked later, so it needs to be excluded checkColumnDuplication( cols, getKey().getColumnIterator() ); } checkColumnDuplication( cols, getDiscriminatorColumnIterator() ); checkPropertyColumnDuplication( cols, getNonDuplicatedPropertyIterator() ); Iterator iter = getJoinIterator(); while ( iter.hasNext() ) { cols.clear(); Join join = (Join) iter.next(); checkColumnDuplication( cols, join.getKey().getColumnIterator() ); checkPropertyColumnDuplication( cols, join.getPropertyIterator() ); } }