|
Liferay 6.0.4 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.liferay.portal.service.persistence.impl.BasePersistenceImpl<T>
public class BasePersistenceImpl<T extends BaseModel<T>>
The base implementation for all persistence classes.
Caching information and settings can be found in
portal.properties
| Field Summary | |
|---|---|
static String |
COUNT_COLUMN_NAME
|
protected ModelListener<T>[] |
listeners
|
protected static String |
ORDER_BY_ASC
|
protected static String |
ORDER_BY_ASC_HAS_NEXT
|
protected static String |
ORDER_BY_CLAUSE
|
protected static String |
ORDER_BY_DESC
|
protected static String |
ORDER_BY_DESC_HAS_NEXT
|
protected static String |
WHERE_AND
|
protected static String |
WHERE_GREATER_THAN
|
protected static String |
WHERE_GREATER_THAN_HAS_NEXT
|
protected static String |
WHERE_LESSER_THAN
|
protected static String |
WHERE_LESSER_THAN_HAS_NEXT
|
protected static String |
WHERE_OR
|
| Constructor Summary | |
|---|---|
BasePersistenceImpl()
|
|
| Method Summary | |
|---|---|
protected void |
appendOrderByComparator(StringBundler query,
String entityAlias,
OrderByComparator orderByComparator)
|
void |
clearCache()
Clears the cache for all instances of this model. |
void |
clearCache(T model)
Clears the cache for one instance of this model. |
void |
closeSession(Session session)
|
long |
countWithDynamicQuery(DynamicQuery dynamicQuery)
Counts the number of rows that match the dynamic query. |
T |
fetchByPrimaryKey(Serializable primaryKey)
Finds the model instance with the primary key or returns null if it could not be found. |
T |
findByPrimaryKey(Serializable primaryKey)
Finds the model instance with the primary key or throws a NoSuchModelException if it could not be found. |
List |
findWithDynamicQuery(DynamicQuery dynamicQuery)
Performs a dynamic query on the database and returns the matching rows. |
List |
findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end)
Performs a dynamic query on the database and returns a range of the matching rows. |
List |
findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end,
OrderByComparator orderByComparator)
Performs a dynamic query on the database and returns an ordered range of the matching rows. |
DataSource |
getDataSource()
Gets the data source for this model. |
Dialect |
getDialect()
|
ModelListener<T>[] |
getListeners()
Gets the listeners registered for this model. |
Session |
openNewSession(Connection connection)
|
Session |
openSession()
|
SystemException |
processException(Exception e)
|
void |
registerListener(ModelListener<T> listener)
Registers a new listener for this model. |
T |
remove(Serializable primaryKey)
Removes the model instance with the primary key from the database. |
T |
remove(T model)
Removes the model instance from the database. |
protected T |
removeImpl(T model)
Removes the model instance from the database. |
void |
setDataSource(DataSource dataSource)
Sets the data source for this model. |
void |
setSessionFactory(SessionFactory sessionFactory)
|
void |
unregisterListener(ModelListener<T> listener)
Unregisters the model listener. |
T |
update(T model,
boolean merge)
Updates the model instance in the database or adds it if it does not yet exist. |
T |
update(T model,
boolean merge,
ServiceContext serviceContext)
Updates the model instance in the database or adds it if it does not yet exist, within a different service context. |
protected T |
updateImpl(T model,
boolean merge)
Updates the model instance in the database or adds it if it does not yet exist. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String COUNT_COLUMN_NAME
protected static final String ORDER_BY_ASC
protected static final String ORDER_BY_ASC_HAS_NEXT
protected static final String ORDER_BY_CLAUSE
protected static final String ORDER_BY_DESC
protected static final String ORDER_BY_DESC_HAS_NEXT
protected static final String WHERE_AND
protected static final String WHERE_LESSER_THAN
protected static final String WHERE_LESSER_THAN_HAS_NEXT
protected static final String WHERE_GREATER_THAN
protected static final String WHERE_GREATER_THAN_HAS_NEXT
protected static final String WHERE_OR
protected ModelListener<T extends BaseModel<T>>[] listeners
| Constructor Detail |
|---|
public BasePersistenceImpl()
| Method Detail |
|---|
public void clearCache()
BasePersistence
The EntityCache and FinderCache are both cleared by this
method.
clearCache in interface BasePersistence<T extends BaseModel<T>>public void clearCache(T model)
BasePersistence
The EntityCache and FinderCache are both cleared by this
method.
clearCache in interface BasePersistence<T extends BaseModel<T>>model - the instance of this model to clear the cache forpublic void closeSession(Session session)
closeSession in interface SessionFactory
public long countWithDynamicQuery(DynamicQuery dynamicQuery)
throws SystemException
BasePersistence
countWithDynamicQuery in interface BasePersistence<T extends BaseModel<T>>dynamicQuery - the dynamic query to search with
SystemException - if a system exception occurred
public T fetchByPrimaryKey(Serializable primaryKey)
throws SystemException
BasePersistencenull if it could not be found.
fetchByPrimaryKey in interface BasePersistence<T extends BaseModel<T>>primaryKey - the primary key of the model instance to find
null if an instance of this
model with the primary key could not be found
SystemException - if the primary key is null, or if a
system exception occurred
public T findByPrimaryKey(Serializable primaryKey)
throws NoSuchModelException,
SystemException
BasePersistenceNoSuchModelException if it could not be found.
findByPrimaryKey in interface BasePersistence<T extends BaseModel<T>>primaryKey - the primary key of the model instance to find
NoSuchModelException - if an instance of this model with the
primary key could not be found
SystemException - if the primary key is null, or if a
system exception occurred
public List findWithDynamicQuery(DynamicQuery dynamicQuery)
throws SystemException
BasePersistence
findWithDynamicQuery in interface BasePersistence<T extends BaseModel<T>>dynamicQuery - the dynamic query to search with
SystemException - if a system exception occurred
public List findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end)
throws SystemException
BasePersistence
Useful when paginating results. Returns a maximum of end -
start instances. start and end are not
primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end to QueryUtil.ALL_POS will return the full
result set.
findWithDynamicQuery in interface BasePersistence<T extends BaseModel<T>>dynamicQuery - the dynamic query to search withstart - the lower bound of the range of model instances to returnend - the upper bound of the range of model instances to return
(not inclusive)
SystemException - if a system exception occurredQueryUtil.list(
com.liferay.portal.kernel.dao.orm.Query,
com.liferay.portal.kernel.dao.orm.Dialect, int, int)
public List findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end,
OrderByComparator orderByComparator)
throws SystemException
BasePersistence
Useful when paginating results. Returns a maximum of end -
start instances. start and end are not
primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end to QueryUtil.ALL_POS will return the full
result set.
findWithDynamicQuery in interface BasePersistence<T extends BaseModel<T>>dynamicQuery - the dynamic query to search withstart - the lower bound of the range of model instances to returnend - the upper bound of the range of model instances to return
(not inclusive)orderByComparator - the comparator to order the results by
SystemException - if a system exception occurredpublic DataSource getDataSource()
BasePersistence
getDataSource in interface BasePersistence<T extends BaseModel<T>>BasePersistence.setDataSource(DataSource)public Dialect getDialect()
getDialect in interface SessionFactorypublic ModelListener<T>[] getListeners()
BasePersistence
getListeners in interface BasePersistence<T extends BaseModel<T>>BasePersistence.registerListener(ModelListener)
public Session openNewSession(Connection connection)
throws ORMException
openNewSession in interface SessionFactoryORMException
public Session openSession()
throws ORMException
openSession in interface SessionFactoryORMExceptionpublic SystemException processException(Exception e)
public void registerListener(ModelListener<T> listener)
BasePersistenceA model listener is notified whenever a change is made to an instance of this model, such as when one is added, updated, or removed.
registerListener in interface BasePersistence<T extends BaseModel<T>>listener - the model listener to register
public T remove(Serializable primaryKey)
throws NoSuchModelException,
SystemException
BasePersistence
remove in interface BasePersistence<T extends BaseModel<T>>primaryKey - the primary key of the model instance to remove
NoSuchModelException - if an instance of this model with the
primary key could not be found
SystemException - if a system exception occurred
public T remove(T model)
throws SystemException
BasePersistence
remove in interface BasePersistence<T extends BaseModel<T>>model - the model instance to remove
SystemException - if a system exception occurredpublic void setDataSource(DataSource dataSource)
BasePersistence
setDataSource in interface BasePersistence<T extends BaseModel<T>>dataSource - the data source to use for this modelpublic void setSessionFactory(SessionFactory sessionFactory)
public void unregisterListener(ModelListener<T> listener)
BasePersistence
unregisterListener in interface BasePersistence<T extends BaseModel<T>>listener - the model listener to unregisterBasePersistence.registerListener(ModelListener)
public T update(T model,
boolean merge)
throws SystemException
BasePersistence
Typically not called directly, use local service update model methods
instead. For example, UserLocalServiceUtil.updateUser(
com.liferay.portal.model.User).
update in interface BasePersistence<T extends BaseModel<T>>model - the model instance to updatemerge - whether to merge the model instance with the current
session. See BatchSession.update(com.liferay.portal.kernel.dao.orm.Session,
BaseModel, boolean) for an explanation.
SystemException - if a system exception occurred
public T update(T model,
boolean merge,
ServiceContext serviceContext)
throws SystemException
BasePersistence
update in interface BasePersistence<T extends BaseModel<T>>model - the model instance to updatemerge - whether to merge the model instance with the current
session. See BatchSession.update(com.liferay.portal.kernel.dao.orm.Session,
BaseModel, boolean) for an explanation.serviceContext - the service context to perform the update in
SystemException - if a system exception occurred
protected void appendOrderByComparator(StringBundler query,
String entityAlias,
OrderByComparator orderByComparator)
protected T removeImpl(T model)
throws SystemException
update(BaseModel,
boolean) depends on this method to implement the remove operation; it
only notifies the model listeners.
model - the model instance to remove
SystemException - if a system exception occurred
protected T updateImpl(T model,
boolean merge)
throws SystemException
remove(BaseModel) depends on this method to implement the
update operation; it only notifies the model listeners.
model - the model instance to updatemerge - whether to merge the model instance with the current
session. See BatchSession.update(
com.liferay.portal.kernel.dao.orm.Session, BaseModel, boolean)
for an explanation.
SystemException - if a system exception occurred
|
Liferay 6.0.4 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||