Liferay 6.1.2-ce-ga3

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
 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.
 
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

delete

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

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

isEnabled

public boolean isEnabled()
Description copied from interface: BatchSession
Returns true 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
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