Interface BasePersistence<T extends BaseModel<T>>
- All Known Subinterfaces:
AddressPersistence,AnnouncementsDeliveryPersistence,AnnouncementsEntryPersistence,AnnouncementsFlagPersistence,AssetCategoryPersistence,AssetEntryPersistence,AssetTagPersistence,AssetVocabularyPersistence,BrowserTrackerPersistence,ClassNamePersistence,CompanyInfoPersistence,CompanyPersistence,ContactPersistence,CountryLocalizationPersistence,CountryPersistence,CTPersistence<T>,DLFileEntryMetadataPersistence,DLFileEntryPersistence,DLFileEntryTypePersistence,DLFileShortcutPersistence,DLFileVersionPersistence,DLFolderPersistence,EmailAddressPersistence,ExpandoColumnPersistence,ExpandoRowPersistence,ExpandoTablePersistence,ExpandoValuePersistence,ExportImportConfigurationPersistence,GroupPersistence,ImagePersistence,LayoutBranchPersistence,LayoutFriendlyURLPersistence,LayoutPersistence,LayoutPrototypePersistence,LayoutRevisionPersistence,LayoutSetBranchPersistence,LayoutSetPersistence,LayoutSetPrototypePersistence,ListTypePersistence,MembershipRequestPersistence,OrganizationPersistence,OrgLaborPersistence,PasswordPolicyPersistence,PasswordPolicyRelPersistence,PasswordTrackerPersistence,PhonePersistence,PluginSettingPersistence,PortalPreferencesPersistence,PortalPreferenceValuePersistence,PortletItemPersistence,PortletPersistence,PortletPreferencesPersistence,PortletPreferenceValuePersistence,RatingsEntryPersistence,RatingsStatsPersistence,RecentLayoutBranchPersistence,RecentLayoutRevisionPersistence,RecentLayoutSetBranchPersistence,RegionLocalizationPersistence,RegionPersistence,ReleasePersistence,RememberMeTokenPersistence,RepositoryEntryPersistence,RepositoryPersistence,ResourceActionPersistence,ResourcePermissionPersistence,RolePersistence,ServiceComponentPersistence,SocialActivityAchievementPersistence,SocialActivityCounterPersistence,SocialActivityLimitPersistence,SocialActivityPersistence,SocialActivitySetPersistence,SocialActivitySettingPersistence,SocialRelationPersistence,SocialRequestPersistence,SubscriptionPersistence,SystemEventPersistence,TeamPersistence,TicketPersistence,UserGroupGroupRolePersistence,UserGroupPersistence,UserGroupRolePersistence,UserIdMapperPersistence,UserNotificationDeliveryPersistence,UserNotificationEventPersistence,UserPersistence,UserTrackerPathPersistence,UserTrackerPersistence,VirtualHostPersistence,WebDAVPropsPersistence,WebsitePersistence,WorkflowDefinitionLinkPersistence,WorkflowInstanceLinkPersistence
- All Known Implementing Classes:
BasePersistenceImpl
Caching information and settings can be found in
portal.properties
- Author:
- Brian Wing Shun Chan
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidClears the cache for all instances of this model.voidclearCache(List<T> modelList) Clears the cache for a List instances of this model.default voidclearCache(Set<Serializable> primaryKeys) 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) default intdslQueryCount(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()Returns the data source for this model.getDB()ModelListener<T>[]Returns the listeners registered for this model.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) voidsetDataSource(DataSource dataSource) Sets the data source for this model.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.
-
Method Details
-
clearCache
void clearCache()Clears the cache for all instances of this model.The
EntityCacheandFinderCacheare both cleared by this method. -
clearCache
Clears the cache for a List instances of this model.The
EntityCacheandFinderCacheare both cleared by this method.- Parameters:
modelList- the List instances of this model to clear the cache for
-
clearCache
-
clearCache
Clears the cache for one instance of this model.The
EntityCacheandFinderCacheare both cleared by this method.- Parameters:
model- the instance of this model to clear the cache for
-
closeSession
-
countWithDynamicQuery
Returns the number of rows that match the dynamic query.- Parameters:
dynamicQuery- the dynamic query- Returns:
- the number of rows that match the dynamic query
-
countWithDynamicQuery
Returns the number of rows that match the dynamic query.- Parameters:
dynamicQuery- the dynamic queryprojection- the projection to apply to the query- Returns:
- the number of rows that match the dynamic query
-
dslQuery
<R> R dslQuery(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) -
dslQueryCount
default int dslQueryCount(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) -
fetchByPrimaryKey
Returns the model instance with the primary key or returnsnullif it could not be found.- 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
-
findByPrimaryKey
Returns the model instance with the primary key or throws aNoSuchModelExceptionif it could not be found.- Parameters:
primaryKey- the primary key of the model instance- Returns:
- the model instance
- Throws:
NoSuchModelException
-
findWithDynamicQuery
Performs a dynamic query on the database and returns the matching rows.- Parameters:
dynamicQuery- the dynamic query- Returns:
- the matching rows
-
findWithDynamicQuery
Performs 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.- 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
<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.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.- 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
void flush() -
getBadColumnNames
-
getCurrentSession
- Throws:
ORMException
-
getDataSource
DataSource getDataSource()Returns the data source for this model.- Returns:
- the data source for this model
- See Also:
-
getDB
DB getDB() -
getDialect
Dialect getDialect() -
getListeners
ModelListener<T>[] getListeners()Returns the listeners registered for this model.- Returns:
- the listeners registered for this model
- See Also:
-
getModelClass
-
openSession
- Throws:
ORMException
-
processException
-
registerListener
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.
- Parameters:
listener- the model listener to register
-
remove
Removes the model instance with the primary key from the database. Also notifies the appropriate model listeners.- Parameters:
primaryKey- the primary key of the model instance to remove- Returns:
- the model instance that was removed
- Throws:
NoSuchModelException
-
remove
Removes the model instance from the database. Also notifies the appropriate model listeners.- Parameters:
model- the model instance to remove- Returns:
- the model instance that was removed
-
removeByFunction
-
setDataSource
Sets the data source for this model.- Parameters:
dataSource- the data source to use for this model
-
unregisterListener
Unregisters the model listener.- Parameters:
listener- the model listener to unregister- See Also:
-
update
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).- Parameters:
model- the model instance to update- Returns:
- the model instance that was updated
-
update
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.- Parameters:
model- the model instance to updateserviceContext- the service context to be applied- Returns:
- the model instance that was updated
-