public interface EbeanServer
Registration with the Ebean Singleton:
When a EbeanServer is constructed it can be registered with the Ebean
singleton (see ServerConfig.setRegister(boolean)). The Ebean
singleton is essentially a map of EbeanServer's that have been registered
with it. The EbeanServer can then be retrieved later via
Ebean.getServer(String).
The 'default' EbeanServer
One EbeanServer can be designated as the 'default' or 'primary' EbeanServer
(see ServerConfig.setDefaultServer(boolean). Many methods on Ebean
such as Ebean.find(Class) etc are actually just a convenient way to
call methods on the 'default/primary' EbeanServer. This is handy for
applications that use a single DataSource.
There is one EbeanServer per Database (javax.sql.DataSource). One EbeanServer
is referred to as the 'default' server and that is the one that
Ebean methods such as Ebean.find(Class) use.
Constructing a EbeanServer
EbeanServer's are constructed by the EbeanServerFactory. They can be created
programmatically via EbeanServerFactory.create(ServerConfig) or they
can be automatically constructed on demand using configuration information in
the ebean.properties file.
Example: Get a EbeanServer
// Get access to the Human Resources EbeanServer/Database
EbeanServer hrServer = Ebean.getServer("HR");
// fetch contact 3 from the HR database Contact contact =
hrServer.find(Contact.class, new Integer(3));
contact.setStatus("INACTIVE"); ...
// save the contact back to the HR database hrServer.save(contact);
EbeanServer has more API than Ebean
EbeanServer provides additional API compared with Ebean. For example it
provides more control over the use of Transactions that is not available in
the Ebean API.
External Transactions: If you wanted to use transactions created externally to eBean then EbeanServer provides additional methods where you can explicitly pass a transaction (that can be created externally).
Bypass ThreadLocal Mechanism: If you want to bypass the built in ThreadLocal transaction management you can use the createTransaction() method. Example: a single thread requires more than one transaction.
Ebean,
EbeanServerFactory,
ServerConfig| Modifier and Type | Method and Description |
|---|---|
Transaction |
beginTransaction()
Start a new transaction putting it into a ThreadLocal.
|
Transaction |
beginTransaction(TxIsolation isolation)
Start a transaction additionally specifying the isolation level.
|
void |
commitTransaction()
Commit the current transaction.
|
CallableSql |
createCallableSql(String callableSql)
Create a CallableSql to execute a given stored procedure.
|
<T> CsvReader<T> |
createCsvReader(Class<T> beanType)
Create a CsvReader for a given beanType.
|
<T> T |
createEntityBean(Class<T> type)
Create a new instance of T that is an EntityBean (for subclassing).
|
JsonContext |
createJsonContext()
Create a JsonContext that will use the default configuration options.
|
<T> Query<T> |
createNamedQuery(Class<T> beanType,
String namedQuery)
Create a named query for an entity bean (refer
Ebean.createQuery(Class, String)) |
SqlQuery |
createNamedSqlQuery(String namedQuery)
Create a named sql query (refer
Ebean.createNamedSqlQuery(String)
). |
SqlUpdate |
createNamedSqlUpdate(String namedQuery)
Create a named sql update (refer
Ebean.createNamedSqlUpdate(String)
). |
<T> Update<T> |
createNamedUpdate(Class<T> beanType,
String namedUpdate)
Create a named update for an entity bean (refer
Ebean.createNamedUpdate(Class, String)). |
<T> Query<T> |
createQuery(Class<T> beanType)
Create a query for an entity bean (refer
Ebean.createQuery(Class)
). |
<T> Query<T> |
createQuery(Class<T> beanType,
String query)
Create a query using the query language.
|
SqlQuery |
createSqlQuery(String sql)
Create a sql query for executing native sql query statements (refer
Ebean.createSqlQuery(String)). |
SqlUpdate |
createSqlUpdate(String sql)
Create a sql update for executing native dml statements (refer
Ebean.createSqlUpdate(String)). |
Transaction |
createTransaction()
Create a new transaction that is not held in TransactionThreadLocal.
|
Transaction |
createTransaction(TxIsolation isolation)
Create a new transaction additionally specifying the isolation level.
|
<T> Update<T> |
createUpdate(Class<T> beanType,
String ormUpdate)
Create a update for an entity bean where you will manually specify the
insert update or delete statement.
|
Transaction |
currentTransaction()
Returns the current transaction or null if there is no current transaction
in scope.
|
void |
delete(Class<?> beanType,
Collection<?> ids)
Delete several beans given their type and id values.
|
void |
delete(Class<?> beanType,
Collection<?> ids,
Transaction t)
Delete several beans given their type and id values with an explicit
transaction.
|
int |
delete(Class<?> beanType,
Object id)
Delete the bean given its type and id.
|
int |
delete(Class<?> beanType,
Object id,
Transaction t)
Delete the bean given its type and id with an explicit transaction.
|
int |
delete(Collection<?> c)
Delete all the beans in the collection.
|
int |
delete(Iterator<?> it)
Delete all the beans from an Iterator.
|
int |
delete(Iterator<?> it,
Transaction t)
Delete all the beans from an iterator.
|
void |
delete(Object bean)
Delete the bean.
|
void |
delete(Object bean,
Transaction t)
Delete the bean with an explicit transaction.
|
int |
deleteManyToManyAssociations(Object ownerBean,
String propertyName)
Delete the associations (from the intersection table) of a ManyToMany given
the owner bean and the propertyName of the ManyToMany collection.
|
int |
deleteManyToManyAssociations(Object ownerBean,
String propertyName,
Transaction t)
Delete the associations (from the intersection table) of a ManyToMany given
the owner bean and the propertyName of the ManyToMany collection.
|
Map<String,ValuePair> |
diff(Object a,
Object b)
Return a map of the differences between two objects of the same type.
|
void |
endTransaction()
If the current transaction has already been committed do nothing otherwise
rollback the transaction.
|
int |
execute(CallableSql callableSql)
Call a stored procedure.
|
int |
execute(CallableSql callableSql,
Transaction t)
Execute explicitly passing a transaction.
|
int |
execute(SqlUpdate updSql)
Execute a SQL Update Delete or Insert statement using the current
transaction.
|
int |
execute(SqlUpdate updSql,
Transaction t)
Execute explicitly passing a transaction.
|
<T> T |
execute(TxCallable<T> c)
Execute a TxCallable in a Transaction with the default scope.
|
void |
execute(TxRunnable r)
Execute a TxRunnable in a Transaction with the default scope.
|
<T> T |
execute(TxScope scope,
TxCallable<T> c)
Execute a TxCallable in a Transaction with an explicit scope.
|
void |
execute(TxScope scope,
TxRunnable r)
Execute a TxRunnable in a Transaction with an explicit scope.
|
int |
execute(Update<?> update)
Execute a ORM insert update or delete statement using the current
transaction.
|
int |
execute(Update<?> update,
Transaction t)
Execute a ORM insert update or delete statement with an explicit
transaction.
|
void |
externalModification(String tableName,
boolean inserted,
boolean updated,
boolean deleted)
Process committed changes from another framework.
|
<T> Filter<T> |
filter(Class<T> beanType)
Create a filter for filtering lists of entity beans.
|
<T> Query<T> |
find(Class<T> beanType)
Create a query for a type of entity bean (the same as
createQuery(Class)). |
<T> T |
find(Class<T> beanType,
Object uid)
Find a bean using its unique id.
|
<T> T |
find(Class<T> beanType,
Object uid,
Transaction transaction)
Find a entity bean with an explicit transaction.
|
<T> FutureIds<T> |
findFutureIds(Query<T> query,
Transaction t)
Execute find Id's query in a background thread.
|
<T> FutureList<T> |
findFutureList(Query<T> query,
Transaction t)
Execute find list query in a background thread.
|
SqlFutureList |
findFutureList(SqlQuery query,
Transaction t)
Execute find list SQL query in a background thread.
|
<T> FutureRowCount<T> |
findFutureRowCount(Query<T> query,
Transaction t)
Execute find row count query in a background thread.
|
<T> List<Object> |
findIds(Query<T> query,
Transaction t)
Return the Id values of the query as a List.
|
<T> QueryIterator<T> |
findIterate(Query<T> query,
Transaction t)
Return a QueryIterator for the query.
|
<T> List<T> |
findList(Query<T> query,
Transaction transaction)
Execute a query returning a list of beans.
|
List<SqlRow> |
findList(SqlQuery query,
Transaction transaction)
Execute the sql query returning a list of MapBean.
|
<T> Map<?,T> |
findMap(Query<T> query,
Transaction transaction)
Execute the query returning the entity beans in a Map.
|
Map<?,SqlRow> |
findMap(SqlQuery query,
Transaction transaction)
Execute the sql query returning a map of MapBean.
|
<T> PagingList<T> |
findPagingList(Query<T> query,
Transaction t,
int pageSize)
Find using a PagingList with explicit transaction and pageSize.
|
<T> int |
findRowCount(Query<T> query,
Transaction transaction)
Return the number of 'top level' or 'root' entities this query should
return.
|
<T> Set<T> |
findSet(Query<T> query,
Transaction transaction)
Execute the query returning a set of entity beans.
|
Set<SqlRow> |
findSet(SqlQuery query,
Transaction transaction)
Execute the sql query returning a set of MapBean.
|
<T> T |
findUnique(Query<T> query,
Transaction transaction)
Execute the query returning at most one entity bean.
|
SqlRow |
findUnique(SqlQuery query,
Transaction transaction)
Execute the sql query returning a single MapBean or null.
|
<T> void |
findVisit(Query<T> query,
QueryResultVisitor<T> visitor,
Transaction t)
Execute the query visiting the results.
|
AdminAutofetch |
getAdminAutofetch()
Return the AdminAutofetch which is used to control and configure the
Autofetch service at runtime.
|
BackgroundExecutor |
getBackgroundExecutor()
Return the BackgroundExecutor service for asynchronous processing of
queries.
|
Object |
getBeanId(Object bean)
Return the value of the Id property for a given bean.
|
BeanState |
getBeanState(Object bean)
Return the BeanState for a given entity bean.
|
ExpressionFactory |
getExpressionFactory()
Return the ExpressionFactory for this server.
|
MetaInfoManager |
getMetaInfoManager()
Return the MetaInfoManager which is used to get meta data from the EbeanServer
such as query execution statistics.
|
String |
getName()
Return the name.
|
<T> T |
getReference(Class<T> beanType,
Object uid)
Get a reference Object (see
Ebean.getReference(Class, Object). |
ServerCacheManager |
getServerCacheManager()
Return the manager of the server cache ("L2" cache).
|
void |
insert(Object bean)
Force the bean to be saved with an explicit insert.
|
void |
insert(Object bean,
Transaction t)
Force the bean to be saved with an explicit insert.
|
Object |
nextId(Class<?> beanType)
Return the next unique identity value for a given bean type.
|
void |
refresh(Object bean)
Refresh the values of a bean.
|
void |
refreshMany(Object bean,
String propertyName)
Refresh a many property of an entity bean.
|
void |
rollbackTransaction()
Rollback the current transaction.
|
void |
runCacheWarming()
Run the cache warming queries on all bean types that have one defined.
|
void |
runCacheWarming(Class<?> beanType)
Run the cache warming query for a specific bean type.
|
int |
save(Collection<?> it)
Save all the beans in the collection.
|
int |
save(Iterator<?> it)
Save all the beans in the iterator.
|
int |
save(Iterator<?> it,
Transaction t)
Save all the beans in the iterator with an explicit transaction.
|
void |
save(Object bean)
Persist the bean by either performing an insert or update.
|
void |
save(Object bean,
Transaction t)
Insert or update a bean with an explicit transaction.
|
void |
saveAssociation(Object ownerBean,
String propertyName)
Save the associated collection or bean given the property name.
|
void |
saveAssociation(Object ownerBean,
String propertyName,
Transaction t)
Save the associated collection or bean given the property name with a
specific transaction.
|
void |
saveManyToManyAssociations(Object ownerBean,
String propertyName)
Save the associations of a ManyToMany given the owner bean and the
propertyName of the ManyToMany collection.
|
void |
saveManyToManyAssociations(Object ownerBean,
String propertyName,
Transaction t)
Save the associations of a ManyToMany given the owner bean and the
propertyName of the ManyToMany collection.
|
void |
shutdown(boolean shutdownDataSource,
boolean deregisterDriver)
Shutdown the EbeanServer.
|
<T> void |
sort(List<T> list,
String sortByClause)
Sort the list using the sortByClause.
|
void |
update(Object bean)
Force an update using the bean.
|
void |
update(Object bean,
Set<String> updateProps)
Force an update using the bean explicitly stating the properties to update.
|
void |
update(Object bean,
Set<String> updateProps,
Transaction t)
Force an update of the specified properties of the bean with an explicit
transaction.
|
void |
update(Object bean,
Set<String> updateProps,
Transaction t,
boolean deleteMissingChildren,
boolean updateNullProperties)
Force an update additionally specifying whether to 'deleteMissingChildren'
when the update cascades to a OneToMany or ManyToMany.
|
void |
update(Object bean,
Transaction t)
Force an update of the non-null properties of the bean with an explicit
transaction.
|
void shutdown(boolean shutdownDataSource,
boolean deregisterDriver)
If the under underlying DataSource is the EbeanORM implementation then you also have the option of shutting down the DataSource and deregistering the JDBC driver.
shutdownDataSource - if true then shutdown the underlying DataSource if it is the EbeanORM
DataSource implementation.deregisterDriver - if true then deregister the JDBC driver if it is the EbeanORM
DataSource implementation.AdminAutofetch getAdminAutofetch()
String getName()
Ebean.getServer(String) to get a
EbeanServer that was registered with the Ebean singleton.ExpressionFactory getExpressionFactory()
MetaInfoManager getMetaInfoManager()
BeanState getBeanState(Object bean)
This will return null if the bean is not an enhanced (or subclassed) entity bean.
Map<String,ValuePair> diff(Object a, Object b)
When null is passed in for b, then the 'OldValues' of a is used for the difference comparison.
<T> T createEntityBean(Class<T> type)
Note that if you are using enhancement (rather than subclassing) then you do not need to use this method and just new up a bean.
Potentially useful when using subclassing and you wish to programmatically load a entity bean . Otherwise this method is generally not required.
<T> CsvReader<T> createCsvReader(Class<T> beanType)
<T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery)
Ebean.createQuery(Class, String))
The query statement will be defined in a deployment orm xml file.
Ebean.createQuery(Class, String)<T> Query<T> createQuery(Class<T> beanType, String query)
Note that you are allowed to add additional clauses using where() as well as use fetch() and setOrderBy() after the query has been created.
Note that this method signature used to map to named queries and that has
moved to createNamedQuery(Class, String).
EbeanServer ebeanServer = ... ;
String q = "find order fetch details where status = :st";
List<Order> newOrders
= ebeanServer.createQuery(Order.class, q)
.setParameter("st", Order.Status.NEW)
.findList();
query - the object query<T> Query<T> createQuery(Class<T> beanType)
Ebean.createQuery(Class)
).Ebean.createQuery(Class)<T> Query<T> find(Class<T> beanType)
createQuery(Class)).Object nextId(Class<?> beanType)
This will only work when a IdGenerator is on the bean such as for beans that use a DB sequence or UUID.
For DB's supporting getGeneratedKeys and sequences such as Oracle10 you do not need to use this method generally. It is made available for more complex cases where it is useful to get an ID prior to some processing.
<T> void sort(List<T> list, String sortByClause)
list - the list of entity beanssortByClause - the properties to sort the list byEbean.sort(List, String)<T> Update<T> createNamedUpdate(Class<T> beanType, String namedUpdate)
Ebean.createNamedUpdate(Class, String)).<T> Update<T> createUpdate(Class<T> beanType, String ormUpdate)
SqlQuery createSqlQuery(String sql)
Ebean.createSqlQuery(String)).Ebean.createSqlQuery(String)SqlQuery createNamedSqlQuery(String namedQuery)
Ebean.createNamedSqlQuery(String)
).
The query statement will be defined in a deployment orm xml file.
Ebean.createNamedSqlQuery(String)SqlUpdate createSqlUpdate(String sql)
Ebean.createSqlUpdate(String)).Ebean.createSqlUpdate(String)CallableSql createCallableSql(String callableSql)
SqlUpdate createNamedSqlUpdate(String namedQuery)
Ebean.createNamedSqlUpdate(String)
).
The statement (an Insert Update or Delete statement) will be defined in a deployment orm xml file.
Ebean.createNamedSqlUpdate(String)Transaction createTransaction()
You will want to do this if you want multiple Transactions in a single thread or generally use transactions outside of the TransactionThreadLocal management.
Transaction createTransaction(TxIsolation isolation)
Note that this transaction is NOT stored in a thread local.
Transaction beginTransaction()
Ebean.beginTransaction()Transaction beginTransaction(TxIsolation isolation)
Transaction currentTransaction()
void commitTransaction()
Ebean.commitTransaction()void rollbackTransaction()
Ebean.rollbackTransaction()void endTransaction()
Useful to put in a finally block to ensure the transaction is ended, rather than a rollbackTransaction() in each catch block.
Code example:
Ebean.startTransaction(); try { // do some fetching
and or persisting
// commit at the end Ebean.commitTransaction();
} finally { // if commit didn't occur then rollback the transaction
Ebean.endTransaction(); }
Ebean.endTransaction()void refresh(Object bean)
Note that this does not refresh any OneToMany or ManyToMany properties.
Ebean.refresh(Object)void refreshMany(Object bean, String propertyName)
bean - the entity bean containing the 'many' propertypropertyName - the 'many' property to be refreshedEbean.refreshMany(Object, String)<T> T find(Class<T> beanType, Object uid)
Ebean.find(Class, Object)<T> T getReference(Class<T> beanType, Object uid)
Ebean.getReference(Class, Object).
This will not perform a query against the database.
Ebean.getReference(Class, Object)<T> int findRowCount(Query<T> query, Transaction transaction)
<T> List<Object> findIds(Query<T> query, Transaction t)
<T> QueryIterator<T> findIterate(Query<T> query, Transaction t)
<T> void findVisit(Query<T> query, QueryResultVisitor<T> visitor, Transaction t)
<T> List<T> findList(Query<T> query, Transaction transaction)
Generally you are able to use Query.findList() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
T - the type of entity bean to fetch.query - the query to execute.transaction - the transaction to use (can be null).Query.findList()<T> FutureRowCount<T> findFutureRowCount(Query<T> query, Transaction t)
This returns a Future object which can be used to cancel, check the execution status (isDone etc) and get the value (with or without a timeout).
query - the query to execute the row count ont - the transaction (can be null).<T> FutureIds<T> findFutureIds(Query<T> query, Transaction t)
This returns a Future object which can be used to cancel, check the execution status (isDone etc) and get the value (with or without a timeout).
query - the query to execute the fetch Id's ont - the transaction (can be null).<T> FutureList<T> findFutureList(Query<T> query, Transaction t)
This returns a Future object which can be used to cancel, check the execution status (isDone etc) and get the value (with or without a timeout).
query - the query to execute in the backgroundt - the transaction (can be null).SqlFutureList findFutureList(SqlQuery query, Transaction t)
This returns a Future object which can be used to cancel, check the execution status (isDone etc) and get the value (with or without a timeout).
query - the query to execute in the backgroundt - the transaction (can be null).<T> PagingList<T> findPagingList(Query<T> query, Transaction t, int pageSize)
<T> Set<T> findSet(Query<T> query, Transaction transaction)
Generally you are able to use Query.findSet() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
T - the type of entity bean to fetch.query - the query to executetransaction - the transaction to use (can be null).Query.findSet()<T> Map<?,T> findMap(Query<T> query, Transaction transaction)
Generally you are able to use Query.findMap() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
T - the type of entity bean to fetch.query - the query to execute.transaction - the transaction to use (can be null).Query.findMap()<T> T findUnique(Query<T> query, Transaction transaction)
Generally you are able to use Query.findUnique() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
T - the type of entity bean to fetch.query - the query to execute.transaction - the transaction to use (can be null).Query.findUnique()List<SqlRow> findList(SqlQuery query, Transaction transaction)
Generally you are able to use SqlQuery.findList() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
query - the query to execute.transaction - the transaction to use (can be null).SqlQuery.findList()Set<SqlRow> findSet(SqlQuery query, Transaction transaction)
Generally you are able to use SqlQuery.findSet() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
query - the query to execute.transaction - the transaction to use (can be null).SqlQuery.findSet()Map<?,SqlRow> findMap(SqlQuery query, Transaction transaction)
Generally you are able to use SqlQuery.findMap() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
query - the query to execute.transaction - the transaction to use (can be null).SqlQuery.findMap()SqlRow findUnique(SqlQuery query, Transaction transaction)
This will throw a PersistenceException if the query found more than one result.
Generally you are able to use SqlQuery.findUnique() rather than
explicitly calling this method. You could use this method if you wish to
explicitly control the transaction used for the query.
query - the query to execute.transaction - the transaction to use (can be null).SqlQuery.findUnique()void save(Object bean) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionEbean.save(Object)int save(Iterator<?> it) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionint save(Collection<?> it) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionvoid delete(Object bean) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionEbean.delete(Object)int delete(Iterator<?> it) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionint delete(Collection<?> c) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionint delete(Class<?> beanType, Object id, Transaction t)
void delete(Class<?> beanType, Collection<?> ids)
void delete(Class<?> beanType, Collection<?> ids, Transaction t)
int execute(SqlUpdate updSql)
Refer to Ebean.execute(UpdateSql) for full documentation.
Ebean.execute(SqlUpdate)int execute(Update<?> update)
This returns the number of rows that where inserted, updated or deleted.
int execute(Update<?> update, Transaction t)
int execute(CallableSql callableSql)
Refer to Ebean.execute(CallableSql) for full documentation.
Ebean.execute(CallableSql)void externalModification(String tableName, boolean inserted, boolean updated, boolean deleted)
This notifies this instance of the framework that beans have been committed externally to it. Either by another framework or clustered server. It uses this to maintain its cache and text indexes appropriately.
<T> T find(Class<T> beanType, Object uid, Transaction transaction)
T - the type of entity bean to findbeanType - the type of entity bean to finduid - the bean id valuetransaction - the transaction to use (can be null)void save(Object bean, Transaction t) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionint save(Iterator<?> it, Transaction t) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionvoid update(Object bean)
You can use this method to FORCE an update to occur (even on a bean that
has not been fetched but say built from JSON or XML). When
save(Object) is used Ebean determines whether to use an
insert or an update based on the state of the bean. Using this method will
force an update to occur.
It is expected that this method is most useful in stateless REST services or web applications where you have the values you wish to update but no existing bean.
For updates against beans that have not been fetched (say built from JSON
or XML) this will treat deleteMissingChildren=true and will delete any
'missing children'. Refer to
update(Object, Set, Transaction, boolean, boolean).
Customer c = new Customer();
c.setId(7);
c.setName("ModifiedNameNoOCC");
// generally you should set the version property
// so that Optimistic Concurrency Checking is used.
// If a version property is not set then no Optimistic
// Concurrency Checking occurs for the update
// c.setLastUpdate(lastUpdateTime);
// by default the Non-null properties
// are included in the update
ebeanServer.update(c);
void update(Object bean, Transaction t)
You can use this method to FORCE an update to occur (even on a bean that
has not been fetched but say built from JSON or XML). When
save(Object) is used Ebean determines whether to use an
insert or an update based on the state of the bean. Using this method will
force an update to occur.
It is expected that this method is most useful in stateless REST services or web applications where you have the values you wish to update but no existing bean.
For updates against beans that have not been fetched (say built from JSON
or XML) this will treat deleteMissingChildren=true and will delete any
'missing children'. Refer to
update(Object, Set, Transaction, boolean, boolean).
void update(Object bean, Set<String> updateProps)
You can use this method to FORCE an update to occur (even on a bean that
has not been fetched but say built from JSON or XML). When
save(Object) is used Ebean determines whether to use an
insert or an update based on the state of the bean. Using this method will
force an update to occur.
It is expected that this method is most useful in stateless REST services or web applications where you have the values you wish to update but no existing bean.
For updates against beans that have not been fetched (say built from JSON
or XML) this will treat deleteMissingChildren=true and will delete any
'missing children'. Refer to
update(Object, Set, Transaction, boolean, boolean).
Customer c = new Customer();
c.setId(7);
c.setName("ModifiedNameNoOCC");
// generally you should set the version property
// so that Optimistic Concurrency Checking is used.
// If a version property is not set then no Optimistic
// Concurrency Checking occurs for the update
// c.setLastUpdate(lastUpdateTime);
// by default the Non-null properties
// are included in the update
ebeanServer.update(c);
void update(Object bean, Set<String> updateProps, Transaction t)
You can use this method to FORCE an update to occur (even on a bean that
has not been fetched but say built from JSON or XML). When
save(Object) is used Ebean determines whether to use an
insert or an update based on the state of the bean. Using this method will
force an update to occur.
It is expected that this method is most useful in stateless REST services or web applications where you have the values you wish to update but no existing bean.
For updates against beans that have not been fetched (say built from JSON
or XML) this will treat deleteMissingChildren=true and will delete any
'missing children'. Refer to
update(Object, Set, Transaction, boolean, boolean).
void update(Object bean, Set<String> updateProps, Transaction t, boolean deleteMissingChildren, boolean updateNullProperties)
By default the deleteMissingChildren is true and it is assumed that when cascade saving a O2M or M2M relationship that the relationship is 'fully loaded' and any child beans that are no longer on the relationship will be deleted.
You can use this method to FORCE an update to occur (even on a bean that
has not been fetched but say built from JSON or XML). When
save(Object) is used Ebean determines whether to use an
insert or an update based on the state of the bean. Using this method will
force an update to occur.
It is expected that this method is most useful in stateless REST services or web applications where you have the values you wish to update but no existing bean.
bean - the bean to updateupdateProps - optionally you can specify the properties to update (can be null).t - optionally you can specify the transaction to use (can be null).deleteMissingChildren - specify false if you do not want 'missing children' of a OneToMany
or ManyToMany to be automatically deleted.updateNullProperties - specify true if by default you want properties with null values to
be included in the update and false if those properties should be
treated as 'unloaded' and excluded from the update. This only
takes effect if the updateProps is null.void insert(Object bean)
Typically you would use save() and let Ebean determine if the bean should be inserted or updated. This can be useful when you are transferring data between databases and want to explicitly insert a bean into a different database that it came from.
void insert(Object bean, Transaction t)
Typically you would use save() and let Ebean determine if the bean should be inserted or updated. This can be useful when you are transferring data between databases and want to explicitly insert a bean into a different database that it came from.
int deleteManyToManyAssociations(Object ownerBean, String propertyName)
Typically these deletions occur automatically when persisting a ManyToMany collection and this provides a way to invoke those deletions directly.
int deleteManyToManyAssociations(Object ownerBean, String propertyName, Transaction t)
Additionally specify a transaction to use.
Typically these deletions occur automatically when persisting a ManyToMany collection and this provides a way to invoke those deletions directly.
void saveManyToManyAssociations(Object ownerBean, String propertyName)
Typically the saving of these associations (inserting into the intersection table) occurs automatically when persisting a ManyToMany. This provides a way to invoke those insertions directly.
void saveManyToManyAssociations(Object ownerBean, String propertyName, Transaction t)
Typically the saving of these associations (inserting into the intersection table) occurs automatically when persisting a ManyToMany. This provides a way to invoke those insertions directly.
void saveAssociation(Object ownerBean, String propertyName)
This is similar to performing a save cascade on a specific property manually.
Note that you can turn on/off cascading for a transaction via
Transaction.setPersistCascade(boolean)
ownerBean - the bean instance holding the property we want to savepropertyName - the property we want to savevoid saveAssociation(Object ownerBean, String propertyName, Transaction t)
This is similar to performing a save cascade on a specific property manually.
Note that you can turn on/off cascading for a transaction via
Transaction.setPersistCascade(boolean)
ownerBean - the bean instance holding the property we want to savepropertyName - the property we want to savevoid delete(Object bean, Transaction t) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionint delete(Iterator<?> it, Transaction t) throws javax.persistence.OptimisticLockException
javax.persistence.OptimisticLockExceptionint execute(SqlUpdate updSql, Transaction t)
int execute(CallableSql callableSql, Transaction t)
void execute(TxScope scope, TxRunnable r)
The scope can control the transaction type, isolation and rollback semantics.
void execute(TxRunnable r)
The default scope runs with REQUIRED and by default will rollback on any exception (checked or runtime).
<T> T execute(TxScope scope, TxCallable<T> c)
The scope can control the transaction type, isolation and rollback semantics.
<T> T execute(TxCallable<T> c)
The default scope runs with REQUIRED and by default will rollback on any exception (checked or runtime).
ServerCacheManager getServerCacheManager()
BackgroundExecutor getBackgroundExecutor()
void runCacheWarming()
A cache warming query can be defined via CacheStrategy.
void runCacheWarming(Class<?> beanType)
A cache warming query can be defined via CacheStrategy.
JsonContext createJsonContext()
Copyright © 2014. All Rights Reserved.