@Override protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SharedSessionContractImplementor session) { return new SubselectOneToManyLoader( this, subselect.toSubselectString( getCollectionType().getLHSPropertyName() ), subselect.getResult(), subselect.getQueryParameters(), subselect.getNamedParameterLocMap(), session.getFactory(), session.getLoadQueryInfluencers() ); }
if ( isRowDeleteEnabled() ) { final Expectation deleteExpectation = Expectations.appropriateExpectation( getDeleteCheckStyle() ); final boolean useBatch = deleteExpectation.canBeBatched(); if ( useBatch && deleteRowBatchKey == null ) { deleteRowBatchKey = new BasicBatchKey( getRole() + "#DELETEROW", deleteExpectation ); final String sql = getSQLDeleteRowString(); .getJdbcCoordinator() .getBatch( deleteRowBatchKey ) .getBatchStatement( sql, isDeleteCallable() ); .getJdbcCoordinator() .getStatementPreparer() .prepareStatement( sql, isDeleteCallable() ); int loc = writeKey( st, id, offset, session ); writeElementToWhere( st, collection.getSnapshotElement( entry, i ), loc, session ); if ( useBatch ) { session if ( isRowInsertEnabled() ) { final Expectation insertExpectation = Expectations.appropriateExpectation( getInsertCheckStyle() ); boolean useBatch = insertExpectation.canBeBatched(); boolean callable = isInsertCallable(); if ( useBatch && insertRowBatchKey == null ) {
@Override public Object getElementByIndex(Serializable key, Object index, SharedSessionContractImplementor session, Object owner) { return new CollectionElementLoader( this, getFactory(), session.getLoadQueryInfluencers() ) .loadElement( session, key, incrementIndexByBase( index ) ); }
/** * Generate the SQL UPDATE that updates a foreign key to a value */ @Override protected String generateInsertRowString() { final Update update = new Update( getDialect() ) .setTableName( qualifiedTableName ) .addColumns( keyColumnNames ); if ( hasIndex && !indexContainsFormula ) { for ( int i = 0 ; i < indexColumnNames.length ; i++ ) { if ( indexColumnIsSettable[i] ) { update.addColumn( indexColumnNames[i] ); } } } //identifier collections not supported for 1-to-many if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( "create one-to-many row " + getRole() ); } return update.addPrimaryKeyColumns( elementColumnNames, elementColumnWriters ) .toStatementString(); }
if ( isRowDeleteEnabled() ) { if ( collection.needsUpdating( entry, i, elementType ) ) { // will still be issued when it used to be null if ( st == null ) { if ( isDeleteCallable() ) { CallableStatement callstatement = session.getBatcher() .prepareBatchCallableStatement( getSQLDeleteRowString() ); st = session.getBatcher().prepareBatchStatement( getSQLDeleteRowString() ); int loc = writeKey( st, id, offset, session ); writeElementToWhere( st, collection.getSnapshotElement(entry, i), loc, session ); session.getBatcher().addToBatch( -1 ); count++; if ( isRowInsertEnabled() ) { if ( st == null ) { st = session.getBatcher() .prepareBatchStatement( getSQLInsertRowString() ); int loc = writeKey( st, id, offset, session ); if ( hasIndex && !indexIsFormula ) { loc = writeIndexToWhere(st, collection.getIndex(entry, i, this), loc, session ); writeElementToWhere( st, collection.getElement(entry), loc, session ); session.getBatcher().addToBatch( 1 ); count++;
/** * Generate the SQL UPDATE that updates a foreign key to a value */ protected String generateInsertRowString() { Update update = new Update() .setTableName( qualifiedTableName ) .addColumns( keyColumnNames ); if ( hasIndex && !indexIsFormula ) update.addColumns( indexColumnNames ); //identifier collections not supported for 1-to-many if ( getFactory().getSettings().isCommentsEnabled() ) { update.setComment( "create one-to-many row " + getRole() ); } return update.setPrimaryKeyColumnNames( elementColumnNames ) .toStatementString(); }
try { if ( entries.hasNext() ) { int nextIndex = resetIndex ? 0 : getSize( id, session ); Expectation expectation = Expectations.appropriateExpectation( getUpdateCheckStyle() ); while ( entries.hasNext() ) { int offset = 1; PreparedStatement st = null; boolean callable = isUpdateCallable(); boolean useBatch = expectation.canBeBatched(); String sql = getSQLUpdateRowString(); getRole() + "#RECREATE", expectation ); offset += expectation.prepare( st ); if ( hasIdentifier ) { offset = writeIdentifier( st, collection.getIdentifier( entry, nextIndex ), offset = writeIndex( st, collection.getIndex( entry, nextIndex, this ), session ); offset = writeElement( st, collection.getElement( entry ), offset, session );
/** * Create the <tt>OneToManyLoader</tt> * * @see org.hibernate.loader.collection.OneToManyLoader */ @Override protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers) throws MappingException { return BatchingCollectionInitializerBuilder.getBuilder( getFactory() ) .createBatchingOneToManyInitializer( this, batchSize, getFactory(), loadQueryInfluencers ); }
if ( isRowDeleteEnabled() ) { boolean useBatch = true; PreparedStatement st = null; if ( collection.needsUpdating( entry, i, elementType ) ) { // will still be issued when it used to be null if ( st == null ) { String sql = getSQLDeleteRowString(); if ( isDeleteCallable() ) { expectation = Expectations.appropriateExpectation( getDeleteCheckStyle() ); useBatch = expectation.canBeBatched(); st = session.getBatcher().prepareBatchStatement( getSQLDeleteRowString() ); int loc = writeKey( st, id, offset, session ); writeElementToWhere( st, collection.getSnapshotElement(entry, i), loc, session ); if ( useBatch ) { session.getBatcher().addToBatch( expectation ); if ( isRowInsertEnabled() ) { Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() ); boolean callable = isInsertCallable(); loc = writeIndexToWhere( st, collection.getIndex( entry, i, this ), loc, session ); getSQLExceptionConverter(), sqle, "could not update collection rows: " +
/** * Generate the SQL UPDATE that updates a particular row's foreign * key to null */ @Override protected String generateDeleteRowString() { final Update update = new Update( getDialect() ) .setTableName( qualifiedTableName ) .addColumns( keyColumnNames, "null" ); if ( hasIndex && !indexContainsFormula ) { for ( int i = 0 ; i < indexColumnNames.length ; i++ ) { if ( indexColumnIsSettable[i] ) { update.addColumn( indexColumnNames[i], "null" ); } } } if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( "delete one-to-many row " + getRole() ); } //use a combination of foreign key columns and pk columns, since //the ordering of removal and addition is not guaranteed when //a child moves from one parent to another String[] rowSelectColumnNames = ArrayHelper.join( keyColumnNames, elementColumnNames ); return update.addPrimaryKeyColumns( rowSelectColumnNames ) .toStatementString(); }
/** * Generate the SQL UPDATE that updates all the foreign keys to null */ protected String generateDeleteString() { Update update = new Update() .setTableName( qualifiedTableName ) .addColumns( keyColumnNames, "null" ) .setPrimaryKeyColumnNames( keyColumnNames ); if ( hasIndex && !indexIsFormula ) update.addColumns( indexColumnNames, "null" ); if ( hasWhere ) update.setWhere( sqlWhereString ); if ( getFactory().getSettings().isCommentsEnabled() ) { update.setComment( "delete one-to-many " + getRole() ); } return update.toStatementString(); }
@Override public Object getElementByIndex(Serializable key, Object index, SessionImplementor session, Object owner) { return new CollectionElementLoader( this, getFactory(), session.getLoadQueryInfluencers() ) .loadElement( session, key, incrementIndexByBase(index) ); }
/** * Create the <tt>OneToManyLoader</tt> * * @see org.hibernate.loader.collection.OneToManyLoader */ @Override protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers) throws MappingException { return BatchingCollectionInitializer.createBatchingOneToManyInitializer( this, batchSize, getFactory(), loadQueryInfluencers ); }
if ( isRowDeleteEnabled() ) { final Expectation deleteExpectation = Expectations.appropriateExpectation( getDeleteCheckStyle() ); final boolean useBatch = deleteExpectation.canBeBatched(); if ( useBatch && deleteRowBatchKey == null ) { deleteRowBatchKey = new BasicBatchKey( getRole() + "#DELETEROW", deleteExpectation ); final String sql = getSQLDeleteRowString(); .getJdbcCoordinator() .getBatch( deleteRowBatchKey ) .getBatchStatement( sql, isDeleteCallable() ); .getJdbcCoordinator() .getStatementPreparer() .prepareStatement( sql, isDeleteCallable() ); int loc = writeKey( st, id, offset, session ); writeElementToWhere( st, collection.getSnapshotElement(entry, i), loc, session ); if ( useBatch ) { session.getTransactionCoordinator() if ( isRowInsertEnabled() ) { final Expectation insertExpectation = Expectations.appropriateExpectation( getInsertCheckStyle() ); boolean useBatch = insertExpectation.canBeBatched(); boolean callable = isInsertCallable(); if ( useBatch && insertRowBatchKey == null ) {
/** * Generate the SQL UPDATE that updates all the foreign keys to null */ @Override protected String generateDeleteString() { final Update update = new Update( getDialect() ) .setTableName( qualifiedTableName ) .addColumns( keyColumnNames, "null" ) .addPrimaryKeyColumns( keyColumnNames ); if ( hasIndex && !indexContainsFormula ) { for ( int i = 0 ; i < indexColumnNames.length ; i++ ) { if ( indexColumnIsSettable[i] ) { update.addColumn( indexColumnNames[i], "null" ); } } } if ( hasWhere ) { update.setWhere( sqlWhereString ); } if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( "delete one-to-many " + getRole() ); } return update.toStatementString(); }
/** * Generate the SQL UPDATE that updates a particular row's foreign * key to null */ protected String generateDeleteRowString() { Update update = new Update() .setTableName( qualifiedTableName ) .addColumns( keyColumnNames, "null" ); if ( hasIndex && !indexIsFormula ) update.addColumns( indexColumnNames, "null" ); if ( getFactory().getSettings().isCommentsEnabled() ) { update.setComment( "delete one-to-many row " + getRole() ); } //use a combination of foreign key columns and pk columns, since //the ordering of removal and addition is not guaranteed when //a child moves from one parent to another String[] rowSelectColumnNames = ArrayHelper.join(keyColumnNames, elementColumnNames); return update.setPrimaryKeyColumnNames( rowSelectColumnNames ) .toStatementString(); }
@Override public Object getElementByIndex(Serializable key, Object index, SessionImplementor session, Object owner) { return new CollectionElementLoader( this, getFactory(), session.getLoadQueryInfluencers() ) .loadElement( session, key, incrementIndexByBase(index) ); }
protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SessionImplementor session) { return new SubselectOneToManyLoader( this, subselect.toSubselectString( getCollectionType().getLHSPropertyName() ), subselect.getResult(), subselect.getQueryParameters(), subselect.getNamedParameterLocMap(), session.getFactory(), session.getEnabledFilters() ); }
/** * Create the <tt>OneToManyLoader</tt> * * @see org.hibernate.loader.collection.OneToManyLoader */ protected CollectionInitializer createCollectionInitializer(java.util.Map enabledFilters) throws MappingException { return BatchingCollectionInitializer.createBatchingOneToManyInitializer( this, batchSize, getFactory(), enabledFilters ); }
if ( isRowDeleteEnabled() ) { final Expectation deleteExpectation = Expectations.appropriateExpectation( getDeleteCheckStyle() ); final boolean useBatch = deleteExpectation.canBeBatched(); if ( useBatch && deleteRowBatchKey == null ) { deleteRowBatchKey = new BasicBatchKey( getRole() + "#DELETEROW", deleteExpectation ); final String sql = getSQLDeleteRowString(); .getJdbcCoordinator() .getBatch( deleteRowBatchKey ) .getBatchStatement( sql, isDeleteCallable() ); .getJdbcCoordinator() .getStatementPreparer() .prepareStatement( sql, isDeleteCallable() ); int loc = writeKey( st, id, offset, session ); writeElementToWhere( st, collection.getSnapshotElement(entry, i), loc, session ); if ( useBatch ) { session.getTransactionCoordinator() if ( isRowInsertEnabled() ) { final Expectation insertExpectation = Expectations.appropriateExpectation( getInsertCheckStyle() ); boolean useBatch = insertExpectation.canBeBatched(); boolean callable = isInsertCallable(); if ( useBatch && insertRowBatchKey == null ) {