@ProviderType
public class CounterUtil
extends Object
CounterPersistenceImpl
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
CounterPersistence
,
CounterPersistenceImpl
Constructor and Description |
---|
CounterUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
cacheResult(Counter counter)
Caches the counter in the entity cache if it is enabled.
|
static void |
cacheResult(List<Counter> counters)
Caches the counters in the entity cache if it is enabled.
|
static void |
clearCache() |
static void |
clearCache(Counter counter) |
static int |
countAll()
Returns the number of counters.
|
static long |
countWithDynamicQuery(DynamicQuery dynamicQuery) |
static Counter |
create(String name)
Creates a new counter with the primary key.
|
static Counter |
fetchByPrimaryKey(String name)
Returns the counter with the primary key or returns
null if it could not be found. |
static Map<Serializable,Counter> |
fetchByPrimaryKeys(Set<Serializable> primaryKeys) |
static List<Counter> |
findAll()
Returns all the counters.
|
static List<Counter> |
findAll(int start,
int end)
Returns a range of all the counters.
|
static List<Counter> |
findAll(int start,
int end,
OrderByComparator<Counter> orderByComparator)
Returns an ordered range of all the counters.
|
static List<Counter> |
findAll(int start,
int end,
OrderByComparator<Counter> orderByComparator,
boolean retrieveFromCache)
Returns an ordered range of all the counters.
|
static Counter |
findByPrimaryKey(String name)
Returns the counter with the primary key or throws a
NoSuchCounterException if it could not be found. |
static List<Counter> |
findWithDynamicQuery(DynamicQuery dynamicQuery) |
static List<Counter> |
findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end) |
static List<Counter> |
findWithDynamicQuery(DynamicQuery dynamicQuery,
int start,
int end,
OrderByComparator<Counter> orderByComparator) |
static CounterPersistence |
getPersistence() |
static Counter |
remove(String name)
Removes the counter with the primary key from the database.
|
static void |
removeAll()
Removes all the counters from the database.
|
static Counter |
update(Counter counter) |
static Counter |
update(Counter counter,
ServiceContext serviceContext) |
static Counter |
updateImpl(Counter counter) |
public static void clearCache()
BasePersistence.clearCache()
public static void clearCache(Counter counter)
public static long countWithDynamicQuery(DynamicQuery dynamicQuery)
public static List<Counter> findWithDynamicQuery(DynamicQuery dynamicQuery)
public static List<Counter> findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end)
public static List<Counter> findWithDynamicQuery(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<Counter> orderByComparator)
public static Counter update(Counter counter, ServiceContext serviceContext)
public static void cacheResult(Counter counter)
counter
- the counterpublic static void cacheResult(List<Counter> counters)
counters
- the counterspublic static Counter create(String name)
name
- the primary key for the new counterpublic static Counter remove(String name) throws NoSuchCounterException
name
- the primary key of the counterNoSuchCounterException
- if a counter with the primary key could not be foundpublic static Counter findByPrimaryKey(String name) throws NoSuchCounterException
NoSuchCounterException
if it could not be found.name
- the primary key of the counterNoSuchCounterException
- if a counter with the primary key could not be foundpublic static Counter fetchByPrimaryKey(String name)
null
if it could not be found.name
- the primary key of the counternull
if a counter with the primary key could not be foundpublic static Map<Serializable,Counter> fetchByPrimaryKeys(Set<Serializable> primaryKeys)
public static List<Counter> findAll()
public static List<Counter> 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 CounterModelImpl
. 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 countersend
- the upper bound of the range of counters (not inclusive)public static List<Counter> findAll(int start, int end, OrderByComparator<Counter> 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 CounterModelImpl
. 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 countersend
- the upper bound of the range of counters (not inclusive)orderByComparator
- the comparator to order the results by (optionally null
)public static List<Counter> findAll(int start, int end, OrderByComparator<Counter> orderByComparator, boolean retrieveFromCache)
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 CounterModelImpl
. 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 countersend
- the upper bound of the range of counters (not inclusive)orderByComparator
- the comparator to order the results by (optionally null
)retrieveFromCache
- whether to retrieve from the finder cachepublic static void removeAll()
public static int countAll()
public static CounterPersistence getPersistence()