001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.counter.service.persistence;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.counter.model.Counter;
020    
021    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
022    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
023    import com.liferay.portal.kernel.util.OrderByComparator;
024    import com.liferay.portal.kernel.util.ReferenceRegistry;
025    import com.liferay.portal.service.ServiceContext;
026    
027    import java.util.List;
028    
029    /**
030     * The persistence utility for the counter service. This utility wraps {@link com.liferay.counter.service.persistence.impl.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.
031     *
032     * <p>
033     * Caching information and settings can be found in <code>portal.properties</code>
034     * </p>
035     *
036     * @author Brian Wing Shun Chan
037     * @see CounterPersistence
038     * @see com.liferay.counter.service.persistence.impl.CounterPersistenceImpl
039     * @generated
040     */
041    @ProviderType
042    public class CounterUtil {
043            /*
044             * NOTE FOR DEVELOPERS:
045             *
046             * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
047             */
048    
049            /**
050             * @see com.liferay.portal.service.persistence.BasePersistence#clearCache()
051             */
052            public static void clearCache() {
053                    getPersistence().clearCache();
054            }
055    
056            /**
057             * @see com.liferay.portal.service.persistence.BasePersistence#clearCache(com.liferay.portal.model.BaseModel)
058             */
059            public static void clearCache(Counter counter) {
060                    getPersistence().clearCache(counter);
061            }
062    
063            /**
064             * @see com.liferay.portal.service.persistence.BasePersistence#countWithDynamicQuery(DynamicQuery)
065             */
066            public static long countWithDynamicQuery(DynamicQuery dynamicQuery) {
067                    return getPersistence().countWithDynamicQuery(dynamicQuery);
068            }
069    
070            /**
071             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery)
072             */
073            public static List<Counter> findWithDynamicQuery(DynamicQuery dynamicQuery) {
074                    return getPersistence().findWithDynamicQuery(dynamicQuery);
075            }
076    
077            /**
078             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int)
079             */
080            public static List<Counter> findWithDynamicQuery(
081                    DynamicQuery dynamicQuery, int start, int end) {
082                    return getPersistence().findWithDynamicQuery(dynamicQuery, start, end);
083            }
084    
085            /**
086             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int, OrderByComparator)
087             */
088            public static List<Counter> findWithDynamicQuery(
089                    DynamicQuery dynamicQuery, int start, int end,
090                    OrderByComparator<Counter> orderByComparator) {
091                    return getPersistence()
092                                       .findWithDynamicQuery(dynamicQuery, start, end,
093                            orderByComparator);
094            }
095    
096            /**
097             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel)
098             */
099            public static Counter update(Counter counter) {
100                    return getPersistence().update(counter);
101            }
102    
103            /**
104             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, ServiceContext)
105             */
106            public static Counter update(Counter counter, ServiceContext serviceContext) {
107                    return getPersistence().update(counter, serviceContext);
108            }
109    
110            /**
111            * Caches the counter in the entity cache if it is enabled.
112            *
113            * @param counter the counter
114            */
115            public static void cacheResult(Counter counter) {
116                    getPersistence().cacheResult(counter);
117            }
118    
119            /**
120            * Caches the counters in the entity cache if it is enabled.
121            *
122            * @param counters the counters
123            */
124            public static void cacheResult(List<Counter> counters) {
125                    getPersistence().cacheResult(counters);
126            }
127    
128            /**
129            * Creates a new counter with the primary key. Does not add the counter to the database.
130            *
131            * @param name the primary key for the new counter
132            * @return the new counter
133            */
134            public static Counter create(java.lang.String name) {
135                    return getPersistence().create(name);
136            }
137    
138            /**
139            * Removes the counter with the primary key from the database. Also notifies the appropriate model listeners.
140            *
141            * @param name the primary key of the counter
142            * @return the counter that was removed
143            * @throws NoSuchCounterException if a counter with the primary key could not be found
144            */
145            public static Counter remove(java.lang.String name)
146                    throws com.liferay.counter.exception.NoSuchCounterException {
147                    return getPersistence().remove(name);
148            }
149    
150            public static Counter updateImpl(Counter counter) {
151                    return getPersistence().updateImpl(counter);
152            }
153    
154            /**
155            * Returns the counter with the primary key or throws a {@link NoSuchCounterException} if it could not be found.
156            *
157            * @param name the primary key of the counter
158            * @return the counter
159            * @throws NoSuchCounterException if a counter with the primary key could not be found
160            */
161            public static Counter findByPrimaryKey(java.lang.String name)
162                    throws com.liferay.counter.exception.NoSuchCounterException {
163                    return getPersistence().findByPrimaryKey(name);
164            }
165    
166            /**
167            * Returns the counter with the primary key or returns <code>null</code> if it could not be found.
168            *
169            * @param name the primary key of the counter
170            * @return the counter, or <code>null</code> if a counter with the primary key could not be found
171            */
172            public static Counter fetchByPrimaryKey(java.lang.String name) {
173                    return getPersistence().fetchByPrimaryKey(name);
174            }
175    
176            public static java.util.Map<java.io.Serializable, Counter> fetchByPrimaryKeys(
177                    java.util.Set<java.io.Serializable> primaryKeys) {
178                    return getPersistence().fetchByPrimaryKeys(primaryKeys);
179            }
180    
181            /**
182            * Returns all the counters.
183            *
184            * @return the counters
185            */
186            public static List<Counter> findAll() {
187                    return getPersistence().findAll();
188            }
189    
190            /**
191            * Returns a range of all the counters.
192            *
193            * <p>
194            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CounterModelImpl}. If both <code>orderByComparator</code> 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.
195            * </p>
196            *
197            * @param start the lower bound of the range of counters
198            * @param end the upper bound of the range of counters (not inclusive)
199            * @return the range of counters
200            */
201            public static List<Counter> findAll(int start, int end) {
202                    return getPersistence().findAll(start, end);
203            }
204    
205            /**
206            * Returns an ordered range of all the counters.
207            *
208            * <p>
209            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CounterModelImpl}. If both <code>orderByComparator</code> 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.
210            * </p>
211            *
212            * @param start the lower bound of the range of counters
213            * @param end the upper bound of the range of counters (not inclusive)
214            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
215            * @return the ordered range of counters
216            */
217            public static List<Counter> findAll(int start, int end,
218                    OrderByComparator<Counter> orderByComparator) {
219                    return getPersistence().findAll(start, end, orderByComparator);
220            }
221    
222            /**
223            * Returns an ordered range of all the counters.
224            *
225            * <p>
226            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CounterModelImpl}. If both <code>orderByComparator</code> 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.
227            * </p>
228            *
229            * @param start the lower bound of the range of counters
230            * @param end the upper bound of the range of counters (not inclusive)
231            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
232            * @param retrieveFromCache whether to retrieve from the finder cache
233            * @return the ordered range of counters
234            */
235            public static List<Counter> findAll(int start, int end,
236                    OrderByComparator<Counter> orderByComparator, boolean retrieveFromCache) {
237                    return getPersistence()
238                                       .findAll(start, end, orderByComparator, retrieveFromCache);
239            }
240    
241            /**
242            * Removes all the counters from the database.
243            */
244            public static void removeAll() {
245                    getPersistence().removeAll();
246            }
247    
248            /**
249            * Returns the number of counters.
250            *
251            * @return the number of counters
252            */
253            public static int countAll() {
254                    return getPersistence().countAll();
255            }
256    
257            public static CounterPersistence getPersistence() {
258                    if (_persistence == null) {
259                            _persistence = (CounterPersistence)PortalBeanLocatorUtil.locate(CounterPersistence.class.getName());
260    
261                            ReferenceRegistry.registerReference(CounterUtil.class,
262                                    "_persistence");
263                    }
264    
265                    return _persistence;
266            }
267    
268            private static CounterPersistence _persistence;
269    }