001    /**
002     * Copyright (c) 2000-2011 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.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#remove(com.liferay.portal.model.BaseModel)
098             */
099            public static Resource remove(Resource resource) throws SystemException {
100                    return getPersistence().remove(resource);
101            }
102    
103            /**
104             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)
105             */
106            public static Resource update(Resource resource, boolean merge)
107                    throws SystemException {
108                    return getPersistence().update(resource, merge);
109            }
110    
111            /**
112             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, boolean, ServiceContext)
113             */
114            public static Resource update(Resource resource, boolean merge,
115                    ServiceContext serviceContext) throws SystemException {
116                    return getPersistence().update(resource, merge, serviceContext);
117            }
118    
119            /**
120            * Caches the resource in the entity cache if it is enabled.
121            *
122            * @param resource the resource
123            */
124            public static void cacheResult(com.liferay.portal.model.Resource resource) {
125                    getPersistence().cacheResult(resource);
126            }
127    
128            /**
129            * Caches the resources in the entity cache if it is enabled.
130            *
131            * @param resources the resources
132            */
133            public static void cacheResult(
134                    java.util.List<com.liferay.portal.model.Resource> resources) {
135                    getPersistence().cacheResult(resources);
136            }
137    
138            /**
139            * Creates a new resource with the primary key. Does not add the resource to the database.
140            *
141            * @param resourceId the primary key for the new resource
142            * @return the new resource
143            */
144            public static com.liferay.portal.model.Resource create(long resourceId) {
145                    return getPersistence().create(resourceId);
146            }
147    
148            /**
149            * Removes the resource with the primary key from the database. Also notifies the appropriate model listeners.
150            *
151            * @param resourceId the primary key of the resource
152            * @return the resource that was removed
153            * @throws com.liferay.portal.NoSuchResourceException if a resource with the primary key could not be found
154            * @throws SystemException if a system exception occurred
155            */
156            public static com.liferay.portal.model.Resource remove(long resourceId)
157                    throws com.liferay.portal.NoSuchResourceException,
158                            com.liferay.portal.kernel.exception.SystemException {
159                    return getPersistence().remove(resourceId);
160            }
161    
162            public static com.liferay.portal.model.Resource updateImpl(
163                    com.liferay.portal.model.Resource resource, boolean merge)
164                    throws com.liferay.portal.kernel.exception.SystemException {
165                    return getPersistence().updateImpl(resource, merge);
166            }
167    
168            /**
169            * Returns the resource with the primary key or throws a {@link com.liferay.portal.NoSuchResourceException} if it could not be found.
170            *
171            * @param resourceId the primary key of the resource
172            * @return the resource
173            * @throws com.liferay.portal.NoSuchResourceException if a resource with the primary key could not be found
174            * @throws SystemException if a system exception occurred
175            */
176            public static com.liferay.portal.model.Resource findByPrimaryKey(
177                    long resourceId)
178                    throws com.liferay.portal.NoSuchResourceException,
179                            com.liferay.portal.kernel.exception.SystemException {
180                    return getPersistence().findByPrimaryKey(resourceId);
181            }
182    
183            /**
184            * Returns the resource with the primary key or returns <code>null</code> if it could not be found.
185            *
186            * @param resourceId the primary key of the resource
187            * @return the resource, or <code>null</code> if a resource with the primary key could not be found
188            * @throws SystemException if a system exception occurred
189            */
190            public static com.liferay.portal.model.Resource fetchByPrimaryKey(
191                    long resourceId)
192                    throws com.liferay.portal.kernel.exception.SystemException {
193                    return getPersistence().fetchByPrimaryKey(resourceId);
194            }
195    
196            /**
197            * Returns all the resources where codeId = &#63;.
198            *
199            * @param codeId the code ID
200            * @return the matching resources
201            * @throws SystemException if a system exception occurred
202            */
203            public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
204                    long codeId) throws com.liferay.portal.kernel.exception.SystemException {
205                    return getPersistence().findByCodeId(codeId);
206            }
207    
208            /**
209            * Returns a range of all the resources where codeId = &#63;.
210            *
211            * <p>
212            * 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.
213            * </p>
214            *
215            * @param codeId the code ID
216            * @param start the lower bound of the range of resources
217            * @param end the upper bound of the range of resources (not inclusive)
218            * @return the range of matching resources
219            * @throws SystemException if a system exception occurred
220            */
221            public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
222                    long codeId, int start, int end)
223                    throws com.liferay.portal.kernel.exception.SystemException {
224                    return getPersistence().findByCodeId(codeId, start, end);
225            }
226    
227            /**
228            * Returns an ordered range of all the resources where codeId = &#63;.
229            *
230            * <p>
231            * 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.
232            * </p>
233            *
234            * @param codeId the code ID
235            * @param start the lower bound of the range of resources
236            * @param end the upper bound of the range of resources (not inclusive)
237            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
238            * @return the ordered range of matching resources
239            * @throws SystemException if a system exception occurred
240            */
241            public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
242                    long codeId, int start, int end,
243                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
244                    throws com.liferay.portal.kernel.exception.SystemException {
245                    return getPersistence()
246                                       .findByCodeId(codeId, start, end, orderByComparator);
247            }
248    
249            /**
250            * Returns the first resource in the ordered set where codeId = &#63;.
251            *
252            * <p>
253            * 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.
254            * </p>
255            *
256            * @param codeId the code ID
257            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
258            * @return the first matching resource
259            * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found
260            * @throws SystemException if a system exception occurred
261            */
262            public static com.liferay.portal.model.Resource findByCodeId_First(
263                    long codeId,
264                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
265                    throws com.liferay.portal.NoSuchResourceException,
266                            com.liferay.portal.kernel.exception.SystemException {
267                    return getPersistence().findByCodeId_First(codeId, orderByComparator);
268            }
269    
270            /**
271            * Returns the last resource in the ordered set where codeId = &#63;.
272            *
273            * <p>
274            * 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.
275            * </p>
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 resources before and after the current resource in the ordered set where codeId = &#63;.
293            *
294            * <p>
295            * 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.
296            * </p>
297            *
298            * @param resourceId the primary key of the current resource
299            * @param codeId the code ID
300            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
301            * @return the previous, current, and next resource
302            * @throws com.liferay.portal.NoSuchResourceException if a resource with the primary key could not be found
303            * @throws SystemException if a system exception occurred
304            */
305            public static com.liferay.portal.model.Resource[] findByCodeId_PrevAndNext(
306                    long resourceId, long codeId,
307                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
308                    throws com.liferay.portal.NoSuchResourceException,
309                            com.liferay.portal.kernel.exception.SystemException {
310                    return getPersistence()
311                                       .findByCodeId_PrevAndNext(resourceId, codeId,
312                            orderByComparator);
313            }
314    
315            /**
316            * Returns the resource where codeId = &#63; and primKey = &#63; or throws a {@link com.liferay.portal.NoSuchResourceException} if it could not be found.
317            *
318            * @param codeId the code ID
319            * @param primKey the prim key
320            * @return the matching resource
321            * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found
322            * @throws SystemException if a system exception occurred
323            */
324            public static com.liferay.portal.model.Resource findByC_P(long codeId,
325                    java.lang.String primKey)
326                    throws com.liferay.portal.NoSuchResourceException,
327                            com.liferay.portal.kernel.exception.SystemException {
328                    return getPersistence().findByC_P(codeId, primKey);
329            }
330    
331            /**
332            * Returns the resource where codeId = &#63; and primKey = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
333            *
334            * @param codeId the code ID
335            * @param primKey the prim key
336            * @return the matching resource, or <code>null</code> if a matching resource could not be found
337            * @throws SystemException if a system exception occurred
338            */
339            public static com.liferay.portal.model.Resource fetchByC_P(long codeId,
340                    java.lang.String primKey)
341                    throws com.liferay.portal.kernel.exception.SystemException {
342                    return getPersistence().fetchByC_P(codeId, primKey);
343            }
344    
345            /**
346            * 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.
347            *
348            * @param codeId the code ID
349            * @param primKey the prim key
350            * @param retrieveFromCache whether to use the finder cache
351            * @return the matching resource, or <code>null</code> if a matching resource could not be found
352            * @throws SystemException if a system exception occurred
353            */
354            public static com.liferay.portal.model.Resource fetchByC_P(long codeId,
355                    java.lang.String primKey, boolean retrieveFromCache)
356                    throws com.liferay.portal.kernel.exception.SystemException {
357                    return getPersistence().fetchByC_P(codeId, primKey, retrieveFromCache);
358            }
359    
360            /**
361            * Returns all the resources.
362            *
363            * @return the resources
364            * @throws SystemException if a system exception occurred
365            */
366            public static java.util.List<com.liferay.portal.model.Resource> findAll()
367                    throws com.liferay.portal.kernel.exception.SystemException {
368                    return getPersistence().findAll();
369            }
370    
371            /**
372            * Returns a range of all the resources.
373            *
374            * <p>
375            * 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.
376            * </p>
377            *
378            * @param start the lower bound of the range of resources
379            * @param end the upper bound of the range of resources (not inclusive)
380            * @return the range of resources
381            * @throws SystemException if a system exception occurred
382            */
383            public static java.util.List<com.liferay.portal.model.Resource> findAll(
384                    int start, int end)
385                    throws com.liferay.portal.kernel.exception.SystemException {
386                    return getPersistence().findAll(start, end);
387            }
388    
389            /**
390            * Returns an ordered range of all the resources.
391            *
392            * <p>
393            * 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.
394            * </p>
395            *
396            * @param start the lower bound of the range of resources
397            * @param end the upper bound of the range of resources (not inclusive)
398            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
399            * @return the ordered range of resources
400            * @throws SystemException if a system exception occurred
401            */
402            public static java.util.List<com.liferay.portal.model.Resource> findAll(
403                    int start, int end,
404                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
405                    throws com.liferay.portal.kernel.exception.SystemException {
406                    return getPersistence().findAll(start, end, orderByComparator);
407            }
408    
409            /**
410            * Removes all the resources where codeId = &#63; from the database.
411            *
412            * @param codeId the code ID
413            * @throws SystemException if a system exception occurred
414            */
415            public static void removeByCodeId(long codeId)
416                    throws com.liferay.portal.kernel.exception.SystemException {
417                    getPersistence().removeByCodeId(codeId);
418            }
419    
420            /**
421            * Removes the resource where codeId = &#63; and primKey = &#63; from the database.
422            *
423            * @param codeId the code ID
424            * @param primKey the prim key
425            * @throws SystemException if a system exception occurred
426            */
427            public static void removeByC_P(long codeId, java.lang.String primKey)
428                    throws com.liferay.portal.NoSuchResourceException,
429                            com.liferay.portal.kernel.exception.SystemException {
430                    getPersistence().removeByC_P(codeId, primKey);
431            }
432    
433            /**
434            * Removes all the resources from the database.
435            *
436            * @throws SystemException if a system exception occurred
437            */
438            public static void removeAll()
439                    throws com.liferay.portal.kernel.exception.SystemException {
440                    getPersistence().removeAll();
441            }
442    
443            /**
444            * Returns the number of resources where codeId = &#63;.
445            *
446            * @param codeId the code ID
447            * @return the number of matching resources
448            * @throws SystemException if a system exception occurred
449            */
450            public static int countByCodeId(long codeId)
451                    throws com.liferay.portal.kernel.exception.SystemException {
452                    return getPersistence().countByCodeId(codeId);
453            }
454    
455            /**
456            * Returns the number of resources where codeId = &#63; and primKey = &#63;.
457            *
458            * @param codeId the code ID
459            * @param primKey the prim key
460            * @return the number of matching resources
461            * @throws SystemException if a system exception occurred
462            */
463            public static int countByC_P(long codeId, java.lang.String primKey)
464                    throws com.liferay.portal.kernel.exception.SystemException {
465                    return getPersistence().countByC_P(codeId, primKey);
466            }
467    
468            /**
469            * Returns the number of resources.
470            *
471            * @return the number of resources
472            * @throws SystemException if a system exception occurred
473            */
474            public static int countAll()
475                    throws com.liferay.portal.kernel.exception.SystemException {
476                    return getPersistence().countAll();
477            }
478    
479            public static ResourcePersistence getPersistence() {
480                    if (_persistence == null) {
481                            _persistence = (ResourcePersistence)PortalBeanLocatorUtil.locate(ResourcePersistence.class.getName());
482    
483                            ReferenceRegistry.registerReference(ResourceUtil.class,
484                                    "_persistence");
485                    }
486    
487                    return _persistence;
488            }
489    
490            public void setPersistence(ResourcePersistence persistence) {
491                    _persistence = persistence;
492    
493                    ReferenceRegistry.registerReference(ResourceUtil.class, "_persistence");
494            }
495    
496            private static ResourcePersistence _persistence;
497    }