001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.kernel.util.OrderByComparator;
021    import com.liferay.portal.kernel.util.ReferenceRegistry;
022    import com.liferay.portal.model.Resource;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import java.util.List;
026    
027    /**
028     * The persistence utility for the resource service. This utility wraps {@link ResourcePersistenceImpl} 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.
029     *
030     * <p>
031     * Caching information and settings can be found in <code>portal.properties</code>
032     * </p>
033     *
034     * @author Brian Wing Shun Chan
035     * @see ResourcePersistence
036     * @see ResourcePersistenceImpl
037     * @generated
038     */
039    public class ResourceUtil {
040            /*
041             * NOTE FOR DEVELOPERS:
042             *
043             * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
044             */
045    
046            /**
047             * @see com.liferay.portal.service.persistence.BasePersistence#clearCache()
048             */
049            public static void clearCache() {
050                    getPersistence().clearCache();
051            }
052    
053            /**
054             * @see com.liferay.portal.service.persistence.BasePersistence#clearCache(com.liferay.portal.model.BaseModel)
055             */
056            public static void clearCache(Resource resource) {
057                    getPersistence().clearCache(resource);
058            }
059    
060            /**
061             * @see com.liferay.portal.service.persistence.BasePersistence#countWithDynamicQuery(DynamicQuery)
062             */
063            public long countWithDynamicQuery(DynamicQuery dynamicQuery)
064                    throws SystemException {
065                    return getPersistence().countWithDynamicQuery(dynamicQuery);
066            }
067    
068            /**
069             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery)
070             */
071            public static List<Resource> findWithDynamicQuery(DynamicQuery dynamicQuery)
072                    throws SystemException {
073                    return getPersistence().findWithDynamicQuery(dynamicQuery);
074            }
075    
076            /**
077             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int)
078             */
079            public static List<Resource> findWithDynamicQuery(
080                    DynamicQuery dynamicQuery, int start, int end)
081                    throws SystemException {
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<Resource> findWithDynamicQuery(
089                    DynamicQuery dynamicQuery, int start, int end,
090                    OrderByComparator orderByComparator) throws SystemException {
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, boolean)
098             */
099            public static Resource update(Resource resource, boolean merge)
100                    throws SystemException {
101                    return getPersistence().update(resource, merge);
102            }
103    
104            /**
105             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, boolean, ServiceContext)
106             */
107            public static Resource update(Resource resource, boolean merge,
108                    ServiceContext serviceContext) throws SystemException {
109                    return getPersistence().update(resource, merge, serviceContext);
110            }
111    
112            /**
113            * Caches the resource in the entity cache if it is enabled.
114            *
115            * @param resource the resource
116            */
117            public static void cacheResult(com.liferay.portal.model.Resource resource) {
118                    getPersistence().cacheResult(resource);
119            }
120    
121            /**
122            * Caches the resources in the entity cache if it is enabled.
123            *
124            * @param resources the resources
125            */
126            public static void cacheResult(
127                    java.util.List<com.liferay.portal.model.Resource> resources) {
128                    getPersistence().cacheResult(resources);
129            }
130    
131            /**
132            * Creates a new resource with the primary key. Does not add the resource to the database.
133            *
134            * @param resourceId the primary key for the new resource
135            * @return the new resource
136            */
137            public static com.liferay.portal.model.Resource create(long resourceId) {
138                    return getPersistence().create(resourceId);
139            }
140    
141            /**
142            * Removes the resource with the primary key from the database. Also notifies the appropriate model listeners.
143            *
144            * @param resourceId the primary key of the resource
145            * @return the resource that was removed
146            * @throws com.liferay.portal.NoSuchResourceException if a resource with the primary key could not be found
147            * @throws SystemException if a system exception occurred
148            */
149            public static com.liferay.portal.model.Resource remove(long resourceId)
150                    throws com.liferay.portal.NoSuchResourceException,
151                            com.liferay.portal.kernel.exception.SystemException {
152                    return getPersistence().remove(resourceId);
153            }
154    
155            public static com.liferay.portal.model.Resource updateImpl(
156                    com.liferay.portal.model.Resource resource, boolean merge)
157                    throws com.liferay.portal.kernel.exception.SystemException {
158                    return getPersistence().updateImpl(resource, merge);
159            }
160    
161            /**
162            * Returns the resource with the primary key or throws a {@link com.liferay.portal.NoSuchResourceException} if it could not be found.
163            *
164            * @param resourceId the primary key of the resource
165            * @return the resource
166            * @throws com.liferay.portal.NoSuchResourceException if a resource with the primary key could not be found
167            * @throws SystemException if a system exception occurred
168            */
169            public static com.liferay.portal.model.Resource findByPrimaryKey(
170                    long resourceId)
171                    throws com.liferay.portal.NoSuchResourceException,
172                            com.liferay.portal.kernel.exception.SystemException {
173                    return getPersistence().findByPrimaryKey(resourceId);
174            }
175    
176            /**
177            * Returns the resource with the primary key or returns <code>null</code> if it could not be found.
178            *
179            * @param resourceId the primary key of the resource
180            * @return the resource, or <code>null</code> if a resource with the primary key could not be found
181            * @throws SystemException if a system exception occurred
182            */
183            public static com.liferay.portal.model.Resource fetchByPrimaryKey(
184                    long resourceId)
185                    throws com.liferay.portal.kernel.exception.SystemException {
186                    return getPersistence().fetchByPrimaryKey(resourceId);
187            }
188    
189            /**
190            * Returns all the resources where codeId = &#63;.
191            *
192            * @param codeId the code ID
193            * @return the matching resources
194            * @throws SystemException if a system exception occurred
195            */
196            public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
197                    long codeId) throws com.liferay.portal.kernel.exception.SystemException {
198                    return getPersistence().findByCodeId(codeId);
199            }
200    
201            /**
202            * Returns a range of all the resources where codeId = &#63;.
203            *
204            * <p>
205            * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
206            * </p>
207            *
208            * @param codeId the code ID
209            * @param start the lower bound of the range of resources
210            * @param end the upper bound of the range of resources (not inclusive)
211            * @return the range of matching resources
212            * @throws SystemException if a system exception occurred
213            */
214            public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
215                    long codeId, int start, int end)
216                    throws com.liferay.portal.kernel.exception.SystemException {
217                    return getPersistence().findByCodeId(codeId, start, end);
218            }
219    
220            /**
221            * Returns an ordered range of all the resources where codeId = &#63;.
222            *
223            * <p>
224            * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
225            * </p>
226            *
227            * @param codeId the code ID
228            * @param start the lower bound of the range of resources
229            * @param end the upper bound of the range of resources (not inclusive)
230            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
231            * @return the ordered range of matching resources
232            * @throws SystemException if a system exception occurred
233            */
234            public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
235                    long codeId, int start, int end,
236                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
237                    throws com.liferay.portal.kernel.exception.SystemException {
238                    return getPersistence()
239                                       .findByCodeId(codeId, start, end, orderByComparator);
240            }
241    
242            /**
243            * Returns the first resource in the ordered set where codeId = &#63;.
244            *
245            * @param codeId the code ID
246            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
247            * @return the first matching resource
248            * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found
249            * @throws SystemException if a system exception occurred
250            */
251            public static com.liferay.portal.model.Resource findByCodeId_First(
252                    long codeId,
253                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
254                    throws com.liferay.portal.NoSuchResourceException,
255                            com.liferay.portal.kernel.exception.SystemException {
256                    return getPersistence().findByCodeId_First(codeId, orderByComparator);
257            }
258    
259            /**
260            * Returns the first resource in the ordered set where codeId = &#63;.
261            *
262            * @param codeId the code ID
263            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
264            * @return the first matching resource, or <code>null</code> if a matching resource could not be found
265            * @throws SystemException if a system exception occurred
266            */
267            public static com.liferay.portal.model.Resource fetchByCodeId_First(
268                    long codeId,
269                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
270                    throws com.liferay.portal.kernel.exception.SystemException {
271                    return getPersistence().fetchByCodeId_First(codeId, orderByComparator);
272            }
273    
274            /**
275            * Returns the last resource in the ordered set where codeId = &#63;.
276            *
277            * @param codeId the code ID
278            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
279            * @return the last matching resource
280            * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found
281            * @throws SystemException if a system exception occurred
282            */
283            public static com.liferay.portal.model.Resource findByCodeId_Last(
284                    long codeId,
285                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
286                    throws com.liferay.portal.NoSuchResourceException,
287                            com.liferay.portal.kernel.exception.SystemException {
288                    return getPersistence().findByCodeId_Last(codeId, orderByComparator);
289            }
290    
291            /**
292            * Returns the last resource in the ordered set where codeId = &#63;.
293            *
294            * @param codeId the code ID
295            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
296            * @return the last matching resource, or <code>null</code> if a matching resource could not be found
297            * @throws SystemException if a system exception occurred
298            */
299            public static com.liferay.portal.model.Resource fetchByCodeId_Last(
300                    long codeId,
301                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
302                    throws com.liferay.portal.kernel.exception.SystemException {
303                    return getPersistence().fetchByCodeId_Last(codeId, orderByComparator);
304            }
305    
306            /**
307            * Returns the resources before and after the current resource in the ordered set where codeId = &#63;.
308            *
309            * @param resourceId the primary key of the current resource
310            * @param codeId the code ID
311            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
312            * @return the previous, current, and next resource
313            * @throws com.liferay.portal.NoSuchResourceException if a resource with the primary key could not be found
314            * @throws SystemException if a system exception occurred
315            */
316            public static com.liferay.portal.model.Resource[] findByCodeId_PrevAndNext(
317                    long resourceId, long codeId,
318                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
319                    throws com.liferay.portal.NoSuchResourceException,
320                            com.liferay.portal.kernel.exception.SystemException {
321                    return getPersistence()
322                                       .findByCodeId_PrevAndNext(resourceId, codeId,
323                            orderByComparator);
324            }
325    
326            /**
327            * Returns the resource where codeId = &#63; and primKey = &#63; or throws a {@link com.liferay.portal.NoSuchResourceException} if it could not be found.
328            *
329            * @param codeId the code ID
330            * @param primKey the prim key
331            * @return the matching resource
332            * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found
333            * @throws SystemException if a system exception occurred
334            */
335            public static com.liferay.portal.model.Resource findByC_P(long codeId,
336                    java.lang.String primKey)
337                    throws com.liferay.portal.NoSuchResourceException,
338                            com.liferay.portal.kernel.exception.SystemException {
339                    return getPersistence().findByC_P(codeId, primKey);
340            }
341    
342            /**
343            * Returns the resource where codeId = &#63; and primKey = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
344            *
345            * @param codeId the code ID
346            * @param primKey the prim key
347            * @return the matching resource, or <code>null</code> if a matching resource could not be found
348            * @throws SystemException if a system exception occurred
349            */
350            public static com.liferay.portal.model.Resource fetchByC_P(long codeId,
351                    java.lang.String primKey)
352                    throws com.liferay.portal.kernel.exception.SystemException {
353                    return getPersistence().fetchByC_P(codeId, primKey);
354            }
355    
356            /**
357            * Returns the resource where codeId = &#63; and primKey = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
358            *
359            * @param codeId the code ID
360            * @param primKey the prim key
361            * @param retrieveFromCache whether to use the finder cache
362            * @return the matching resource, or <code>null</code> if a matching resource could not be found
363            * @throws SystemException if a system exception occurred
364            */
365            public static com.liferay.portal.model.Resource fetchByC_P(long codeId,
366                    java.lang.String primKey, boolean retrieveFromCache)
367                    throws com.liferay.portal.kernel.exception.SystemException {
368                    return getPersistence().fetchByC_P(codeId, primKey, retrieveFromCache);
369            }
370    
371            /**
372            * Returns all the resources.
373            *
374            * @return the resources
375            * @throws SystemException if a system exception occurred
376            */
377            public static java.util.List<com.liferay.portal.model.Resource> findAll()
378                    throws com.liferay.portal.kernel.exception.SystemException {
379                    return getPersistence().findAll();
380            }
381    
382            /**
383            * Returns a range of all the resources.
384            *
385            * <p>
386            * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
387            * </p>
388            *
389            * @param start the lower bound of the range of resources
390            * @param end the upper bound of the range of resources (not inclusive)
391            * @return the range of resources
392            * @throws SystemException if a system exception occurred
393            */
394            public static java.util.List<com.liferay.portal.model.Resource> findAll(
395                    int start, int end)
396                    throws com.liferay.portal.kernel.exception.SystemException {
397                    return getPersistence().findAll(start, end);
398            }
399    
400            /**
401            * Returns an ordered range of all the resources.
402            *
403            * <p>
404            * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
405            * </p>
406            *
407            * @param start the lower bound of the range of resources
408            * @param end the upper bound of the range of resources (not inclusive)
409            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
410            * @return the ordered range of resources
411            * @throws SystemException if a system exception occurred
412            */
413            public static java.util.List<com.liferay.portal.model.Resource> findAll(
414                    int start, int end,
415                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
416                    throws com.liferay.portal.kernel.exception.SystemException {
417                    return getPersistence().findAll(start, end, orderByComparator);
418            }
419    
420            /**
421            * Removes all the resources where codeId = &#63; from the database.
422            *
423            * @param codeId the code ID
424            * @throws SystemException if a system exception occurred
425            */
426            public static void removeByCodeId(long codeId)
427                    throws com.liferay.portal.kernel.exception.SystemException {
428                    getPersistence().removeByCodeId(codeId);
429            }
430    
431            /**
432            * Removes the resource where codeId = &#63; and primKey = &#63; from the database.
433            *
434            * @param codeId the code ID
435            * @param primKey the prim key
436            * @return the resource that was removed
437            * @throws SystemException if a system exception occurred
438            */
439            public static com.liferay.portal.model.Resource removeByC_P(long codeId,
440                    java.lang.String primKey)
441                    throws com.liferay.portal.NoSuchResourceException,
442                            com.liferay.portal.kernel.exception.SystemException {
443                    return getPersistence().removeByC_P(codeId, primKey);
444            }
445    
446            /**
447            * Removes all the resources from the database.
448            *
449            * @throws SystemException if a system exception occurred
450            */
451            public static void removeAll()
452                    throws com.liferay.portal.kernel.exception.SystemException {
453                    getPersistence().removeAll();
454            }
455    
456            /**
457            * Returns the number of resources where codeId = &#63;.
458            *
459            * @param codeId the code ID
460            * @return the number of matching resources
461            * @throws SystemException if a system exception occurred
462            */
463            public static int countByCodeId(long codeId)
464                    throws com.liferay.portal.kernel.exception.SystemException {
465                    return getPersistence().countByCodeId(codeId);
466            }
467    
468            /**
469            * Returns the number of resources where codeId = &#63; and primKey = &#63;.
470            *
471            * @param codeId the code ID
472            * @param primKey the prim key
473            * @return the number of matching resources
474            * @throws SystemException if a system exception occurred
475            */
476            public static int countByC_P(long codeId, java.lang.String primKey)
477                    throws com.liferay.portal.kernel.exception.SystemException {
478                    return getPersistence().countByC_P(codeId, primKey);
479            }
480    
481            /**
482            * Returns the number of resources.
483            *
484            * @return the number of resources
485            * @throws SystemException if a system exception occurred
486            */
487            public static int countAll()
488                    throws com.liferay.portal.kernel.exception.SystemException {
489                    return getPersistence().countAll();
490            }
491    
492            public static ResourcePersistence getPersistence() {
493                    if (_persistence == null) {
494                            _persistence = (ResourcePersistence)PortalBeanLocatorUtil.locate(ResourcePersistence.class.getName());
495    
496                            ReferenceRegistry.registerReference(ResourceUtil.class,
497                                    "_persistence");
498                    }
499    
500                    return _persistence;
501            }
502    
503            /**
504             * @deprecated
505             */
506            public void setPersistence(ResourcePersistence persistence) {
507            }
508    
509            private static ResourcePersistence _persistence;
510    }