public class BasePersistenceImpl<T extends BaseModel<T>> extends java.lang.Object implements BasePersistence<T>, SessionFactory
Caching information and settings can be found in
portal.properties
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
COUNT_COLUMN_NAME |
protected static java.lang.Object[] |
FINDER_ARGS_EMPTY |
protected ModelListener<T>[] |
listeners |
protected static java.lang.String |
ORDER_BY_ASC |
protected static java.lang.String |
ORDER_BY_ASC_HAS_NEXT |
protected static java.lang.String |
ORDER_BY_CLAUSE |
protected static java.lang.String |
ORDER_BY_DESC |
protected static java.lang.String |
ORDER_BY_DESC_HAS_NEXT |
protected static java.lang.String |
WHERE_AND |
protected static java.lang.String |
WHERE_GREATER_THAN |
protected static java.lang.String |
WHERE_GREATER_THAN_HAS_NEXT |
protected static java.lang.String |
WHERE_LESSER_THAN |
protected static java.lang.String |
WHERE_LESSER_THAN_HAS_NEXT |
protected static java.lang.String |
WHERE_OR |
| Constructor and Description |
|---|
BasePersistenceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
appendOrderByComparator(StringBundler query,
java.lang.String entityAlias,
OrderByComparator orderByComparator) |
protected void |
appendOrderByComparator(StringBundler query,
java.lang.String entityAlias,
OrderByComparator orderByComparator,
boolean sqlQuery) |
void |
clearCache()
Clears the cache for all instances of this model.
|
void |
clearCache(java.util.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.
|
T |
fetchByPrimaryKey(java.io.Serializable primaryKey)
Returns the model instance with the primary key or returns
null if it could not be found. |
T |
findByPrimaryKey(java.io.Serializable primaryKey)
Returns the model instance with the primary key or throws a
NoSuchModelException if it could not be found. |
java.util.List |
findWithDynamicQuery(DynamicQuery dynamicQuery)
Performs a dynamic query on the database and returns the matching rows.
|
java.util.List |
findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end)
Performs a dynamic query on the database and returns a range of the
matching rows.
|
java.util.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.
|
void |
flush() |
protected java.util.Set<java.lang.String> |
getBadColumnNames() |
protected java.lang.ClassLoader |
getClassLoader() |
Session |
getCurrentSession() |
javax.sql.DataSource |
getDataSource()
Returns the data source for this model.
|
DB |
getDB() |
Dialect |
getDialect() |
ModelListener<T>[] |
getListeners()
Returns the listeners registered for this model.
|
java.lang.Class<T> |
getModelClass() |
Session |
openNewSession(java.sql.Connection connection) |
Session |
openSession() |
SystemException |
processException(java.lang.Exception e) |
void |
registerListener(ModelListener<T> listener)
Registers a new listener for this model.
|
T |
remove(java.io.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 static java.lang.String |
removeConjunction(java.lang.String sql) |
protected T |
removeImpl(T model)
Removes the model instance from the database.
|
void |
setDataSource(javax.sql.DataSource dataSource)
Sets the data source for this model.
|
protected void |
setModelClass(java.lang.Class<T> modelClass) |
void |
setSessionFactory(SessionFactory sessionFactory) |
void |
unregisterListener(ModelListener<T> listener)
Unregisters the model listener.
|
T |
update(T model)
Updates the model instance in the database or adds it if it does not yet
exist.
|
T |
update(T model,
boolean merge)
Deprecated.
As of 6.2.0, replaced by
update(BaseModel)} |
T |
update(T model,
boolean merge,
ServiceContext serviceContext)
Deprecated.
As of 6.2.0, replaced by
update(BaseModel,
ServiceContext)} |
T |
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.
|
protected T |
updateImpl(T model,
boolean merge)
Deprecated.
As of 6.2.0, replaced by
updateImpl(BaseModel) |
public static final java.lang.String COUNT_COLUMN_NAME
protected static final java.lang.Object[] FINDER_ARGS_EMPTY
protected static final java.lang.String ORDER_BY_ASC
protected static final java.lang.String ORDER_BY_ASC_HAS_NEXT
protected static final java.lang.String ORDER_BY_CLAUSE
protected static final java.lang.String ORDER_BY_DESC
protected static final java.lang.String ORDER_BY_DESC_HAS_NEXT
protected static final java.lang.String WHERE_AND
protected static final java.lang.String WHERE_GREATER_THAN
protected static final java.lang.String WHERE_GREATER_THAN_HAS_NEXT
protected static final java.lang.String WHERE_LESSER_THAN
protected static final java.lang.String WHERE_LESSER_THAN_HAS_NEXT
protected static final java.lang.String WHERE_OR
protected ModelListener<T extends BaseModel<T>>[] listeners
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(java.util.List<T> model)
BasePersistence
The EntityCache and FinderCache are both cleared by this
method.
clearCache in interface BasePersistence<T extends BaseModel<T>>model - the List instances of this model to clear the cache forpublic 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 SessionFactorycloseSession in interface BasePersistence<T extends BaseModel<T>>public long countWithDynamicQuery(DynamicQuery dynamicQuery) throws SystemException
BasePersistencecountWithDynamicQuery in interface BasePersistence<T extends BaseModel<T>>dynamicQuery - the dynamic querySystemException - if a system exception occurredpublic long countWithDynamicQuery(DynamicQuery dynamicQuery, Projection projection) throws SystemException
BasePersistencecountWithDynamicQuery in interface BasePersistence<T extends BaseModel<T>>dynamicQuery - the dynamic queryprojection - the projection to apply to the querySystemException - if a system exception occurredpublic T fetchByPrimaryKey(java.io.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 instancenull if an instance of this
model with the primary key could not be foundSystemException - if the primary key is null, or if a
system exception occurredpublic T findByPrimaryKey(java.io.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 instanceNoSuchModelException - if an instance of this model with the
primary key could not be foundSystemException - if the primary key is null, or if a
system exception occurredpublic java.util.List findWithDynamicQuery(DynamicQuery dynamicQuery) throws SystemException
BasePersistencefindWithDynamicQuery in interface BasePersistence<T extends BaseModel<T>>dynamicQuery - the dynamic querySystemException - if a system exception occurredpublic java.util.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 querystart - the lower bound of the range of matching rowsend - the upper bound of the range of matching rows (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 java.util.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 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
(optionally null)SystemException - if a system exception occurredpublic void flush()
throws SystemException
flush in interface BasePersistence<T extends BaseModel<T>>SystemExceptionpublic Session getCurrentSession() throws ORMException
getCurrentSession in interface SessionFactorygetCurrentSession in interface BasePersistence<T extends BaseModel<T>>ORMExceptionpublic javax.sql.DataSource getDataSource()
BasePersistencegetDataSource in interface BasePersistence<T extends BaseModel<T>>BasePersistence.setDataSource(DataSource)public DB getDB()
public Dialect getDialect()
getDialect in interface SessionFactorypublic ModelListener<T>[] getListeners()
BasePersistencegetListeners in interface BasePersistence<T extends BaseModel<T>>BasePersistence.registerListener(ModelListener)public java.lang.Class<T> getModelClass()
getModelClass in interface BasePersistence<T extends BaseModel<T>>public Session openNewSession(java.sql.Connection connection) throws ORMException
openNewSession in interface SessionFactoryORMExceptionpublic Session openSession() throws ORMException
openSession in interface SessionFactoryopenSession in interface BasePersistence<T extends BaseModel<T>>ORMExceptionpublic SystemException processException(java.lang.Exception e)
processException in interface BasePersistence<T extends BaseModel<T>>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 registerpublic T remove(java.io.Serializable primaryKey) throws NoSuchModelException, SystemException
BasePersistenceremove in interface BasePersistence<T extends BaseModel<T>>primaryKey - the primary key of the model instance to removeNoSuchModelException - if an instance of this model with the
primary key could not be foundSystemException - if a system exception occurredpublic T remove(T model) throws SystemException
BasePersistenceremove in interface BasePersistence<T extends BaseModel<T>>model - the model instance to removeSystemException - if a system exception occurredpublic void setDataSource(javax.sql.DataSource dataSource)
BasePersistencesetDataSource 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)
BasePersistenceunregisterListener in interface BasePersistence<T extends BaseModel<T>>listener - the model listener to unregisterBasePersistence.registerListener(ModelListener)public T update(T model) 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 updateSystemException - if a system exception occurredpublic T update(T model, boolean merge) throws SystemException
update(BaseModel)}update in interface BasePersistence<T extends BaseModel<T>>SystemExceptionpublic T update(T model, boolean merge, ServiceContext serviceContext) throws SystemException
update(BaseModel,
ServiceContext)}update in interface BasePersistence<T extends BaseModel<T>>SystemExceptionpublic T update(T model, ServiceContext serviceContext) throws SystemException
BasePersistenceupdate in interface BasePersistence<T extends BaseModel<T>>model - the model instance to updateserviceContext - the service context to be appliedSystemException - if a system exception occurredprotected static java.lang.String removeConjunction(java.lang.String sql)
protected void appendOrderByComparator(StringBundler query, java.lang.String entityAlias, OrderByComparator orderByComparator)
protected void appendOrderByComparator(StringBundler query, java.lang.String entityAlias, OrderByComparator orderByComparator, boolean sqlQuery)
protected java.util.Set<java.lang.String> getBadColumnNames()
protected java.lang.ClassLoader getClassLoader()
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 removeSystemException - if a system exception occurredprotected void setModelClass(java.lang.Class<T> modelClass)
protected T updateImpl(T model) throws SystemException
remove(BaseModel) depends on this method to implement the
update operation; it only notifies the model listeners.model - the model instance to updateSystemException - if a system exception occurredprotected T updateImpl(T model, boolean merge) throws SystemException
updateImpl(BaseModel)SystemException