001 /** 002 * Copyright (c) 2000-2012 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#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 = ?. 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 = ?. 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 = ?. 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 = ?. 244 * 245 * <p> 246 * 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. 247 * </p> 248 * 249 * @param codeId the code ID 250 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 251 * @return the first matching resource 252 * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found 253 * @throws SystemException if a system exception occurred 254 */ 255 public static com.liferay.portal.model.Resource findByCodeId_First( 256 long codeId, 257 com.liferay.portal.kernel.util.OrderByComparator orderByComparator) 258 throws com.liferay.portal.NoSuchResourceException, 259 com.liferay.portal.kernel.exception.SystemException { 260 return getPersistence().findByCodeId_First(codeId, orderByComparator); 261 } 262 263 /** 264 * Returns the last resource in the ordered set where codeId = ?. 265 * 266 * <p> 267 * 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. 268 * </p> 269 * 270 * @param codeId the code ID 271 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 272 * @return the last matching resource 273 * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found 274 * @throws SystemException if a system exception occurred 275 */ 276 public static com.liferay.portal.model.Resource findByCodeId_Last( 277 long codeId, 278 com.liferay.portal.kernel.util.OrderByComparator orderByComparator) 279 throws com.liferay.portal.NoSuchResourceException, 280 com.liferay.portal.kernel.exception.SystemException { 281 return getPersistence().findByCodeId_Last(codeId, orderByComparator); 282 } 283 284 /** 285 * Returns the resources before and after the current resource in the ordered set where codeId = ?. 286 * 287 * <p> 288 * 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. 289 * </p> 290 * 291 * @param resourceId the primary key of the current resource 292 * @param codeId the code ID 293 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 294 * @return the previous, current, and next resource 295 * @throws com.liferay.portal.NoSuchResourceException if a resource with the primary key could not be found 296 * @throws SystemException if a system exception occurred 297 */ 298 public static com.liferay.portal.model.Resource[] findByCodeId_PrevAndNext( 299 long resourceId, long codeId, 300 com.liferay.portal.kernel.util.OrderByComparator orderByComparator) 301 throws com.liferay.portal.NoSuchResourceException, 302 com.liferay.portal.kernel.exception.SystemException { 303 return getPersistence() 304 .findByCodeId_PrevAndNext(resourceId, codeId, 305 orderByComparator); 306 } 307 308 /** 309 * Returns the resource where codeId = ? and primKey = ? or throws a {@link com.liferay.portal.NoSuchResourceException} if it could not be found. 310 * 311 * @param codeId the code ID 312 * @param primKey the prim key 313 * @return the matching resource 314 * @throws com.liferay.portal.NoSuchResourceException if a matching resource could not be found 315 * @throws SystemException if a system exception occurred 316 */ 317 public static com.liferay.portal.model.Resource findByC_P(long codeId, 318 java.lang.String primKey) 319 throws com.liferay.portal.NoSuchResourceException, 320 com.liferay.portal.kernel.exception.SystemException { 321 return getPersistence().findByC_P(codeId, primKey); 322 } 323 324 /** 325 * Returns the resource where codeId = ? and primKey = ? or returns <code>null</code> if it could not be found. Uses the finder cache. 326 * 327 * @param codeId the code ID 328 * @param primKey the prim key 329 * @return the matching resource, or <code>null</code> if a matching resource could not be found 330 * @throws SystemException if a system exception occurred 331 */ 332 public static com.liferay.portal.model.Resource fetchByC_P(long codeId, 333 java.lang.String primKey) 334 throws com.liferay.portal.kernel.exception.SystemException { 335 return getPersistence().fetchByC_P(codeId, primKey); 336 } 337 338 /** 339 * Returns the resource where codeId = ? and primKey = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. 340 * 341 * @param codeId the code ID 342 * @param primKey the prim key 343 * @param retrieveFromCache whether to use the finder cache 344 * @return the matching resource, or <code>null</code> if a matching resource could not be found 345 * @throws SystemException if a system exception occurred 346 */ 347 public static com.liferay.portal.model.Resource fetchByC_P(long codeId, 348 java.lang.String primKey, boolean retrieveFromCache) 349 throws com.liferay.portal.kernel.exception.SystemException { 350 return getPersistence().fetchByC_P(codeId, primKey, retrieveFromCache); 351 } 352 353 /** 354 * Returns all the resources. 355 * 356 * @return the resources 357 * @throws SystemException if a system exception occurred 358 */ 359 public static java.util.List<com.liferay.portal.model.Resource> findAll() 360 throws com.liferay.portal.kernel.exception.SystemException { 361 return getPersistence().findAll(); 362 } 363 364 /** 365 * Returns a range of all the resources. 366 * 367 * <p> 368 * 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. 369 * </p> 370 * 371 * @param start the lower bound of the range of resources 372 * @param end the upper bound of the range of resources (not inclusive) 373 * @return the range of resources 374 * @throws SystemException if a system exception occurred 375 */ 376 public static java.util.List<com.liferay.portal.model.Resource> findAll( 377 int start, int end) 378 throws com.liferay.portal.kernel.exception.SystemException { 379 return getPersistence().findAll(start, end); 380 } 381 382 /** 383 * Returns an ordered 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 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 392 * @return the ordered range of resources 393 * @throws SystemException if a system exception occurred 394 */ 395 public static java.util.List<com.liferay.portal.model.Resource> findAll( 396 int start, int end, 397 com.liferay.portal.kernel.util.OrderByComparator orderByComparator) 398 throws com.liferay.portal.kernel.exception.SystemException { 399 return getPersistence().findAll(start, end, orderByComparator); 400 } 401 402 /** 403 * Removes all the resources where codeId = ? from the database. 404 * 405 * @param codeId the code ID 406 * @throws SystemException if a system exception occurred 407 */ 408 public static void removeByCodeId(long codeId) 409 throws com.liferay.portal.kernel.exception.SystemException { 410 getPersistence().removeByCodeId(codeId); 411 } 412 413 /** 414 * Removes the resource where codeId = ? and primKey = ? from the database. 415 * 416 * @param codeId the code ID 417 * @param primKey the prim key 418 * @throws SystemException if a system exception occurred 419 */ 420 public static void removeByC_P(long codeId, java.lang.String primKey) 421 throws com.liferay.portal.NoSuchResourceException, 422 com.liferay.portal.kernel.exception.SystemException { 423 getPersistence().removeByC_P(codeId, primKey); 424 } 425 426 /** 427 * Removes all the resources from the database. 428 * 429 * @throws SystemException if a system exception occurred 430 */ 431 public static void removeAll() 432 throws com.liferay.portal.kernel.exception.SystemException { 433 getPersistence().removeAll(); 434 } 435 436 /** 437 * Returns the number of resources where codeId = ?. 438 * 439 * @param codeId the code ID 440 * @return the number of matching resources 441 * @throws SystemException if a system exception occurred 442 */ 443 public static int countByCodeId(long codeId) 444 throws com.liferay.portal.kernel.exception.SystemException { 445 return getPersistence().countByCodeId(codeId); 446 } 447 448 /** 449 * Returns the number of resources where codeId = ? and primKey = ?. 450 * 451 * @param codeId the code ID 452 * @param primKey the prim key 453 * @return the number of matching resources 454 * @throws SystemException if a system exception occurred 455 */ 456 public static int countByC_P(long codeId, java.lang.String primKey) 457 throws com.liferay.portal.kernel.exception.SystemException { 458 return getPersistence().countByC_P(codeId, primKey); 459 } 460 461 /** 462 * Returns the number of resources. 463 * 464 * @return the number of resources 465 * @throws SystemException if a system exception occurred 466 */ 467 public static int countAll() 468 throws com.liferay.portal.kernel.exception.SystemException { 469 return getPersistence().countAll(); 470 } 471 472 public static ResourcePersistence getPersistence() { 473 if (_persistence == null) { 474 _persistence = (ResourcePersistence)PortalBeanLocatorUtil.locate(ResourcePersistence.class.getName()); 475 476 ReferenceRegistry.registerReference(ResourceUtil.class, 477 "_persistence"); 478 } 479 480 return _persistence; 481 } 482 483 public void setPersistence(ResourcePersistence persistence) { 484 _persistence = persistence; 485 486 ReferenceRegistry.registerReference(ResourceUtil.class, "_persistence"); 487 } 488 489 private static ResourcePersistence _persistence; 490 }