io.ebeaninternal.server.core.PersistRequestUpdateSql Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.core;
import io.ebean.SqlUpdate;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiSqlUpdate;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.persist.PersistExecute;
/**
* Persist request specifically for CallableSql.
*/
public final class PersistRequestUpdateSql extends PersistRequest {
public enum SqlType {
SQL_UPDATE, SQL_DELETE, SQL_INSERT, SQL_UNKNOWN
}
private final SpiSqlUpdate updateSql;
private int rowCount;
private String bindLog;
private SqlType sqlType;
private String tableName;
private String description;
/**
* Create.
*/
public PersistRequestUpdateSql(SpiEbeanServer server, SqlUpdate updateSql,
SpiTransaction t, PersistExecute persistExecute) {
super(server, t, persistExecute);
this.type = Type.UPDATESQL;
this.updateSql = (SpiSqlUpdate) updateSql;
}
@Override
public int executeNow() {
return persistExecute.executeSqlUpdate(this);
}
@Override
public int executeOrQueue() {
return executeStatement();
}
/**
* Return the UpdateSql.
*/
public SpiSqlUpdate getUpdateSql() {
return updateSql;
}
/**
* No concurrency checking so just note the rowCount.
*/
@Override
public void checkRowCount(int count) {
this.rowCount = count;
}
/**
* Not called for this type of request.
*/
@Override
public void setGeneratedKey(Object idValue) {
}
/**
* Specify the type of statement executed. Used to automatically register
* with the transaction event.
*/
public void setType(SqlType sqlType, String tableName, String description) {
this.sqlType = sqlType;
this.tableName = tableName;
this.description = description;
}
/**
* Set the bound values.
*/
public void setBindLog(String bindLog) {
this.bindLog = bindLog;
}
/**
* Perform post execute processing.
*/
@Override
public void postExecute() {
if (transaction.isLogSummary()) {
String m = description + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]";
transaction.logSummary(m);
}
if (updateSql.isAutoTableMod()) {
// add the modification info to the TransactionEvent
// this is used to invalidate cached objects etc
switch (sqlType) {
case SQL_INSERT:
transaction.getEvent().add(tableName, true, false, false);
break;
case SQL_UPDATE:
transaction.getEvent().add(tableName, false, true, false);
break;
case SQL_DELETE:
transaction.getEvent().add(tableName, false, false, true);
break;
default:
break;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy