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