001    /**
002     * Copyright (c) 2000-2011 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#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 to cache
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 to cache
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 to remove
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            * Finds 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 to find
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            * Finds 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 to find
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            * Finds all the resources where codeId = &#63;.
198            *
199            * @param codeId the code ID to search with
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            * Finds 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 to search with
216            * @param start the lower bound of the range of resources to return
217            * @param end the upper bound of the range of resources to return (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            * Finds 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 to search with
235            * @param start the lower bound of the range of resources to return
236            * @param end the upper bound of the range of resources to return (not inclusive)
237            * @param orderByComparator the comparator to order the results by
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            * Finds 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 to search with
257            * @param orderByComparator the comparator to order the set by
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            * Finds 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 to search with
278            * @param orderByComparator the comparator to order the set by
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            * Finds 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 to search with
300            * @param orderByComparator the comparator to order the set by
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            * Finds 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 to search with
319            * @param primKey the prim key to search with
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            * Finds 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 to search with
335            * @param primKey the prim key to search with
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            * Finds 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 to search with
349            * @param primKey the prim key to search with
350            * @return the matching resource, or <code>null</code> if a matching resource could not be found
351            * @throws SystemException if a system exception occurred
352            */
353            public static com.liferay.portal.model.Resource fetchByC_P(long codeId,
354                    java.lang.String primKey, boolean retrieveFromCache)
355                    throws com.liferay.portal.kernel.exception.SystemException {
356                    return getPersistence().fetchByC_P(codeId, primKey, retrieveFromCache);
357            }
358    
359            /**
360            * Finds all the resources.
361            *
362            * @return the resources
363            * @throws SystemException if a system exception occurred
364            */
365            public static java.util.List<com.liferay.portal.model.Resource> findAll()
366                    throws com.liferay.portal.kernel.exception.SystemException {
367                    return getPersistence().findAll();
368            }
369    
370            /**
371            * Finds a range of all the resources.
372            *
373            * <p>
374            * 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.
375            * </p>
376            *
377            * @param start the lower bound of the range of resources to return
378            * @param end the upper bound of the range of resources to return (not inclusive)
379            * @return the range of resources
380            * @throws SystemException if a system exception occurred
381            */
382            public static java.util.List<com.liferay.portal.model.Resource> findAll(
383                    int start, int end)
384                    throws com.liferay.portal.kernel.exception.SystemException {
385                    return getPersistence().findAll(start, end);
386            }
387    
388            /**
389            * Finds an ordered range of all the resources.
390            *
391            * <p>
392            * 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.
393            * </p>
394            *
395            * @param start the lower bound of the range of resources to return
396            * @param end the upper bound of the range of resources to return (not inclusive)
397            * @param orderByComparator the comparator to order the results by
398            * @return the ordered range of resources
399            * @throws SystemException if a system exception occurred
400            */
401            public static java.util.List<com.liferay.portal.model.Resource> findAll(
402                    int start, int end,
403                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
404                    throws com.liferay.portal.kernel.exception.SystemException {
405                    return getPersistence().findAll(start, end, orderByComparator);
406            }
407    
408            /**
409            * Removes all the resources where codeId = &#63; from the database.
410            *
411            * @param codeId the code ID to search with
412            * @throws SystemException if a system exception occurred
413            */
414            public static void removeByCodeId(long codeId)
415                    throws com.liferay.portal.kernel.exception.SystemException {
416                    getPersistence().removeByCodeId(codeId);
417            }
418    
419            /**
420            * Removes the resource where codeId = &#63; and primKey = &#63; from the database.
421            *
422            * @param codeId the code ID to search with
423            * @param primKey the prim key to search with
424            * @throws SystemException if a system exception occurred
425            */
426            public static void removeByC_P(long codeId, java.lang.String primKey)
427                    throws com.liferay.portal.NoSuchResourceException,
428                            com.liferay.portal.kernel.exception.SystemException {
429                    getPersistence().removeByC_P(codeId, primKey);
430            }
431    
432            /**
433            * Removes all the resources from the database.
434            *
435            * @throws SystemException if a system exception occurred
436            */
437            public static void removeAll()
438                    throws com.liferay.portal.kernel.exception.SystemException {
439                    getPersistence().removeAll();
440            }
441    
442            /**
443            * Counts all the resources where codeId = &#63;.
444            *
445            * @param codeId the code ID to search with
446            * @return the number of matching resources
447            * @throws SystemException if a system exception occurred
448            */
449            public static int countByCodeId(long codeId)
450                    throws com.liferay.portal.kernel.exception.SystemException {
451                    return getPersistence().countByCodeId(codeId);
452            }
453    
454            /**
455            * Counts all the resources where codeId = &#63; and primKey = &#63;.
456            *
457            * @param codeId the code ID to search with
458            * @param primKey the prim key to search with
459            * @return the number of matching resources
460            * @throws SystemException if a system exception occurred
461            */
462            public static int countByC_P(long codeId, java.lang.String primKey)
463                    throws com.liferay.portal.kernel.exception.SystemException {
464                    return getPersistence().countByC_P(codeId, primKey);
465            }
466    
467            /**
468            * Counts all the resources.
469            *
470            * @return the number of resources
471            * @throws SystemException if a system exception occurred
472            */
473            public static int countAll()
474                    throws com.liferay.portal.kernel.exception.SystemException {
475                    return getPersistence().countAll();
476            }
477    
478            public static ResourcePersistence getPersistence() {
479                    if (_persistence == null) {
480                            _persistence = (ResourcePersistence)PortalBeanLocatorUtil.locate(ResourcePersistence.class.getName());
481    
482                            ReferenceRegistry.registerReference(ResourceUtil.class,
483                                    "_persistence");
484                    }
485    
486                    return _persistence;
487            }
488    
489            public void setPersistence(ResourcePersistence persistence) {
490                    _persistence = persistence;
491    
492                    ReferenceRegistry.registerReference(ResourceUtil.class, "_persistence");
493            }
494    
495            private static ResourcePersistence _persistence;
496    }