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 String
static final String
protected int
protected static EntityCache
protected static FinderCache
protected boolean
Deprecated.As of Athanasius (7.3.x), with no direct replacementprotected static final Object[]
protected boolean
Deprecated.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.NullModel
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
appendOrderByComparator
(com.liferay.petra.string.StringBundler sb, String entityAlias, OrderByComparator<T> orderByComparator) protected void
appendOrderByComparator
(com.liferay.petra.string.StringBundler sb, String entityAlias, OrderByComparator<T> orderByComparator, boolean sqlQuery) void
cacheResult
(T model) void
Clears the cache for all instances of this model.void
clearCache
(List<T> model) Clears the cache for a List 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) Returns the number of rows that match the dynamic query.long
countWithDynamicQuery
(DynamicQuery dynamicQuery, Projection projection) Returns the number of rows that match the dynamic query.<R> R
dslQuery
(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) fetchByPrimaryKey
(Serializable primaryKey) Returns the model instance with the primary key or returnsnull
if it could not be found.fetchByPrimaryKeys
(Set<Serializable> primaryKeys) findByPrimaryKey
(Serializable primaryKey) Returns the model instance with the primary key or throws aNoSuchModelException
if 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.void
flush()
protected ClassLoader
protected String
getColumnName
(String entityAlias, String fieldName, boolean sqlQuery) Returns the data source for this model.getDB()
protected EntityCache
protected FinderCache
ModelListener<T>[]
Returns the listeners registered for this model.protected String
protected String
openNewSession
(Connection connection) processException
(Exception exception) void
registerListener
(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 String
removeConjunction
(String sql) protected T
removeImpl
(T model) Removes the model instance from the database.void
setConfiguration
(Configuration configuration) Deprecated.As of Athanasius (7.3.x), with no direct replacementvoid
setDataSource
(DataSource dataSource) Sets the data source for this model.protected void
setDBColumnNames
(Map<String, String> dbColumnNames) protected void
setEntityCacheEnabled
(boolean entityCacheEnabled) protected void
setModelClass
(Class<T> modelClass) protected void
setModelImplClass
(Class<? extends T> modelImplClass) protected void
setModelPKClass
(Class<? extends Serializable> clazz) void
setSessionFactory
(SessionFactory sessionFactory) protected void
setTable
(com.liferay.petra.sql.dsl.Table<?> table) void
unregisterListener
(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 T
updateImpl
(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, wait
Methods 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:BasePersistence
Clears the cache for all instances of this model.The
EntityCache
andFinderCache
are both cleared by this method.- Specified by:
clearCache
in interfaceBasePersistence<T extends BaseModel<T>>
-
clearCache
Description copied from interface:BasePersistence
Clears the cache for a List instances of this model.The
EntityCache
andFinderCache
are both cleared by this method.- Specified by:
clearCache
in interfaceBasePersistence<T extends BaseModel<T>>
- Parameters:
model
- the List instances of this model to clear the cache for
-
clearCache
Description copied from interface:BasePersistence
Clears the cache for one instance of this model.The
EntityCache
andFinderCache
are both cleared by this method.- Specified by:
clearCache
in interfaceBasePersistence<T extends BaseModel<T>>
- Parameters:
model
- the instance of this model to clear the cache for
-
closeSession
- Specified by:
closeSession
in interfaceBasePersistence<T extends BaseModel<T>>
- Specified by:
closeSession
in interfaceSessionFactory
-
countWithDynamicQuery
Description copied from interface:BasePersistence
Returns the number of rows that match the dynamic query.- Specified by:
countWithDynamicQuery
in 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:BasePersistence
Returns the number of rows that match the dynamic query.- Specified by:
countWithDynamicQuery
in 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:
dslQuery
in interfaceBasePersistence<T extends BaseModel<T>>
-
fetchByPrimaryKey
Description copied from interface:BasePersistence
Returns the model instance with the primary key or returnsnull
if it could not be found.- Specified by:
fetchByPrimaryKey
in interfaceBasePersistence<T extends BaseModel<T>>
- Parameters:
primaryKey
- the primary key of the model instance- Returns:
- the model instance, or
null
if an instance of this model with the primary key could not be found
-
fetchByPrimaryKeys
- Specified by:
fetchByPrimaryKeys
in interfaceBasePersistence<T extends BaseModel<T>>
-
findByPrimaryKey
Description copied from interface:BasePersistence
Returns the model instance with the primary key or throws aNoSuchModelException
if it could not be found.- Specified by:
findByPrimaryKey
in 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:BasePersistence
Performs a dynamic query on the database and returns the matching rows.- Specified by:
findWithDynamicQuery
in interfaceBasePersistence<T extends BaseModel<T>>
- Parameters:
dynamicQuery
- the dynamic query- Returns:
- the matching rows
-
findWithDynamicQuery
Description copied from interface:BasePersistence
Performs a dynamic query on the database and returns a range of the matching rows.Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
toQueryUtil.ALL_POS
will return the full result set.- Specified by:
findWithDynamicQuery
in 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:BasePersistence
Performs a dynamic query on the database and returns an ordered range of the matching rows.Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
toQueryUtil.ALL_POS
will return the full result set.- Specified by:
findWithDynamicQuery
in 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:
flush
in interfaceBasePersistence<T extends BaseModel<T>>
-
getBadColumnNames
- Specified by:
getBadColumnNames
in interfaceBasePersistence<T extends BaseModel<T>>
-
getCompoundPKColumnNames
-
getCurrentSession
- Specified by:
getCurrentSession
in interfaceBasePersistence<T extends BaseModel<T>>
- Specified by:
getCurrentSession
in interfaceSessionFactory
- Throws:
ORMException
-
getDataSource
Description copied from interface:BasePersistence
Returns the data source for this model.- Specified by:
getDataSource
in interfaceBasePersistence<T extends BaseModel<T>>
- Returns:
- the data source for this model
- See Also:
-
getDB
- Specified by:
getDB
in interfaceBasePersistence<T extends BaseModel<T>>
-
getDialect
- Specified by:
getDialect
in interfaceBasePersistence<T extends BaseModel<T>>
- Specified by:
getDialect
in interfaceSessionFactory
-
getListeners
Description copied from interface:BasePersistence
Returns the listeners registered for this model.- Specified by:
getListeners
in interfaceBasePersistence<T extends BaseModel<T>>
- Returns:
- the listeners registered for this model
- See Also:
-
getModelClass
- Specified by:
getModelClass
in interfaceBasePersistence<T extends BaseModel<T>>
-
openNewSession
- Specified by:
openNewSession
in interfaceSessionFactory
- Throws:
ORMException
-
openSession
- Specified by:
openSession
in interfaceBasePersistence<T extends BaseModel<T>>
- Specified by:
openSession
in interfaceSessionFactory
- Throws:
ORMException
-
processException
- Specified by:
processException
in interfaceBasePersistence<T extends BaseModel<T>>
-
registerListener
Description copied from interface:BasePersistence
Registers 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:
registerListener
in interfaceBasePersistence<T extends BaseModel<T>>
-
remove
Description copied from interface:BasePersistence
Removes the model instance with the primary key from the database. Also notifies the appropriate model listeners.- Specified by:
remove
in 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:BasePersistence
Removes the model instance from the database. Also notifies the appropriate model listeners.- Specified by:
remove
in interfaceBasePersistence<T extends BaseModel<T>>
- Parameters:
model
- the model instance to remove- Returns:
- the model instance that was removed
-
removeByFunction
- Specified by:
removeByFunction
in interfaceBasePersistence<T extends BaseModel<T>>
-
setConfiguration
Deprecated.As of Athanasius (7.3.x), with no direct replacement -
setDataSource
Description copied from interface:BasePersistence
Sets the data source for this model.- Specified by:
setDataSource
in interfaceBasePersistence<T extends BaseModel<T>>
- Parameters:
dataSource
- the data source to use for this model
-
setSessionFactory
-
unregisterListener
Description copied from interface:BasePersistence
Unregisters the model listener.- Specified by:
unregisterListener
in interfaceBasePersistence<T extends BaseModel<T>>
- See Also:
-
update
Description copied from interface:BasePersistence
Updates 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:
update
in interfaceBasePersistence<T extends BaseModel<T>>
- Parameters:
model
- the model instance to update- Returns:
- the model instance that was updated
-
update
Description copied from interface:BasePersistence
Updates 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:
update
in 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
-