public class PortletUtil
extends Object
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
PortletPersistence
Constructor and Description |
---|
PortletUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
cacheResult(List<Portlet> portlets)
Caches the portlets in the entity cache if it is enabled.
|
static void |
cacheResult(Portlet portlet)
Caches the portlet in the entity cache if it is enabled.
|
static void |
clearCache() |
static void |
clearCache(Portlet portlet) |
static int |
countAll()
Returns the number of portlets.
|
static int |
countByC_P(long companyId,
String portletId)
Returns the number of portlets where companyId = ? and portletId = ?.
|
static int |
countByCompanyId(long companyId)
Returns the number of portlets where companyId = ?.
|
static long |
countWithDynamicQuery(DynamicQuery dynamicQuery) |
static Portlet |
create(long id)
Creates a new portlet with the primary key.
|
static Portlet |
fetchByC_P(long companyId,
String portletId)
Returns the portlet where companyId = ? and portletId = ? or returns
null if it could not be found. |
static Portlet |
fetchByC_P(long companyId,
String portletId,
boolean useFinderCache)
Returns the portlet where companyId = ? and portletId = ? or returns
null if it could not be found, optionally using the finder cache. |
static Portlet |
fetchByCompanyId_First(long companyId,
OrderByComparator<Portlet> orderByComparator)
Returns the first portlet in the ordered set where companyId = ?.
|
static Portlet |
fetchByCompanyId_Last(long companyId,
OrderByComparator<Portlet> orderByComparator)
Returns the last portlet in the ordered set where companyId = ?.
|
static Portlet |
fetchByPrimaryKey(long id)
Returns the portlet with the primary key or returns
null if it could not be found. |
static Map<Serializable,Portlet> |
fetchByPrimaryKeys(Set<Serializable> primaryKeys) |
static List<Portlet> |
findAll()
Returns all the portlets.
|
static List<Portlet> |
findAll(int start,
int end)
Returns a range of all the portlets.
|
static List<Portlet> |
findAll(int start,
int end,
OrderByComparator<Portlet> orderByComparator)
Returns an ordered range of all the portlets.
|
static List<Portlet> |
findAll(int start,
int end,
OrderByComparator<Portlet> orderByComparator,
boolean useFinderCache)
Returns an ordered range of all the portlets.
|
static Portlet |
findByC_P(long companyId,
String portletId)
Returns the portlet where companyId = ? and portletId = ? or throws a
NoSuchPortletException if it could not be found. |
static Portlet |
findByCompanyId_First(long companyId,
OrderByComparator<Portlet> orderByComparator)
Returns the first portlet in the ordered set where companyId = ?.
|
static Portlet |
findByCompanyId_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 List<Portlet> |
findByCompanyId(long companyId)
Returns all the portlets where companyId = ?.
|
static List<Portlet> |
findByCompanyId(long companyId,
int start,
int end)
Returns a range of all the portlets where companyId = ?.
|
static List<Portlet> |
findByCompanyId(long companyId,
int start,
int end,
OrderByComparator<Portlet> orderByComparator)
Returns an ordered range of all the portlets where companyId = ?.
|
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 = ?.
|
static Portlet |
findByPrimaryKey(long id)
Returns the portlet with the primary key or throws a
NoSuchPortletException if it could not be found. |
static List<Portlet> |
findWithDynamicQuery(DynamicQuery dynamicQuery) |
static List<Portlet> |
findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end) |
static List<Portlet> |
findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end,
OrderByComparator<Portlet> orderByComparator) |
static PortletPersistence |
getPersistence() |
static Portlet |
remove(long id)
Removes the portlet with the primary key from the database.
|
static void |
removeAll()
Removes all the portlets from the database.
|
static Portlet |
removeByC_P(long companyId,
String portletId)
Removes the portlet where companyId = ? and portletId = ? from the database.
|
static void |
removeByCompanyId(long companyId)
Removes all the portlets where companyId = ? from the database.
|
static Portlet |
update(Portlet portlet) |
static Portlet |
update(Portlet portlet,
ServiceContext serviceContext) |
static Portlet |
updateImpl(Portlet portlet) |
public static void clearCache()
BasePersistence.clearCache()
public static void clearCache(Portlet portlet)
public static long countWithDynamicQuery(DynamicQuery dynamicQuery)
public static Map<Serializable,Portlet> fetchByPrimaryKeys(Set<Serializable> primaryKeys)
BasePersistence.fetchByPrimaryKeys(Set)
public static List<Portlet> findWithDynamicQuery(DynamicQuery dynamicQuery)
public static List<Portlet> findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end)
public static List<Portlet> findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<Portlet> orderByComparator)
public static Portlet update(Portlet portlet, ServiceContext serviceContext)
public static List<Portlet> findByCompanyId(long companyId)
companyId
- the company IDpublic static List<Portlet> findByCompanyId(long companyId, int start, int end)
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. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from PortletModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
companyId
- the company IDstart
- the lower bound of the range of portletsend
- the upper bound of the range of portlets (not inclusive)public static List<Portlet> findByCompanyId(long companyId, int start, int end, OrderByComparator<Portlet> orderByComparator)
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. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from PortletModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
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 (optionally null
)public static List<Portlet> findByCompanyId(long companyId, int start, int end, OrderByComparator<Portlet> orderByComparator, boolean useFinderCache)
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. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from PortletModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
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 (optionally null
)useFinderCache
- whether to use the finder cachepublic static Portlet findByCompanyId_First(long companyId, OrderByComparator<Portlet> orderByComparator) throws NoSuchPortletException
companyId
- the company IDorderByComparator
- the comparator to order the set by (optionally null
)NoSuchPortletException
- if a matching portlet could not be foundpublic static Portlet fetchByCompanyId_First(long companyId, OrderByComparator<Portlet> orderByComparator)
companyId
- the company IDorderByComparator
- the comparator to order the set by (optionally null
)null
if a matching portlet could not be foundpublic static Portlet findByCompanyId_Last(long companyId, OrderByComparator<Portlet> orderByComparator) throws NoSuchPortletException
companyId
- the company IDorderByComparator
- the comparator to order the set by (optionally null
)NoSuchPortletException
- if a matching portlet could not be foundpublic static Portlet fetchByCompanyId_Last(long companyId, OrderByComparator<Portlet> orderByComparator)
companyId
- the company IDorderByComparator
- the comparator to order the set by (optionally null
)null
if a matching portlet could not be foundpublic static Portlet[] findByCompanyId_PrevAndNext(long id, long companyId, OrderByComparator<Portlet> orderByComparator) throws NoSuchPortletException
id
- the primary key of the current portletcompanyId
- the company IDorderByComparator
- the comparator to order the set by (optionally null
)NoSuchPortletException
- if a portlet with the primary key could not be foundpublic static void removeByCompanyId(long companyId)
companyId
- the company IDpublic static int countByCompanyId(long companyId)
companyId
- the company IDpublic static Portlet findByC_P(long companyId, String portletId) throws NoSuchPortletException
NoSuchPortletException
if it could not be found.companyId
- the company IDportletId
- the portlet IDNoSuchPortletException
- if a matching portlet could not be foundpublic static Portlet fetchByC_P(long companyId, String portletId)
null
if it could not be found. Uses the finder cache.companyId
- the company IDportletId
- the portlet IDnull
if a matching portlet could not be foundpublic static Portlet fetchByC_P(long companyId, String portletId, boolean useFinderCache)
null
if it could not be found, optionally using the finder cache.companyId
- the company IDportletId
- the portlet IDuseFinderCache
- whether to use the finder cachenull
if a matching portlet could not be foundpublic static Portlet removeByC_P(long companyId, String portletId) throws NoSuchPortletException
companyId
- the company IDportletId
- the portlet IDNoSuchPortletException
public static int countByC_P(long companyId, String portletId)
companyId
- the company IDportletId
- the portlet IDpublic static void cacheResult(Portlet portlet)
portlet
- the portletpublic static void cacheResult(List<Portlet> portlets)
portlets
- the portletspublic static Portlet create(long id)
id
- the primary key for the new portletpublic static Portlet remove(long id) throws NoSuchPortletException
id
- the primary key of the portletNoSuchPortletException
- if a portlet with the primary key could not be foundpublic static Portlet findByPrimaryKey(long id) throws NoSuchPortletException
NoSuchPortletException
if it could not be found.id
- the primary key of the portletNoSuchPortletException
- if a portlet with the primary key could not be foundpublic static Portlet fetchByPrimaryKey(long id)
null
if it could not be found.id
- the primary key of the portletnull
if a portlet with the primary key could not be foundpublic static List<Portlet> findAll()
public static List<Portlet> findAll(int start, int end)
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. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from PortletModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
start
- the lower bound of the range of portletsend
- the upper bound of the range of portlets (not inclusive)public static List<Portlet> findAll(int start, int end, OrderByComparator<Portlet> orderByComparator)
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. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from PortletModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
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 (optionally null
)public static List<Portlet> findAll(int start, int end, OrderByComparator<Portlet> orderByComparator, boolean useFinderCache)
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. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent and pagination is required (start
and end
are not QueryUtil#ALL_POS
), then the query will include the default ORDER BY logic from PortletModelImpl
. If both orderByComparator
and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
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 (optionally null
)useFinderCache
- whether to use the finder cachepublic static void removeAll()
public static int countAll()
public static PortletPersistence getPersistence()