final ProcessedWhereClause processedWhereClause = processWhereClause( updateStatement.getWhereClause() ); this.idSelectParameterSpecifications = processedWhereClause.getIdSelectParameterSpecifications(); this.idInsertSelect = generateIdInsertSelect( bulkTargetAlias, idTableInfo, processedWhereClause ); log.tracev( "Generated ID-INSERT-SELECT SQL (multi-table update) : {0}", idInsertSelect ); String idSubselect = generateIdSubselect( targetedPersister, idTableInfo ); .setTableName( tableNames[tableIndex] ) .setWhere( "(" + String.join( ", ", columnNames[tableIndex] ) + ") IN (" + idSubselect + ")" ); if ( factory().getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( "bulk update" );
@Override public int execute(SharedSessionContractImplementor session, QueryParameters queryParameters) { prepareForUse( targetedPersister, session ); try { ps = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( idInsertSelect, false ); int position = 1; position += handlePrependedParametersOnIdSelection( ps, session, position ); for ( ParameterSpecification parameterSpecification : idSelectParameterSpecifications ) { position += parameterSpecification.bind( ps, queryParameters, session, position ); position += assignmentParameterSpecifications[i][x].bind( ps, queryParameters, session, position ); handleAddedParametersOnUpdate( ps, session, position ); releaseFromUse( targetedPersister, session );
String[] updates = delegate.getSqlStatements(); UpdateStatement updateStatement = (UpdateStatement) walker.getAST(); FromElement fromElement = updateStatement.getFromClause().getFromElement(); String[][] columnNames = targetedPersister.getContraintOrderedTableKeyColumnClosure(); int subclassCount = delegate.getTargetedQueryable().getEntityMetamodel().getSubclassEntityNames().size(); Set<String> subclassTableNames = new HashSet<>(); for (int i = 0; i < subclassCount; i++) { subclassTableNames.add(delegate.getTargetedQueryable().getSubclassTableName(i));
@Override public String[] getSqlStatements() { return delegate.getSqlStatements(); } }
@Override public Queryable getTargetedQueryable() { return delegate.getTargetedQueryable(); }
@Override public int execute(final SessionImplementor session, QueryParameters queryParameters) { final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator(); Object jdbcCoordinatorProxy = Proxy.newProxyInstance(jdbcCoordinator.getClass().getClassLoader(), new Class[]{JdbcCoordinator.class}, new JdbcCoordinatorInvocationHandler(jdbcCoordinator, new DelegatingStatementPreparerImpl(jdbcCoordinator.getStatementPreparer()) { PreparedStatement statementProxy; SecondaryTableUpdateSupportingPreparedStatementInvocationHandler invocationHandler; @Override public PreparedStatement prepareStatement(String sql, boolean isCallable) { if (sql.isEmpty()) { // Return the statement proxy which collects parameters and then executes update/insert statements for secondary tables invocationHandler.prepareNext(); return statementProxy; } else { PreparedStatement insertStatement = super.prepareStatement(sql, isCallable); this.invocationHandler = new SecondaryTableUpdateSupportingPreparedStatementInvocationHandler(session, jdbcCoordinator.getStatementPreparer(), insertStatement, secondaryTableUpdates, secondaryTableInserts); this.statementProxy = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{PreparedStatement.class}, invocationHandler); return statementProxy; } } })); SessionImplementor sessionProxy = (SessionImplementor) Proxy.newProxyInstance(session.getClass().getClassLoader(), new Class[]{SessionImplementor.class, EventSource.class}, new Hibernate5SessionInvocationHandler(session, jdbcCoordinatorProxy)); return delegate.execute(sessionProxy, queryParameters); }
@Override protected String generateIdSubselect(Queryable persister, IdTableInfo idTableInfo) { return super.generateIdSubselect( persister, idTableInfo ) + " where " + SESSION_ID_COLUMN_NAME + "=?"; }
String[] updates = delegate.getSqlStatements(); UpdateStatement updateStatement = (UpdateStatement) walker.getAST(); FromElement fromElement = updateStatement.getFromClause().getFromElement(); String[][] columnNames = targetedPersister.getContraintOrderedTableKeyColumnClosure(); int subclassCount = delegate.getTargetedQueryable().getEntityMetamodel().getSubclassEntityNames().size(); Set<String> subclassTableNames = new HashSet<>(); for (int i = 0; i < subclassCount; i++) { subclassTableNames.add(delegate.getTargetedQueryable().getSubclassTableName(i));
@Override public String[] getSqlStatements() { return delegate.getSqlStatements(); } }
@Override public Queryable getTargetedQueryable() { return delegate.getTargetedQueryable(); }
@Override public int execute(SharedSessionContractImplementor s, QueryParameters queryParameters) { final SessionImplementor session = (SessionImplementor) s; final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator(); Object jdbcCoordinatorProxy = Proxy.newProxyInstance(jdbcCoordinator.getClass().getClassLoader(), new Class[]{JdbcCoordinator.class}, new JdbcCoordinatorInvocationHandler(jdbcCoordinator, new DelegatingStatementPreparerImpl(jdbcCoordinator.getStatementPreparer()) { PreparedStatement statementProxy; SecondaryTableUpdateSupportingPreparedStatementInvocationHandler invocationHandler; @Override public PreparedStatement prepareStatement(String sql, boolean isCallable) { if (sql.isEmpty()) { // Return the statement proxy which collects parameters and then executes update/insert statements for secondary tables invocationHandler.prepareNext(); return statementProxy; } else { PreparedStatement insertStatement = super.prepareStatement(sql, isCallable); this.invocationHandler = new SecondaryTableUpdateSupportingPreparedStatementInvocationHandler(session, jdbcCoordinator.getStatementPreparer(), insertStatement, secondaryTableUpdates, secondaryTableInserts); this.statementProxy = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{PreparedStatement.class}, invocationHandler); return statementProxy; } } })); SessionImplementor sessionProxy = (SessionImplementor) Proxy.newProxyInstance(session.getClass().getClassLoader(), new Class[]{SessionImplementor.class, EventSource.class}, new Hibernate53SessionInvocationHandler(session, jdbcCoordinatorProxy)); return delegate.execute(sessionProxy, queryParameters); }
String[] updates = delegate.getSqlStatements(); UpdateStatement updateStatement = (UpdateStatement) walker.getAST(); FromElement fromElement = updateStatement.getFromClause().getFromElement(); String[][] columnNames = targetedPersister.getContraintOrderedTableKeyColumnClosure(); int subclassCount = delegate.getTargetedQueryable().getEntityMetamodel().getSubclassEntityNames().size(); Set<String> subclassTableNames = new HashSet<>(); for (int i = 0; i < subclassCount; i++) { subclassTableNames.add(delegate.getTargetedQueryable().getSubclassTableName(i));
@Override public String[] getSqlStatements() { return delegate.getSqlStatements(); } }
@Override public Queryable getTargetedQueryable() { return delegate.getTargetedQueryable(); }
@Override public int execute(SharedSessionContractImplementor s, QueryParameters queryParameters) { final SessionImplementor session = (SessionImplementor) s; final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator(); Object jdbcCoordinatorProxy = Proxy.newProxyInstance(jdbcCoordinator.getClass().getClassLoader(), new Class[]{JdbcCoordinator.class}, new JdbcCoordinatorInvocationHandler(jdbcCoordinator, new DelegatingStatementPreparerImpl(jdbcCoordinator.getStatementPreparer()) { PreparedStatement statementProxy; SecondaryTableUpdateSupportingPreparedStatementInvocationHandler invocationHandler; @Override public PreparedStatement prepareStatement(String sql, boolean isCallable) { if (sql.isEmpty()) { // Return the statement proxy which collects parameters and then executes update/insert statements for secondary tables invocationHandler.prepareNext(); return statementProxy; } else { PreparedStatement insertStatement = super.prepareStatement(sql, isCallable); this.invocationHandler = new SecondaryTableUpdateSupportingPreparedStatementInvocationHandler(session, jdbcCoordinator.getStatementPreparer(), insertStatement, secondaryTableUpdates, secondaryTableInserts); this.statementProxy = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{PreparedStatement.class}, invocationHandler); return statementProxy; } } })); SessionImplementor sessionProxy = (SessionImplementor) Proxy.newProxyInstance(session.getClass().getClassLoader(), new Class[]{SessionImplementor.class, EventSource.class}, new Hibernate53SessionInvocationHandler(session, jdbcCoordinatorProxy)); return delegate.execute(sessionProxy, queryParameters); }
String[] updates = delegate.getSqlStatements(); UpdateStatement updateStatement = (UpdateStatement) walker.getAST(); FromElement fromElement = updateStatement.getFromClause().getFromElement(); String[][] columnNames = targetedPersister.getContraintOrderedTableKeyColumnClosure(); int subclassCount = delegate.getTargetedQueryable().getEntityMetamodel().getSubclassEntityNames().size(); Set<String> subclassTableNames = new HashSet<>(); for (int i = 0; i < subclassCount; i++) { subclassTableNames.add(delegate.getTargetedQueryable().getSubclassTableName(i));
@Override public String[] getSqlStatements() { return delegate.getSqlStatements(); } }
@Override public Queryable getTargetedQueryable() { return delegate.getTargetedQueryable(); }
@Override public int execute(final SessionImplementor session, QueryParameters queryParameters) { final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator(); Object jdbcCoordinatorProxy = Proxy.newProxyInstance(jdbcCoordinator.getClass().getClassLoader(), new Class[]{JdbcCoordinator.class}, new JdbcCoordinatorInvocationHandler(jdbcCoordinator, new DelegatingStatementPreparerImpl(jdbcCoordinator.getStatementPreparer()) { PreparedStatement statementProxy; SecondaryTableUpdateSupportingPreparedStatementInvocationHandler invocationHandler; @Override public PreparedStatement prepareStatement(String sql, boolean isCallable) { if (sql.isEmpty()) { // Return the statement proxy which collects parameters and then executes update/insert statements for secondary tables invocationHandler.prepareNext(); return statementProxy; } else { PreparedStatement insertStatement = super.prepareStatement(sql, isCallable); this.invocationHandler = new SecondaryTableUpdateSupportingPreparedStatementInvocationHandler(session, jdbcCoordinator.getStatementPreparer(), insertStatement, secondaryTableUpdates, secondaryTableInserts); this.statementProxy = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{PreparedStatement.class}, invocationHandler); return statementProxy; } } })); SessionImplementor sessionProxy = (SessionImplementor) Proxy.newProxyInstance(session.getClass().getClassLoader(), new Class[]{SessionImplementor.class, EventSource.class}, new Hibernate5SessionInvocationHandler(session, jdbcCoordinatorProxy)); return delegate.execute(sessionProxy, queryParameters); }
String[] updates = delegate.getSqlStatements(); UpdateStatement updateStatement = (UpdateStatement) walker.getAST(); FromElement fromElement = updateStatement.getFromClause().getFromElement(); String[][] columnNames = targetedPersister.getContraintOrderedTableKeyColumnClosure(); int subclassCount = delegate.getTargetedQueryable().getEntityMetamodel().getSubclassEntityNames().size(); Set<String> subclassTableNames = new HashSet<>(); for (int i = 0; i < subclassCount; i++) { subclassTableNames.add(delegate.getTargetedQueryable().getSubclassTableName(i));