001 /** 002 * Copyright (c) 2000-2013 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 aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; 020 import com.liferay.portal.kernel.dao.orm.DynamicQuery; 021 import com.liferay.portal.kernel.exception.SystemException; 022 import com.liferay.portal.kernel.util.OrderByComparator; 023 import com.liferay.portal.kernel.util.ReferenceRegistry; 024 import com.liferay.portal.model.Shard; 025 import com.liferay.portal.service.ServiceContext; 026 027 import java.util.List; 028 029 /** 030 * The persistence utility for the shard service. This utility wraps {@link ShardPersistenceImpl} 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. 031 * 032 * <p> 033 * Caching information and settings can be found in <code>portal.properties</code> 034 * </p> 035 * 036 * @author Brian Wing Shun Chan 037 * @see ShardPersistence 038 * @see ShardPersistenceImpl 039 * @generated 040 */ 041 @ProviderType 042 public class ShardUtil { 043 /* 044 * NOTE FOR DEVELOPERS: 045 * 046 * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. 047 */ 048 049 /** 050 * @see com.liferay.portal.service.persistence.BasePersistence#clearCache() 051 */ 052 public static void clearCache() { 053 getPersistence().clearCache(); 054 } 055 056 /** 057 * @see com.liferay.portal.service.persistence.BasePersistence#clearCache(com.liferay.portal.model.BaseModel) 058 */ 059 public static void clearCache(Shard shard) { 060 getPersistence().clearCache(shard); 061 } 062 063 /** 064 * @see com.liferay.portal.service.persistence.BasePersistence#countWithDynamicQuery(DynamicQuery) 065 */ 066 public static long countWithDynamicQuery(DynamicQuery dynamicQuery) 067 throws SystemException { 068 return getPersistence().countWithDynamicQuery(dynamicQuery); 069 } 070 071 /** 072 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery) 073 */ 074 public static List<Shard> findWithDynamicQuery(DynamicQuery dynamicQuery) 075 throws SystemException { 076 return getPersistence().findWithDynamicQuery(dynamicQuery); 077 } 078 079 /** 080 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int) 081 */ 082 public static List<Shard> findWithDynamicQuery(DynamicQuery dynamicQuery, 083 int start, int end) throws SystemException { 084 return getPersistence().findWithDynamicQuery(dynamicQuery, start, end); 085 } 086 087 /** 088 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int, OrderByComparator) 089 */ 090 public static List<Shard> findWithDynamicQuery(DynamicQuery dynamicQuery, 091 int start, int end, OrderByComparator orderByComparator) 092 throws SystemException { 093 return getPersistence() 094 .findWithDynamicQuery(dynamicQuery, start, end, 095 orderByComparator); 096 } 097 098 /** 099 * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel) 100 */ 101 public static Shard update(Shard shard) throws SystemException { 102 return getPersistence().update(shard); 103 } 104 105 /** 106 * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, ServiceContext) 107 */ 108 public static Shard update(Shard shard, ServiceContext serviceContext) 109 throws SystemException { 110 return getPersistence().update(shard, serviceContext); 111 } 112 113 /** 114 * Returns the shard where name = ? or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found. 115 * 116 * @param name the name 117 * @return the matching shard 118 * @throws com.liferay.portal.NoSuchShardException if a matching shard could not be found 119 * @throws SystemException if a system exception occurred 120 */ 121 public static com.liferay.portal.model.Shard findByName( 122 java.lang.String name) 123 throws com.liferay.portal.NoSuchShardException, 124 com.liferay.portal.kernel.exception.SystemException { 125 return getPersistence().findByName(name); 126 } 127 128 /** 129 * Returns the shard where name = ? or returns <code>null</code> if it could not be found. Uses the finder cache. 130 * 131 * @param name the name 132 * @return the matching shard, or <code>null</code> if a matching shard could not be found 133 * @throws SystemException if a system exception occurred 134 */ 135 public static com.liferay.portal.model.Shard fetchByName( 136 java.lang.String name) 137 throws com.liferay.portal.kernel.exception.SystemException { 138 return getPersistence().fetchByName(name); 139 } 140 141 /** 142 * Returns the shard where name = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. 143 * 144 * @param name the name 145 * @param retrieveFromCache whether to use the finder cache 146 * @return the matching shard, or <code>null</code> if a matching shard could not be found 147 * @throws SystemException if a system exception occurred 148 */ 149 public static com.liferay.portal.model.Shard fetchByName( 150 java.lang.String name, boolean retrieveFromCache) 151 throws com.liferay.portal.kernel.exception.SystemException { 152 return getPersistence().fetchByName(name, retrieveFromCache); 153 } 154 155 /** 156 * Removes the shard where name = ? from the database. 157 * 158 * @param name the name 159 * @return the shard that was removed 160 * @throws SystemException if a system exception occurred 161 */ 162 public static com.liferay.portal.model.Shard removeByName( 163 java.lang.String name) 164 throws com.liferay.portal.NoSuchShardException, 165 com.liferay.portal.kernel.exception.SystemException { 166 return getPersistence().removeByName(name); 167 } 168 169 /** 170 * Returns the number of shards where name = ?. 171 * 172 * @param name the name 173 * @return the number of matching shards 174 * @throws SystemException if a system exception occurred 175 */ 176 public static int countByName(java.lang.String name) 177 throws com.liferay.portal.kernel.exception.SystemException { 178 return getPersistence().countByName(name); 179 } 180 181 /** 182 * Returns the shard where classNameId = ? and classPK = ? or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found. 183 * 184 * @param classNameId the class name ID 185 * @param classPK the class p k 186 * @return the matching shard 187 * @throws com.liferay.portal.NoSuchShardException if a matching shard could not be found 188 * @throws SystemException if a system exception occurred 189 */ 190 public static com.liferay.portal.model.Shard findByC_C(long classNameId, 191 long classPK) 192 throws com.liferay.portal.NoSuchShardException, 193 com.liferay.portal.kernel.exception.SystemException { 194 return getPersistence().findByC_C(classNameId, classPK); 195 } 196 197 /** 198 * Returns the shard where classNameId = ? and classPK = ? or returns <code>null</code> if it could not be found. Uses the finder cache. 199 * 200 * @param classNameId the class name ID 201 * @param classPK the class p k 202 * @return the matching shard, or <code>null</code> if a matching shard could not be found 203 * @throws SystemException if a system exception occurred 204 */ 205 public static com.liferay.portal.model.Shard fetchByC_C(long classNameId, 206 long classPK) 207 throws com.liferay.portal.kernel.exception.SystemException { 208 return getPersistence().fetchByC_C(classNameId, classPK); 209 } 210 211 /** 212 * Returns the shard where classNameId = ? and classPK = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. 213 * 214 * @param classNameId the class name ID 215 * @param classPK the class p k 216 * @param retrieveFromCache whether to use the finder cache 217 * @return the matching shard, or <code>null</code> if a matching shard could not be found 218 * @throws SystemException if a system exception occurred 219 */ 220 public static com.liferay.portal.model.Shard fetchByC_C(long classNameId, 221 long classPK, boolean retrieveFromCache) 222 throws com.liferay.portal.kernel.exception.SystemException { 223 return getPersistence() 224 .fetchByC_C(classNameId, classPK, retrieveFromCache); 225 } 226 227 /** 228 * Removes the shard where classNameId = ? and classPK = ? from the database. 229 * 230 * @param classNameId the class name ID 231 * @param classPK the class p k 232 * @return the shard that was removed 233 * @throws SystemException if a system exception occurred 234 */ 235 public static com.liferay.portal.model.Shard removeByC_C(long classNameId, 236 long classPK) 237 throws com.liferay.portal.NoSuchShardException, 238 com.liferay.portal.kernel.exception.SystemException { 239 return getPersistence().removeByC_C(classNameId, classPK); 240 } 241 242 /** 243 * Returns the number of shards where classNameId = ? and classPK = ?. 244 * 245 * @param classNameId the class name ID 246 * @param classPK the class p k 247 * @return the number of matching shards 248 * @throws SystemException if a system exception occurred 249 */ 250 public static int countByC_C(long classNameId, long classPK) 251 throws com.liferay.portal.kernel.exception.SystemException { 252 return getPersistence().countByC_C(classNameId, classPK); 253 } 254 255 /** 256 * Caches the shard in the entity cache if it is enabled. 257 * 258 * @param shard the shard 259 */ 260 public static void cacheResult(com.liferay.portal.model.Shard shard) { 261 getPersistence().cacheResult(shard); 262 } 263 264 /** 265 * Caches the shards in the entity cache if it is enabled. 266 * 267 * @param shards the shards 268 */ 269 public static void cacheResult( 270 java.util.List<com.liferay.portal.model.Shard> shards) { 271 getPersistence().cacheResult(shards); 272 } 273 274 /** 275 * Creates a new shard with the primary key. Does not add the shard to the database. 276 * 277 * @param shardId the primary key for the new shard 278 * @return the new shard 279 */ 280 public static com.liferay.portal.model.Shard create(long shardId) { 281 return getPersistence().create(shardId); 282 } 283 284 /** 285 * Removes the shard with the primary key from the database. Also notifies the appropriate model listeners. 286 * 287 * @param shardId the primary key of the shard 288 * @return the shard that was removed 289 * @throws com.liferay.portal.NoSuchShardException if a shard with the primary key could not be found 290 * @throws SystemException if a system exception occurred 291 */ 292 public static com.liferay.portal.model.Shard remove(long shardId) 293 throws com.liferay.portal.NoSuchShardException, 294 com.liferay.portal.kernel.exception.SystemException { 295 return getPersistence().remove(shardId); 296 } 297 298 public static com.liferay.portal.model.Shard updateImpl( 299 com.liferay.portal.model.Shard shard) 300 throws com.liferay.portal.kernel.exception.SystemException { 301 return getPersistence().updateImpl(shard); 302 } 303 304 /** 305 * Returns the shard with the primary key or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found. 306 * 307 * @param shardId the primary key of the shard 308 * @return the shard 309 * @throws com.liferay.portal.NoSuchShardException if a shard with the primary key could not be found 310 * @throws SystemException if a system exception occurred 311 */ 312 public static com.liferay.portal.model.Shard findByPrimaryKey(long shardId) 313 throws com.liferay.portal.NoSuchShardException, 314 com.liferay.portal.kernel.exception.SystemException { 315 return getPersistence().findByPrimaryKey(shardId); 316 } 317 318 /** 319 * Returns the shard with the primary key or returns <code>null</code> if it could not be found. 320 * 321 * @param shardId the primary key of the shard 322 * @return the shard, or <code>null</code> if a shard with the primary key could not be found 323 * @throws SystemException if a system exception occurred 324 */ 325 public static com.liferay.portal.model.Shard fetchByPrimaryKey(long shardId) 326 throws com.liferay.portal.kernel.exception.SystemException { 327 return getPersistence().fetchByPrimaryKey(shardId); 328 } 329 330 /** 331 * Returns all the shards. 332 * 333 * @return the shards 334 * @throws SystemException if a system exception occurred 335 */ 336 public static java.util.List<com.liferay.portal.model.Shard> findAll() 337 throws com.liferay.portal.kernel.exception.SystemException { 338 return getPersistence().findAll(); 339 } 340 341 /** 342 * Returns a range of all the shards. 343 * 344 * <p> 345 * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ShardModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 346 * </p> 347 * 348 * @param start the lower bound of the range of shards 349 * @param end the upper bound of the range of shards (not inclusive) 350 * @return the range of shards 351 * @throws SystemException if a system exception occurred 352 */ 353 public static java.util.List<com.liferay.portal.model.Shard> findAll( 354 int start, int end) 355 throws com.liferay.portal.kernel.exception.SystemException { 356 return getPersistence().findAll(start, end); 357 } 358 359 /** 360 * Returns an ordered range of all the shards. 361 * 362 * <p> 363 * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ShardModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 364 * </p> 365 * 366 * @param start the lower bound of the range of shards 367 * @param end the upper bound of the range of shards (not inclusive) 368 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 369 * @return the ordered range of shards 370 * @throws SystemException if a system exception occurred 371 */ 372 public static java.util.List<com.liferay.portal.model.Shard> findAll( 373 int start, int end, 374 com.liferay.portal.kernel.util.OrderByComparator orderByComparator) 375 throws com.liferay.portal.kernel.exception.SystemException { 376 return getPersistence().findAll(start, end, orderByComparator); 377 } 378 379 /** 380 * Removes all the shards from the database. 381 * 382 * @throws SystemException if a system exception occurred 383 */ 384 public static void removeAll() 385 throws com.liferay.portal.kernel.exception.SystemException { 386 getPersistence().removeAll(); 387 } 388 389 /** 390 * Returns the number of shards. 391 * 392 * @return the number of shards 393 * @throws SystemException if a system exception occurred 394 */ 395 public static int countAll() 396 throws com.liferay.portal.kernel.exception.SystemException { 397 return getPersistence().countAll(); 398 } 399 400 public static ShardPersistence getPersistence() { 401 if (_persistence == null) { 402 _persistence = (ShardPersistence)PortalBeanLocatorUtil.locate(ShardPersistence.class.getName()); 403 404 ReferenceRegistry.registerReference(ShardUtil.class, "_persistence"); 405 } 406 407 return _persistence; 408 } 409 410 /** 411 * @deprecated As of 6.2.0 412 */ 413 public void setPersistence(ShardPersistence persistence) { 414 } 415 416 private static ShardPersistence _persistence; 417 }