public abstract class DmlHandler extends Object implements PersistHandler, BindableRequest
| Modifier and Type | Field and Description |
|---|---|
protected StringBuilder |
bindLog |
protected DataBind |
dataBind
The PreparedStatement used for the dml.
|
protected boolean |
emptyStringToNull |
protected Set<String> |
loadedProps |
protected boolean |
logLevelSql |
protected PersistRequestBean<?> |
persistRequest
The originating request.
|
protected String |
sql |
protected SpiTransaction |
transaction |
protected ArrayList<com.avaje.ebeaninternal.server.persist.dml.DmlHandler.UpdateGenValue> |
updateGenValues |
| Modifier | Constructor and Description |
|---|---|
protected |
DmlHandler(PersistRequestBean<?> persistRequest,
boolean emptyStringToNull) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch()
Add this for batch execution.
|
abstract void |
bind()
Get the sql and bind the statement.
|
Object |
bind(Object value,
BeanProperty prop,
String propName,
boolean bindNull)
Bind the value to the preparedStatement.
|
Object |
bind(String propName,
Object value,
int sqlType)
Bind a raw value.
|
Object |
bindNoLog(Object value,
BeanProperty prop,
String propName,
boolean bindNull)
Bind the value to the preparedStatement without logging.
|
Object |
bindNoLog(Object value,
int sqlType,
String logPlaceHolder)
Bind a raw value with a placeHolder to put into the transaction log.
|
protected void |
checkRowCount(int rowCount)
Check the rowCount.
|
void |
close()
Close the underlying statement.
|
abstract void |
execute()
Execute now for non-batch execution.
|
String |
getBindLog()
Return the bind log.
|
PersistRequestBean<?> |
getPersistRequest()
Return the original PersistRequest.
|
protected PreparedStatement |
getPstmt(SpiTransaction t,
String sql,
boolean genKeys)
Check with useGeneratedKeys to get appropriate PreparedStatement.
|
protected PreparedStatement |
getPstmt(SpiTransaction t,
String sql,
PersistRequestBean<?> request,
boolean genKeys)
Return a prepared statement taking into account batch requirements.
|
boolean |
isIncluded(BeanProperty prop)
Return true if the property is included in this request.
|
boolean |
isIncludedWhere(BeanProperty prop)
Return true if the property is included in the WHERE clause for this
request.
|
protected void |
logSql(String sql)
Log the sql to the transaction log.
|
void |
registerAdditionalProperty(String propertyName)
For generated properties set on insert register as additional loaded
properties if required.
|
void |
registerUpdateGenValue(BeanProperty prop,
Object bean,
Object value)
Register a generated value on a update.
|
protected void |
setAdditionalProperties()
Set any additional (generated) properties to the set of loaded properties
if required.
|
void |
setIdValue(Object idValue)
Set the Id value that was bound.
|
void |
setUpdateGenValues()
Set any update generated values to the bean.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitregisterDerivedRelationshipprotected final PersistRequestBean<?> persistRequest
protected final StringBuilder bindLog
protected final SpiTransaction transaction
protected final boolean emptyStringToNull
protected final boolean logLevelSql
protected DataBind dataBind
protected String sql
protected ArrayList<com.avaje.ebeaninternal.server.persist.dml.DmlHandler.UpdateGenValue> updateGenValues
protected DmlHandler(PersistRequestBean<?> persistRequest, boolean emptyStringToNull)
public PersistRequestBean<?> getPersistRequest()
BindableRequestgetPersistRequest in interface BindableRequestpublic abstract void bind()
throws SQLException
bind in interface PersistHandlerSQLExceptionpublic abstract void execute()
throws SQLException
execute in interface PersistHandlerSQLExceptionprotected void checkRowCount(int rowCount)
throws SQLException,
javax.persistence.OptimisticLockException
SQLExceptionjavax.persistence.OptimisticLockExceptionpublic void addBatch()
throws SQLException
addBatch in interface PersistHandlerSQLExceptionpublic void close()
close in interface PersistHandlerpublic String getBindLog()
getBindLog in interface PersistHandlerpublic void setIdValue(Object idValue)
setIdValue in interface BindableRequestprotected void logSql(String sql)
public boolean isIncluded(BeanProperty prop)
BindableRequestisIncluded in interface BindableRequestpublic boolean isIncludedWhere(BeanProperty prop)
BindableRequestisIncludedWhere in interface BindableRequestpublic Object bind(String propName, Object value, int sqlType) throws SQLException
bind in interface BindableRequestSQLExceptionpublic Object bindNoLog(Object value, int sqlType, String logPlaceHolder) throws SQLException
BindableRequestbindNoLog in interface BindableRequestSQLExceptionpublic Object bind(Object value, BeanProperty prop, String propName, boolean bindNull) throws SQLException
bind in interface BindableRequestvalue - the value of a propertybindNull - if true bind null values, if false use IS NULL.SQLExceptionpublic Object bindNoLog(Object value, BeanProperty prop, String propName, boolean bindNull) throws SQLException
bindNoLog in interface BindableRequestSQLExceptionpublic final void registerAdditionalProperty(String propertyName)
registerAdditionalProperty in interface BindableRequestprotected void setAdditionalProperties()
public void registerUpdateGenValue(BeanProperty prop, Object bean, Object value)
GeneratedProperty values are likely going to be used for optimistic concurrency checking. This includes 'counter' and 'update timestamp' generation.
registerUpdateGenValue in interface BindableRequestpublic void setUpdateGenValues()
protected PreparedStatement getPstmt(SpiTransaction t, String sql, boolean genKeys) throws SQLException
SQLExceptionprotected PreparedStatement getPstmt(SpiTransaction t, String sql, PersistRequestBean<?> request, boolean genKeys) throws SQLException
SQLExceptionCopyright © 2014. All Rights Reserved.