|
Liferay 6.1.2-ce-ga3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface BatchSession
Tracks database updates and flushes them from the session in batches.
Although all database updates ultimately pass through this class, its
batching functionality is only used for large sets of contiguous updates. For
usage examples see com.liferay.portal.service.impl.LayoutLocalServiceImpl#importLayouts(long,
long, boolean, java.util.Map, java.io.File)
, com.liferay.portal.verify.VerifyProcessUtil#verifyProcess(boolean, boolean)
, and com.liferay.portal.convert.ConvertPermissionAlgorithm#doConvert()
.
Method Summary | |
---|---|
void |
delete(Session session,
BaseModel<?> model)
Deletes the model instance in the database, and possibly flushes the session. |
boolean |
isEnabled()
Returns true if update batching is enabled |
void |
setEnabled(boolean enabled)
Sets whether update batching is enabled. |
void |
update(Session session,
BaseModel<?> model,
boolean merge)
Updates the model instance in the database or adds it if it does not yet exist, and possibly flushes the session. |
Method Detail |
---|
void delete(Session session, BaseModel<?> model) throws ORMException
The session will be flushed if one of the following is true
:
The batch size may be set in portal.properties with the key
hibernate.jdbc.batch_size
.
session
- the session to perform the update onmodel
- the model instance to update
ORMException
- if a database exception occurredboolean isEnabled()
true
if update batching is enabled
true
if update batching is enabled;
false
otherwisevoid setEnabled(boolean enabled)
enabled
- whether update batching is enabled.void update(Session session, BaseModel<?> model, boolean merge) throws ORMException
The session will be flushed if one of the following is true
:
The batch size may be set in portal.properties with the key
hibernate.jdbc.batch_size
.
The merge
parameter controls a special case of persistence.
If the session that a model instance was originally loaded from is
closed, that instance becomes "detached", and changes to it
will not be persisted automatically. To persist its changes, the detached
instance must be merged with the current session. This will load a new
copy of the model instance from the database, copy the changes to it, and
persist it.
This process is most commonly necessary if a model instance is modified
in the controller or view, as the database session is closed when control
leaves the model layer. However, local service update model methods use
merging by default, so in most cases this nuance is handled
automatically. See UserLocalService.updateUser(
com.liferay.portal.model.User)
for an example.
session
- the sessionmodel
- the model instancemerge
- whether to merge the model instance with the current
session
ORMException
- if a database exception occurred
|
Liferay 6.1.2-ce-ga3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |