Class PortletUtil
com.liferay.portal.service.persistence.impl.PortletPersistenceImpl and provides direct access to the database for CRUD operations. This utility should only be used by the service layer, as it must operate within a transaction. Never access this utility in a JSP, controller, model, or other front-end class.
Caching information and settings can be found in portal.properties
- Author:
- Brian Wing Shun Chan
- See Also:
- {$generated.description}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcacheResult(Portlet portlet) Caches the portlet in the entity cache if it is enabled.static voidcacheResult(List<Portlet> portlets) Caches the portlets in the entity cache if it is enabled.static voidstatic voidclearCache(Portlet portlet) static intcountAll()Returns the number of portlets.static intcountByC_P(long companyId, String portletId) Returns the number of portlets where companyId = ? and portletId = ?.static intcountByCompanyId(long companyId) Returns the number of portlets where companyId = ?.static longcountWithDynamicQuery(DynamicQuery dynamicQuery) static Portletcreate(long id) Creates a new portlet with the primary key.static PortletfetchByC_P(long companyId, String portletId) Returns the portlet where companyId = ? and portletId = ? or returnsnullif it could not be found.static PortletfetchByC_P(long companyId, String portletId, boolean useFinderCache) Returns the portlet where companyId = ? and portletId = ? or returnsnullif it could not be found, optionally using the finder cache.static PortletfetchByCompanyId_First(long companyId, OrderByComparator<Portlet> orderByComparator) Returns the first portlet in the ordered set where companyId = ?.static PortletfetchByCompanyId_Last(long companyId, OrderByComparator<Portlet> orderByComparator) Returns the last portlet in the ordered set where companyId = ?.static PortletfetchByPrimaryKey(long id) Returns the portlet with the primary key or returnsnullif it could not be found.static Map<Serializable,Portlet> fetchByPrimaryKeys(Set<Serializable> primaryKeys) findAll()Returns all the portlets.findAll(int start, int end) Returns a range of all the portlets.findAll(int start, int end, OrderByComparator<Portlet> orderByComparator) Returns an ordered range of all the portlets.findAll(int start, int end, OrderByComparator<Portlet> orderByComparator, boolean useFinderCache) Returns an ordered range of all the portlets.static PortletReturns the portlet where companyId = ? and portletId = ? or throws aNoSuchPortletExceptionif it could not be found.findByCompanyId(long companyId) Returns all the portlets where companyId = ?.findByCompanyId(long companyId, int start, int end) Returns a range of all the portlets where companyId = ?.findByCompanyId(long companyId, int start, int end, OrderByComparator<Portlet> orderByComparator) Returns an ordered range of all the portlets where companyId = ?.findByCompanyId(long companyId, int start, int end, OrderByComparator<Portlet> orderByComparator, boolean useFinderCache) Returns an ordered range of all the portlets where companyId = ?.static PortletfindByCompanyId_First(long companyId, OrderByComparator<Portlet> orderByComparator) Returns the first portlet in the ordered set where companyId = ?.static PortletfindByCompanyId_Last(long companyId, OrderByComparator<Portlet> orderByComparator) Returns the last portlet in the ordered set where companyId = ?.static Portlet[]findByCompanyId_PrevAndNext(long id, long companyId, OrderByComparator<Portlet> orderByComparator) Returns the portlets before and after the current portlet in the ordered set where companyId = ?.static PortletfindByPrimaryKey(long id) Returns the portlet with the primary key or throws aNoSuchPortletExceptionif it could not be found.findWithDynamicQuery(DynamicQuery dynamicQuery) findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end) findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<Portlet> orderByComparator) static PortletPersistencestatic Portletremove(long id) Removes the portlet with the primary key from the database.static voidRemoves all the portlets from the database.static PortletremoveByC_P(long companyId, String portletId) Removes the portlet where companyId = ? and portletId = ? from the database.static voidremoveByCompanyId(long companyId) Removes all the portlets where companyId = ? from the database.static voidsetPersistence(PortletPersistence persistence) static Portletstatic Portletupdate(Portlet portlet, ServiceContext serviceContext) static PortletupdateImpl(Portlet portlet)
-
Constructor Details
-
PortletUtil
public PortletUtil()
-
-
Method Details
-
clearCache
public static void clearCache()- See Also:
-
clearCache
-
countWithDynamicQuery
-
fetchByPrimaryKeys
- See Also:
-
findWithDynamicQuery
-
findWithDynamicQuery
-
findWithDynamicQuery
public static List<Portlet> findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<Portlet> orderByComparator) -
update
-
update
-
findByCompanyId
Returns all the portlets where companyId = ?.- Parameters:
companyId- the company ID- Returns:
- the matching portlets
-
findByCompanyId
Returns a range of all the portlets where companyId = ?.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. IforderByComparatoris specified, then the query will include the given ORDER BY logic. IforderByComparatoris absent, then the query will include the default ORDER BY logic fromPortletModelImpl.- Parameters:
companyId- the company IDstart- the lower bound of the range of portletsend- the upper bound of the range of portlets (not inclusive)- Returns:
- the range of matching portlets
-
findByCompanyId
public static List<Portlet> findByCompanyId(long companyId, int start, int end, OrderByComparator<Portlet> orderByComparator) Returns an ordered range of all the portlets where companyId = ?.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. IforderByComparatoris specified, then the query will include the given ORDER BY logic. IforderByComparatoris absent, then the query will include the default ORDER BY logic fromPortletModelImpl.- Parameters:
companyId- the company IDstart- the lower bound of the range of portletsend- the upper bound of the range of portlets (not inclusive)orderByComparator- the comparator to order the results by (optionallynull)- Returns:
- the ordered range of matching portlets
-
findByCompanyId
public static List<Portlet> findByCompanyId(long companyId, int start, int end, OrderByComparator<Portlet> orderByComparator, boolean useFinderCache) Returns an ordered range of all the portlets where companyId = ?.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. IforderByComparatoris specified, then the query will include the given ORDER BY logic. IforderByComparatoris absent, then the query will include the default ORDER BY logic fromPortletModelImpl.- Parameters:
companyId- the company IDstart- the lower bound of the range of portletsend- the upper bound of the range of portlets (not inclusive)orderByComparator- the comparator to order the results by (optionallynull)useFinderCache- whether to use the finder cache- Returns:
- the ordered range of matching portlets
-
findByCompanyId_First
public static Portlet findByCompanyId_First(long companyId, OrderByComparator<Portlet> orderByComparator) throws NoSuchPortletException Returns the first portlet in the ordered set where companyId = ?.- Parameters:
companyId- the company IDorderByComparator- the comparator to order the set by (optionallynull)- Returns:
- the first matching portlet
- Throws:
NoSuchPortletException- if a matching portlet could not be foundNoSuchPortletException
-
fetchByCompanyId_First
public static Portlet fetchByCompanyId_First(long companyId, OrderByComparator<Portlet> orderByComparator) Returns the first portlet in the ordered set where companyId = ?.- Parameters:
companyId- the company IDorderByComparator- the comparator to order the set by (optionallynull)- Returns:
- the first matching portlet, or
nullif a matching portlet could not be found
-
findByCompanyId_Last
public static Portlet findByCompanyId_Last(long companyId, OrderByComparator<Portlet> orderByComparator) throws NoSuchPortletException Returns the last portlet in the ordered set where companyId = ?.- Parameters:
companyId- the company IDorderByComparator- the comparator to order the set by (optionallynull)- Returns:
- the last matching portlet
- Throws:
NoSuchPortletException- if a matching portlet could not be foundNoSuchPortletException
-
fetchByCompanyId_Last
public static Portlet fetchByCompanyId_Last(long companyId, OrderByComparator<Portlet> orderByComparator) Returns the last portlet in the ordered set where companyId = ?.- Parameters:
companyId- the company IDorderByComparator- the comparator to order the set by (optionallynull)- Returns:
- the last matching portlet, or
nullif a matching portlet could not be found
-
findByCompanyId_PrevAndNext
public static Portlet[] findByCompanyId_PrevAndNext(long id, long companyId, OrderByComparator<Portlet> orderByComparator) throws NoSuchPortletException Returns the portlets before and after the current portlet in the ordered set where companyId = ?.- Parameters:
id- the primary key of the current portletcompanyId- the company IDorderByComparator- the comparator to order the set by (optionallynull)- Returns:
- the previous, current, and next portlet
- Throws:
NoSuchPortletException- if a portlet with the primary key could not be foundNoSuchPortletException
-
removeByCompanyId
public static void removeByCompanyId(long companyId) Removes all the portlets where companyId = ? from the database.- Parameters:
companyId- the company ID
-
countByCompanyId
public static int countByCompanyId(long companyId) Returns the number of portlets where companyId = ?.- Parameters:
companyId- the company ID- Returns:
- the number of matching portlets
-
findByC_P
Returns the portlet where companyId = ? and portletId = ? or throws aNoSuchPortletExceptionif it could not be found.- Parameters:
companyId- the company IDportletId- the portlet ID- Returns:
- the matching portlet
- Throws:
NoSuchPortletException- if a matching portlet could not be foundNoSuchPortletException
-
fetchByC_P
Returns the portlet where companyId = ? and portletId = ? or returnsnullif it could not be found. Uses the finder cache.- Parameters:
companyId- the company IDportletId- the portlet ID- Returns:
- the matching portlet, or
nullif a matching portlet could not be found
-
fetchByC_P
Returns the portlet where companyId = ? and portletId = ? or returnsnullif it could not be found, optionally using the finder cache.- Parameters:
companyId- the company IDportletId- the portlet IDuseFinderCache- whether to use the finder cache- Returns:
- the matching portlet, or
nullif a matching portlet could not be found
-
removeByC_P
Removes the portlet where companyId = ? and portletId = ? from the database.- Parameters:
companyId- the company IDportletId- the portlet ID- Returns:
- the portlet that was removed
- Throws:
NoSuchPortletException
-
countByC_P
Returns the number of portlets where companyId = ? and portletId = ?.- Parameters:
companyId- the company IDportletId- the portlet ID- Returns:
- the number of matching portlets
-
cacheResult
Caches the portlet in the entity cache if it is enabled.- Parameters:
portlet- the portlet
-
cacheResult
Caches the portlets in the entity cache if it is enabled.- Parameters:
portlets- the portlets
-
create
Creates a new portlet with the primary key. Does not add the portlet to the database.- Parameters:
id- the primary key for the new portlet- Returns:
- the new portlet
-
remove
Removes the portlet with the primary key from the database. Also notifies the appropriate model listeners.- Parameters:
id- the primary key of the portlet- Returns:
- the portlet that was removed
- Throws:
NoSuchPortletException- if a portlet with the primary key could not be foundNoSuchPortletException
-
updateImpl
-
findByPrimaryKey
Returns the portlet with the primary key or throws aNoSuchPortletExceptionif it could not be found.- Parameters:
id- the primary key of the portlet- Returns:
- the portlet
- Throws:
NoSuchPortletException- if a portlet with the primary key could not be foundNoSuchPortletException
-
fetchByPrimaryKey
Returns the portlet with the primary key or returnsnullif it could not be found.- Parameters:
id- the primary key of the portlet- Returns:
- the portlet, or
nullif a portlet with the primary key could not be found
-
findAll
Returns all the portlets.- Returns:
- the portlets
-
findAll
Returns a range of all the portlets.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. IforderByComparatoris specified, then the query will include the given ORDER BY logic. IforderByComparatoris absent, then the query will include the default ORDER BY logic fromPortletModelImpl.- Parameters:
start- the lower bound of the range of portletsend- the upper bound of the range of portlets (not inclusive)- Returns:
- the range of portlets
-
findAll
public static List<Portlet> findAll(int start, int end, OrderByComparator<Portlet> orderByComparator) Returns an ordered range of all the portlets.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. IforderByComparatoris specified, then the query will include the given ORDER BY logic. IforderByComparatoris absent, then the query will include the default ORDER BY logic fromPortletModelImpl.- Parameters:
start- the lower bound of the range of portletsend- the upper bound of the range of portlets (not inclusive)orderByComparator- the comparator to order the results by (optionallynull)- Returns:
- the ordered range of portlets
-
findAll
public static List<Portlet> findAll(int start, int end, OrderByComparator<Portlet> orderByComparator, boolean useFinderCache) Returns an ordered range of all the portlets.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. IforderByComparatoris specified, then the query will include the given ORDER BY logic. IforderByComparatoris absent, then the query will include the default ORDER BY logic fromPortletModelImpl.- Parameters:
start- the lower bound of the range of portletsend- the upper bound of the range of portlets (not inclusive)orderByComparator- the comparator to order the results by (optionallynull)useFinderCache- whether to use the finder cache- Returns:
- the ordered range of portlets
-
removeAll
public static void removeAll()Removes all the portlets from the database. -
countAll
public static int countAll()Returns the number of portlets.- Returns:
- the number of portlets
-
getPersistence
-
setPersistence
-