Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the point of hibernatetemplate's bulkupdate?
    primarykey
    data
    text
    <p>Is hibernatetemplate's <code>bulkUpdate</code> actually doing a <code>bulkUpdate</code>? I looked at the code, and it doesn't seem to be doing <code>bulkUpdate</code>. Or maybe am I missing something?</p> <pre><code>public int bulkUpdate(final String queryString, final Object... values) throws DataAccessException { return executeWithNativeSession(new HibernateCallback&lt;Integer&gt;() { public Integer doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery(queryString); prepareQuery(queryObject); if (values != null) { for (int i = 0; i &lt; values.length; i++) { queryObject.setParameter(i, values[i]); } } return queryObject.executeUpdate(); } }); } </code></pre> <p>whereas <code>JdbcTemplate batchUpdate</code> (looks like) is doing a <code>batchUpdate</code></p> <pre><code>public int[] batchUpdate(final String[] sql) throws DataAccessException { Assert.notEmpty(sql, "SQL array must not be empty"); if (logger.isDebugEnabled()) { logger.debug("Executing SQL batch update of " + sql.length + " statements"); } class BatchUpdateStatementCallback implements StatementCallback&lt;int[]&gt;, SqlProvider { private String currSql; public int[] doInStatement(Statement stmt) throws SQLException, DataAccessException { int[] rowsAffected = new int[sql.length]; if (JdbcUtils.supportsBatchUpdates(stmt.getConnection())) { for (String sqlStmt : sql) { this.currSql = sqlStmt; stmt.addBatch(sqlStmt); } rowsAffected = stmt.executeBatch(); } else { for (int i = 0; i &lt; sql.length; i++) { this.currSql = sql[i]; if (!stmt.execute(sql[i])) { rowsAffected[i] = stmt.getUpdateCount(); } else { throw new InvalidDataAccessApiUsageException("Invalid batch SQL statement: " + sql[i]); } } } return rowsAffected; } public String getSql() { return this.currSql; } } return execute(new BatchUpdateStatementCallback()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload