Liferay 6.1.2-ce-ga3

com.liferay.portal.service.persistence
Interface BatchSession


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

delete

void delete(Session session,
            BaseModel<?> model)
            throws ORMException
Deletes the model instance in the database, and possibly flushes the session.

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.

Parameters:
session - the session to perform the update on
model - the model instance to update
Throws:
ORMException - if a database exception occurred

isEnabled

boolean isEnabled()
Returns true if update batching is enabled

Returns:
true if update batching is enabled; false otherwise

setEnabled

void setEnabled(boolean enabled)
Sets whether update batching is enabled.

Parameters:
enabled - whether update batching is enabled.

update

void update(Session session,
            BaseModel<?> model,
            boolean merge)
            throws ORMException
Updates the model instance in the database or adds it if it does not yet exist, and possibly flushes the session.

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.

Parameters:
session - the session
model - the model instance
merge - whether to merge the model instance with the current session
Throws:
ORMException - if a database exception occurred

Liferay 6.1.2-ce-ga3