Liferay 6.0.5

com.liferay.portal.service.persistence
Class BatchSessionImpl

java.lang.Object
  extended by com.liferay.portal.service.persistence.BatchSessionImpl
All Implemented Interfaces:
BatchSession

public class BatchSessionImpl
extends Object
implements BatchSession


Constructor Summary
BatchSessionImpl()
           
 
Method Summary
 boolean isEnabled()
          Determines 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchSessionImpl

public BatchSessionImpl()
Method Detail

isEnabled

public boolean isEnabled()
Description copied from interface: BatchSession
Determines if update batching is enabled

Specified by:
isEnabled in interface BatchSession
Returns:
true if update batching is enabled; false otherwise

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: BatchSession
Sets whether update batching is enabled.

Specified by:
setEnabled in interface BatchSession
Parameters:
enabled - whether update batching is enabled.

update

public void update(Session session,
                   BaseModel<?> model,
                   boolean merge)
            throws ORMException
Description copied from interface: BatchSession
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.

Specified by:
update in interface BatchSession
Parameters:
session - the session to perform the update on
model - the model instance to update
merge - whether to merge the model instance with the current session
Throws:
ORMException - if a database exception occurred

Liferay 6.0.5