Class BasePersistenceImpl<T extends BaseModel<T>>
- All Implemented Interfaces:
SessionFactory,BasePersistence<T>
Caching information and settings can be found in
portal.properties
- Author:
- Brian Wing Shun Chan, Shuyang Zhou, Peter Fellwock
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final Stringprotected intprotected static EntityCacheprotected static FinderCacheprotected booleanDeprecated.As of Athanasius (7.3.x), with no direct replacementprotected static final Object[]protected booleanDeprecated.As of Athanasius (7.3.x), with no direct replacementprotected static final Comparator<String>Deprecated.As of Mueller (7.2.x), with no direct replacementprotected static final com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.NullModelprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendOrderByComparator(com.liferay.petra.string.StringBundler sb, String entityAlias, OrderByComparator<T> orderByComparator) protected voidappendOrderByComparator(com.liferay.petra.string.StringBundler sb, String entityAlias, OrderByComparator<T> orderByComparator, boolean sqlQuery) voidcacheResult(T model) voidClears the cache for all instances of this model.voidclearCache(List<T> model) Clears the cache for a List instances of this model.voidclearCache(T model) Clears the cache for one instance of this model.voidcloseSession(Session session) longcountWithDynamicQuery(DynamicQuery dynamicQuery) Returns the number of rows that match the dynamic query.longcountWithDynamicQuery(DynamicQuery dynamicQuery, Projection projection) Returns the number of rows that match the dynamic query.<R> RdslQuery(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) fetchByPrimaryKey(Serializable primaryKey) Returns the model instance with the primary key or returnsnullif it could not be found.fetchByPrimaryKeys(Set<Serializable> primaryKeys) findByPrimaryKey(Serializable primaryKey) Returns the model instance with the primary key or throws aNoSuchModelExceptionif it could not be found.<V> List<V>findWithDynamicQuery(DynamicQuery dynamicQuery) Performs a dynamic query on the database and returns the matching rows.<V> List<V>findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end) Performs a dynamic query on the database and returns a range of the matching rows.<V> List<V>findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<V> orderByComparator) Performs a dynamic query on the database and returns an ordered range of the matching rows.voidflush()protected ClassLoaderprotected StringgetColumnName(String entityAlias, String fieldName, boolean sqlQuery) Returns the data source for this model.getDB()protected EntityCacheprotected FinderCacheModelListener<T>[]Returns the listeners registered for this model.protected Stringprotected StringopenNewSession(Connection connection) processException(Exception exception) voidregisterListener(ModelListener<T> modelListener) Registers a new listener for this model.remove(Serializable primaryKey) Removes the model instance with the primary key from the database.Removes the model instance from the database.removeByFunction(T model, Function<T, T> function) protected static StringremoveConjunction(String sql) protected TremoveImpl(T model) Removes the model instance from the database.voidsetConfiguration(Configuration configuration) Deprecated.As of Athanasius (7.3.x), with no direct replacementvoidsetDataSource(DataSource dataSource) Sets the data source for this model.protected voidsetDBColumnNames(Map<String, String> dbColumnNames) protected voidsetEntityCacheEnabled(boolean entityCacheEnabled) protected voidsetModelClass(Class<T> modelClass) protected voidsetModelImplClass(Class<? extends T> modelImplClass) protected voidsetModelPKClass(Class<? extends Serializable> clazz) voidsetSessionFactory(SessionFactory sessionFactory) protected voidsetTable(com.liferay.petra.sql.dsl.Table<?> table) voidunregisterListener(ModelListener<T> modelListener) Unregisters the model listener.Updates the model instance in the database or adds it if it does not yet exist.update(T model, ServiceContext serviceContext) Updates the model instance in the database or adds it if it does not yet exist, within a different service context.protected TupdateImpl(T model) 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, waitMethods inherited from interface com.liferay.portal.kernel.service.persistence.BasePersistence
clearCache, dslQueryCount
-
Field Details
-
COUNT_COLUMN_NAME
- See Also:
-
CAST_CLOB_TEXT_OPEN
- See Also:
-
FINDER_ARGS_EMPTY
-
NULL_SAFE_STRING_COMPARATOR
Deprecated.As of Mueller (7.2.x), with no direct replacement -
ORDER_BY_ASC
- See Also:
-
ORDER_BY_ASC_HAS_NEXT
- See Also:
-
ORDER_BY_CLAUSE
- See Also:
-
ORDER_BY_DESC
- See Also:
-
ORDER_BY_DESC_HAS_NEXT
- See Also:
-
WHERE_AND
- See Also:
-
WHERE_GREATER_THAN
- See Also:
-
WHERE_GREATER_THAN_HAS_NEXT
- See Also:
-
WHERE_LESSER_THAN
- See Also:
-
WHERE_LESSER_THAN_HAS_NEXT
- See Also:
-
WHERE_OR
- See Also:
-
dummyEntityCache
-
dummyFinderCache
-
nullModel
protected static final com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.NullModel nullModel -
databaseInMaxParameters
protected int databaseInMaxParameters -
dbColumnNames
-
entityCacheEnabled
Deprecated.As of Athanasius (7.3.x), with no direct replacement -
finderCacheEnabled
Deprecated.As of Athanasius (7.3.x), with no direct replacement
-
-
Constructor Details
-
BasePersistenceImpl
public BasePersistenceImpl()
-
-
Method Details
-
cacheResult
-
clearCache
public void clearCache()Description copied from interface:BasePersistenceClears the cache for all instances of this model.The
EntityCacheandFinderCacheare both cleared by this method.- Specified by:
clearCachein interfaceBasePersistence<T extends BaseModel<T>>
-
clearCache
Description copied from interface:BasePersistenceClears the cache for a List instances of this model.The
EntityCacheandFinderCacheare both cleared by this method.- Specified by:
clearCachein interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
model- the List instances of this model to clear the cache for
-
clearCache
Description copied from interface:BasePersistenceClears the cache for one instance of this model.The
EntityCacheandFinderCacheare both cleared by this method.- Specified by:
clearCachein interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
model- the instance of this model to clear the cache for
-
closeSession
- Specified by:
closeSessionin interfaceBasePersistence<T extends BaseModel<T>>- Specified by:
closeSessionin interfaceSessionFactory
-
countWithDynamicQuery
Description copied from interface:BasePersistenceReturns the number of rows that match the dynamic query.- Specified by:
countWithDynamicQueryin interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
dynamicQuery- the dynamic query- Returns:
- the number of rows that match the dynamic query
-
countWithDynamicQuery
Description copied from interface:BasePersistenceReturns the number of rows that match the dynamic query.- Specified by:
countWithDynamicQueryin interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
dynamicQuery- the dynamic queryprojection- the projection to apply to the query- Returns:
- the number of rows that match the dynamic query
-
dslQuery
public <R> R dslQuery(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) - Specified by:
dslQueryin interfaceBasePersistence<T extends BaseModel<T>>
-
fetchByPrimaryKey
Description copied from interface:BasePersistenceReturns the model instance with the primary key or returnsnullif it could not be found.- Specified by:
fetchByPrimaryKeyin interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
primaryKey- the primary key of the model instance- Returns:
- the model instance, or
nullif an instance of this model with the primary key could not be found
-
fetchByPrimaryKeys
- Specified by:
fetchByPrimaryKeysin interfaceBasePersistence<T extends BaseModel<T>>
-
findByPrimaryKey
Description copied from interface:BasePersistenceReturns the model instance with the primary key or throws aNoSuchModelExceptionif it could not be found.- Specified by:
findByPrimaryKeyin interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
primaryKey- the primary key of the model instance- Returns:
- the model instance
- Throws:
NoSuchModelException
-
findWithDynamicQuery
Description copied from interface:BasePersistencePerforms a dynamic query on the database and returns the matching rows.- Specified by:
findWithDynamicQueryin interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
dynamicQuery- the dynamic query- Returns:
- the matching rows
-
findWithDynamicQuery
Description copied from interface:BasePersistencePerforms a dynamic query on the database and returns a range of the matching rows.Useful when paginating results. Returns a maximum of
end - startinstances.startandendare not primary keys, they are indexes in the result set. Thus,0refers to the first result in the set. Setting bothstartandendtoQueryUtil.ALL_POSwill return the full result set.- Specified by:
findWithDynamicQueryin interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
dynamicQuery- the dynamic querystart- the lower bound of the range of matching rowsend- the upper bound of the range of matching rows (not inclusive)- Returns:
- the range of matching rows
- See Also:
-
findWithDynamicQuery
public <V> List<V> findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<V> orderByComparator) Description copied from interface:BasePersistencePerforms a dynamic query on the database and returns an ordered range of the matching rows.Useful when paginating results. Returns a maximum of
end - startinstances.startandendare not primary keys, they are indexes in the result set. Thus,0refers to the first result in the set. Setting bothstartandendtoQueryUtil.ALL_POSwill return the full result set.- Specified by:
findWithDynamicQueryin interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
dynamicQuery- the dynamic querystart- the lower bound of the range of matching rowsend- the upper bound of the range of matching rows (not inclusive)orderByComparator- the comparator to order the results by (optionallynull)- Returns:
- the ordered range of matching rows
-
flush
public void flush()- Specified by:
flushin interfaceBasePersistence<T extends BaseModel<T>>
-
getBadColumnNames
- Specified by:
getBadColumnNamesin interfaceBasePersistence<T extends BaseModel<T>>
-
getCompoundPKColumnNames
-
getCurrentSession
- Specified by:
getCurrentSessionin interfaceBasePersistence<T extends BaseModel<T>>- Specified by:
getCurrentSessionin interfaceSessionFactory- Throws:
ORMException
-
getDataSource
Description copied from interface:BasePersistenceReturns the data source for this model.- Specified by:
getDataSourcein interfaceBasePersistence<T extends BaseModel<T>>- Returns:
- the data source for this model
- See Also:
-
getDB
- Specified by:
getDBin interfaceBasePersistence<T extends BaseModel<T>>
-
getDialect
- Specified by:
getDialectin interfaceBasePersistence<T extends BaseModel<T>>- Specified by:
getDialectin interfaceSessionFactory
-
getListeners
Description copied from interface:BasePersistenceReturns the listeners registered for this model.- Specified by:
getListenersin interfaceBasePersistence<T extends BaseModel<T>>- Returns:
- the listeners registered for this model
- See Also:
-
getModelClass
- Specified by:
getModelClassin interfaceBasePersistence<T extends BaseModel<T>>
-
openNewSession
- Specified by:
openNewSessionin interfaceSessionFactory- Throws:
ORMException
-
openSession
- Specified by:
openSessionin interfaceBasePersistence<T extends BaseModel<T>>- Specified by:
openSessionin interfaceSessionFactory- Throws:
ORMException
-
processException
- Specified by:
processExceptionin interfaceBasePersistence<T extends BaseModel<T>>
-
registerListener
Description copied from interface:BasePersistenceRegisters a new listener for this model.A model listener is notified whenever a change is made to an instance of this model, such as when one is added, updated, or removed.
- Specified by:
registerListenerin interfaceBasePersistence<T extends BaseModel<T>>
-
remove
Description copied from interface:BasePersistenceRemoves the model instance with the primary key from the database. Also notifies the appropriate model listeners.- Specified by:
removein interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
primaryKey- the primary key of the model instance to remove- Returns:
- the model instance that was removed
- Throws:
NoSuchModelException
-
remove
Description copied from interface:BasePersistenceRemoves the model instance from the database. Also notifies the appropriate model listeners.- Specified by:
removein interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
model- the model instance to remove- Returns:
- the model instance that was removed
-
removeByFunction
- Specified by:
removeByFunctionin interfaceBasePersistence<T extends BaseModel<T>>
-
setConfiguration
Deprecated.As of Athanasius (7.3.x), with no direct replacement -
setDataSource
Description copied from interface:BasePersistenceSets the data source for this model.- Specified by:
setDataSourcein interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
dataSource- the data source to use for this model
-
setSessionFactory
-
unregisterListener
Description copied from interface:BasePersistenceUnregisters the model listener.- Specified by:
unregisterListenerin interfaceBasePersistence<T extends BaseModel<T>>- See Also:
-
update
Description copied from interface:BasePersistenceUpdates the model instance in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.Typically not called directly, use local service update model methods instead. For example,
UserLocalServiceUtil.updateUser(com.liferay.portal.kernel.model.User).- Specified by:
updatein interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
model- the model instance to update- Returns:
- the model instance that was updated
-
update
Description copied from interface:BasePersistenceUpdates the model instance in the database or adds it if it does not yet exist, within a different service context. Also notifies the appropriate model listeners.- Specified by:
updatein interfaceBasePersistence<T extends BaseModel<T>>- Parameters:
model- the model instance to updateserviceContext- the service context to be applied- Returns:
- the model instance that was updated
-
removeConjunction
-
appendOrderByComparator
protected void appendOrderByComparator(com.liferay.petra.string.StringBundler sb, String entityAlias, OrderByComparator<T> orderByComparator) -
appendOrderByComparator
protected void appendOrderByComparator(com.liferay.petra.string.StringBundler sb, String entityAlias, OrderByComparator<T> orderByComparator, boolean sqlQuery) -
getClassLoader
-
getColumnName
-
getEntityCache
-
getFinderCache
-
getPKDBName
-
getSelectSQL
-
getTableColumnsMap
-
removeImpl
Removes the model instance from the database.#update(BaseModel, boolean)depends on this method to implement the remove operation; it only notifies the model listeners.- Parameters:
model- the model instance to remove- Returns:
- the model instance that was removed
-
setDBColumnNames
-
setEntityCacheEnabled
protected void setEntityCacheEnabled(boolean entityCacheEnabled) -
setModelClass
-
setModelImplClass
-
setModelPKClass
-
setTable
protected void setTable(com.liferay.petra.sql.dsl.Table<?> table) -
updateImpl
Updates the model instance in the database or adds it if it does not yet exist.remove(BaseModel)depends on this method to implement the update operation; it only notifies the model listeners.- Parameters:
model- the model instance to update- Returns:
- the model instance that was updated
-