Class DefaultOrmUpdate<T>
- java.lang.Object
-
- io.ebeaninternal.server.querydefn.DefaultOrmUpdate<T>
-
- All Implemented Interfaces:
Update<T>
,SpiUpdate<T>
,Serializable
public final class DefaultOrmUpdate<T> extends Object implements SpiUpdate<T>, Serializable
Default implementation of OrmUpdate.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.ebeaninternal.api.SpiUpdate
SpiUpdate.OrmUpdateType
-
-
Constructor Summary
Constructors Constructor Description DefaultOrmUpdate(Class<?> beanType, EbeanServer server, String baseTable, String updateStatement)
Create with a specific server.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
execute()
Execute the statement returning the number of rows modified.String
getBaseTable()
Return the name of the table being modified.Class<?>
getBeanType()
Return the type of bean being updated.BindParams
getBindParams()
Return the bind parameters.String
getGeneratedSql()
Return the sql that is actually executed.String
getLabel()
Return the label (for metrics collection).String
getName()
Return the name if it is a named update.SpiUpdate.OrmUpdateType
getOrmUpdateType()
Return the type of this - insert, update or delete.int
getTimeout()
Return the timeout in seconds.String
getUpdateStatement()
Return the update statement.boolean
isNotifyCache()
Return true if the cache should be notified so that invalidates appropriate objects.DefaultOrmUpdate<T>
set(int position, Object value)
Set an ordered bind parameter.DefaultOrmUpdate<T>
set(String name, Object value)
Set a named parameter.void
setGeneratedSql(String generatedSql)
Set the generated sql used.Update<T>
setLabel(String label)
Set a label meaning performance metrics will be collected for the execution of this update.DefaultOrmUpdate<T>
setNotifyCache(boolean notifyCache)
Set this to false if you don't want eBean to automatically deduce the table modification information and process it.DefaultOrmUpdate<T>
setNull(int position, int jdbcType)
Set an ordered parameter that is null.DefaultOrmUpdate<T>
setNull(String name, int jdbcType)
Set a named parameter that is null.DefaultOrmUpdate<T>
setNullParameter(int position, int jdbcType)
Set an ordered parameter that is null (same as bind).DefaultOrmUpdate<T>
setNullParameter(String name, int jdbcType)
Bind a named parameter that is null (same as bind).DefaultOrmUpdate<T>
setParameter(int position, Object value)
Set and ordered bind parameter (same as bind).DefaultOrmUpdate<T>
setParameter(String name, Object param)
Bind a named parameter (same as bind).DefaultOrmUpdate<T>
setTimeout(int secs)
Set a timeout for statement execution.
-
-
-
Constructor Detail
-
DefaultOrmUpdate
public DefaultOrmUpdate(Class<?> beanType, EbeanServer server, String baseTable, String updateStatement)
Create with a specific server. This means you can use the UpdateSql.execute() method.
-
-
Method Detail
-
setTimeout
public DefaultOrmUpdate<T> setTimeout(int secs)
Description copied from interface:Update
Set a timeout for statement execution.This will typically result in a call to setQueryTimeout() on a preparedStatement. If the timeout occurs an exception will be thrown - this will be a SQLException wrapped up in a PersistenceException.
- Specified by:
setTimeout
in interfaceUpdate<T>
- Parameters:
secs
- the timeout in seconds. Zero implies unlimited.
-
getBeanType
public Class<?> getBeanType()
Description copied from interface:SpiUpdate
Return the type of bean being updated.- Specified by:
getBeanType
in interfaceSpiUpdate<T>
-
getTimeout
public int getTimeout()
Return the timeout in seconds.- Specified by:
getTimeout
in interfaceSpiUpdate<T>
-
execute
public int execute()
Description copied from interface:Update
Execute the statement returning the number of rows modified.
-
setNotifyCache
public DefaultOrmUpdate<T> setNotifyCache(boolean notifyCache)
Set this to false if you don't want eBean to automatically deduce the table modification information and process it.Set this to false if you don't want any cache invalidation or text index management to occur. You may do this when say you update only one column and you know that it is not important for cached objects or text indexes.
- Specified by:
setNotifyCache
in interfaceUpdate<T>
-
isNotifyCache
public boolean isNotifyCache()
Return true if the cache should be notified so that invalidates appropriate objects.- Specified by:
isNotifyCache
in interfaceSpiUpdate<T>
-
getName
public String getName()
Description copied from interface:Update
Return the name if it is a named update.
-
setLabel
public Update<T> setLabel(String label)
Description copied from interface:Update
Set a label meaning performance metrics will be collected for the execution of this update.
-
getLabel
public String getLabel()
Description copied from interface:SpiUpdate
Return the label (for metrics collection).
-
getUpdateStatement
public String getUpdateStatement()
Description copied from interface:SpiUpdate
Return the update statement. This could be either sql or an orm update with bean types and property names.- Specified by:
getUpdateStatement
in interfaceSpiUpdate<T>
-
set
public DefaultOrmUpdate<T> set(int position, Object value)
Description copied from interface:Update
Set an ordered bind parameter.position starts at value 1 (not 0) to be consistent with PreparedStatement.
Set a value for each ? you have in the sql.
-
setParameter
public DefaultOrmUpdate<T> setParameter(int position, Object value)
Description copied from interface:Update
Set and ordered bind parameter (same as bind).- Specified by:
setParameter
in interfaceUpdate<T>
- Parameters:
position
- the index position of the parameter starting with 1.value
- the parameter value to bind.
-
setNull
public DefaultOrmUpdate<T> setNull(int position, int jdbcType)
Description copied from interface:Update
Set an ordered parameter that is null. The JDBC type of the null must be specified.position starts at value 1 (not 0) to be consistent with PreparedStatement.
-
setNullParameter
public DefaultOrmUpdate<T> setNullParameter(int position, int jdbcType)
Description copied from interface:Update
Set an ordered parameter that is null (same as bind).- Specified by:
setNullParameter
in interfaceUpdate<T>
-
set
public DefaultOrmUpdate<T> set(String name, Object value)
Description copied from interface:Update
Set a named parameter. Named parameters have a colon to prefix the name.A more succinct version of setParameter() to be consistent with Query.
-
setParameter
public DefaultOrmUpdate<T> setParameter(String name, Object param)
Description copied from interface:Update
Bind a named parameter (same as bind).- Specified by:
setParameter
in interfaceUpdate<T>
-
setNull
public DefaultOrmUpdate<T> setNull(String name, int jdbcType)
Description copied from interface:Update
Set a named parameter that is null. The JDBC type of the null must be specified.A more succinct version of setNullParameter().
-
setNullParameter
public DefaultOrmUpdate<T> setNullParameter(String name, int jdbcType)
Description copied from interface:Update
Bind a named parameter that is null (same as bind).- Specified by:
setNullParameter
in interfaceUpdate<T>
-
getBindParams
public BindParams getBindParams()
Return the bind parameters.- Specified by:
getBindParams
in interfaceSpiUpdate<T>
-
getGeneratedSql
public String getGeneratedSql()
Description copied from interface:Update
Return the sql that is actually executed.- Specified by:
getGeneratedSql
in interfaceUpdate<T>
-
setGeneratedSql
public void setGeneratedSql(String generatedSql)
Description copied from interface:SpiUpdate
Set the generated sql used.- Specified by:
setGeneratedSql
in interfaceSpiUpdate<T>
-
getBaseTable
public String getBaseTable()
Description copied from interface:SpiUpdate
Return the name of the table being modified.- Specified by:
getBaseTable
in interfaceSpiUpdate<T>
-
getOrmUpdateType
public SpiUpdate.OrmUpdateType getOrmUpdateType()
Description copied from interface:SpiUpdate
Return the type of this - insert, update or delete.- Specified by:
getOrmUpdateType
in interfaceSpiUpdate<T>
-
-