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