|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- the type of entity beans inserted updated or deletedpublic interface Update<T>
An Insert Update or Delete statement.
Generally a named update will be defined on the entity bean. This will take the form of either an actual sql insert update delete statement or a similar statement with bean name and property names in place of database table and column names. The statement will likely include named parameters.
The following is an example of named updates on an entity bean.
... @NamedUpdates(value = { @NamedUpdate( name = "setTitle", notifyCache = false, update = "update topic set title = :title, postCount = :count where id = :id"), @NamedUpdate( name = "setPostCount", notifyCache = false, update = "update f_topic set post_count = :postCount where id = :id"), @NamedUpdate( name = "incrementPostCount", notifyCache = false, update = "update Topic set postCount = postCount + 1 where id = :id") //update = "update f_topic set post_count = post_count + 1 where id = :id") }) @Entity @Table(name = "f_topic") public class Topic { ...
The following show code that would use a named update on the Topic entity bean.
Update<Topic> update = Ebean.createUpdate(Topic.class, "incrementPostCount"); update.setParameter("id", 1); int rows = update.execute();
Method Summary | |
---|---|
int |
execute()
Execute the statement returning the number of rows modified. |
String |
getGeneratedSql()
Return the sql that is actually executed. |
String |
getName()
Return the name if it is a named update. |
Update<T> |
set(int position,
Object value)
Set an ordered bind parameter. |
Update<T> |
set(String name,
Object value)
Set a named parameter. |
Update<T> |
setNotifyCache(boolean notifyCache)
Set this to false if you do not want the cache to invalidate related objects. |
Update<T> |
setNull(int position,
int jdbcType)
Set an ordered parameter that is null. |
Update<T> |
setNull(String name,
int jdbcType)
Set a named parameter that is null. |
Update<T> |
setNullParameter(int position,
int jdbcType)
Set an ordered parameter that is null (same as bind). |
Update<T> |
setNullParameter(String name,
int jdbcType)
Bind a named parameter that is null (same as bind). |
Update<T> |
setParameter(int position,
Object value)
Set and ordered bind parameter (same as bind). |
Update<T> |
setParameter(String name,
Object param)
Bind a named parameter (same as bind). |
Update<T> |
setTimeout(int secs)
Set a timeout for statement execution. |
Method Detail |
---|
String getName()
Update<T> setNotifyCache(boolean notifyCache)
If you don't set this Ebean will automatically invalidate the appropriate parts of the "L2" server cache.
Update<T> setTimeout(int secs)
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.
secs
- the timeout in seconds. Zero implies unlimited.int execute()
Update<T> set(int position, Object value)
position starts at value 1 (not 0) to be consistent with PreparedStatement.
Set a value for each ? you have in the sql.
position
- the index position of the parameter starting with 1.value
- the parameter value to bind.Update<T> setParameter(int position, Object value)
position
- the index position of the parameter starting with 1.value
- the parameter value to bind.Update<T> setNull(int position, int jdbcType)
position starts at value 1 (not 0) to be consistent with PreparedStatement.
Update<T> setNullParameter(int position, int jdbcType)
Update<T> set(String name, Object value)
A more succinct version of setParameter() to be consistent with Query.
name
- the parameter name.value
- the parameter value.Update<T> setParameter(String name, Object param)
Update<T> setNull(String name, int jdbcType)
A more succinct version of setNullParameter().
name
- the parameter name.jdbcType
- the type of the property being bound.Update<T> setNullParameter(String name, int jdbcType)
String getGeneratedSql()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |