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