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 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 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 com.liferay.portal.NoSuchShardException} if it could not be found. 110 * 111 * @param name the name 112 * @return the matching shard 113 * @throws com.liferay.portal.NoSuchShardException if a matching shard could not be found 114 */ 115 public static com.liferay.portal.model.Shard findByName( 116 java.lang.String name) 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 com.liferay.portal.model.Shard fetchByName( 127 java.lang.String name) { 128 return getPersistence().fetchByName(name); 129 } 130 131 /** 132 * Returns the shard where name = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. 133 * 134 * @param name the name 135 * @param retrieveFromCache whether to use the finder cache 136 * @return the matching shard, or <code>null</code> if a matching shard could not be found 137 */ 138 public static com.liferay.portal.model.Shard fetchByName( 139 java.lang.String name, boolean retrieveFromCache) { 140 return getPersistence().fetchByName(name, retrieveFromCache); 141 } 142 143 /** 144 * Removes the shard where name = ? from the database. 145 * 146 * @param name the name 147 * @return the shard that was removed 148 */ 149 public static com.liferay.portal.model.Shard removeByName( 150 java.lang.String name) throws com.liferay.portal.NoSuchShardException { 151 return getPersistence().removeByName(name); 152 } 153 154 /** 155 * Returns the number of shards where name = ?. 156 * 157 * @param name the name 158 * @return the number of matching shards 159 */ 160 public static int countByName(java.lang.String name) { 161 return getPersistence().countByName(name); 162 } 163 164 /** 165 * Returns the shard where classNameId = ? and classPK = ? or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found. 166 * 167 * @param classNameId the class name ID 168 * @param classPK the class p k 169 * @return the matching shard 170 * @throws com.liferay.portal.NoSuchShardException if a matching shard could not be found 171 */ 172 public static com.liferay.portal.model.Shard findByC_C(long classNameId, 173 long classPK) throws com.liferay.portal.NoSuchShardException { 174 return getPersistence().findByC_C(classNameId, classPK); 175 } 176 177 /** 178 * Returns the shard where classNameId = ? and classPK = ? or returns <code>null</code> if it could not be found. Uses the finder cache. 179 * 180 * @param classNameId the class name ID 181 * @param classPK the class p k 182 * @return the matching shard, or <code>null</code> if a matching shard could not be found 183 */ 184 public static com.liferay.portal.model.Shard fetchByC_C(long classNameId, 185 long classPK) { 186 return getPersistence().fetchByC_C(classNameId, classPK); 187 } 188 189 /** 190 * Returns the shard where classNameId = ? and classPK = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. 191 * 192 * @param classNameId the class name ID 193 * @param classPK the class p k 194 * @param retrieveFromCache whether to use the finder cache 195 * @return the matching shard, or <code>null</code> if a matching shard could not be found 196 */ 197 public static com.liferay.portal.model.Shard fetchByC_C(long classNameId, 198 long classPK, boolean retrieveFromCache) { 199 return getPersistence() 200 .fetchByC_C(classNameId, classPK, retrieveFromCache); 201 } 202 203 /** 204 * Removes the shard where classNameId = ? and classPK = ? from the database. 205 * 206 * @param classNameId the class name ID 207 * @param classPK the class p k 208 * @return the shard that was removed 209 */ 210 public static com.liferay.portal.model.Shard removeByC_C(long classNameId, 211 long classPK) throws com.liferay.portal.NoSuchShardException { 212 return getPersistence().removeByC_C(classNameId, classPK); 213 } 214 215 /** 216 * Returns the number of shards where classNameId = ? and classPK = ?. 217 * 218 * @param classNameId the class name ID 219 * @param classPK the class p k 220 * @return the number of matching shards 221 */ 222 public static int countByC_C(long classNameId, long classPK) { 223 return getPersistence().countByC_C(classNameId, classPK); 224 } 225 226 /** 227 * Caches the shard in the entity cache if it is enabled. 228 * 229 * @param shard the shard 230 */ 231 public static void cacheResult(com.liferay.portal.model.Shard shard) { 232 getPersistence().cacheResult(shard); 233 } 234 235 /** 236 * Caches the shards in the entity cache if it is enabled. 237 * 238 * @param shards the shards 239 */ 240 public static void cacheResult( 241 java.util.List<com.liferay.portal.model.Shard> shards) { 242 getPersistence().cacheResult(shards); 243 } 244 245 /** 246 * Creates a new shard with the primary key. Does not add the shard to the database. 247 * 248 * @param shardId the primary key for the new shard 249 * @return the new shard 250 */ 251 public static com.liferay.portal.model.Shard create(long shardId) { 252 return getPersistence().create(shardId); 253 } 254 255 /** 256 * Removes the shard with the primary key from the database. Also notifies the appropriate model listeners. 257 * 258 * @param shardId the primary key of the shard 259 * @return the shard that was removed 260 * @throws com.liferay.portal.NoSuchShardException if a shard with the primary key could not be found 261 */ 262 public static com.liferay.portal.model.Shard remove(long shardId) 263 throws com.liferay.portal.NoSuchShardException { 264 return getPersistence().remove(shardId); 265 } 266 267 public static com.liferay.portal.model.Shard updateImpl( 268 com.liferay.portal.model.Shard shard) { 269 return getPersistence().updateImpl(shard); 270 } 271 272 /** 273 * Returns the shard with the primary key or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found. 274 * 275 * @param shardId the primary key of the shard 276 * @return the shard 277 * @throws com.liferay.portal.NoSuchShardException if a shard with the primary key could not be found 278 */ 279 public static com.liferay.portal.model.Shard findByPrimaryKey(long shardId) 280 throws com.liferay.portal.NoSuchShardException { 281 return getPersistence().findByPrimaryKey(shardId); 282 } 283 284 /** 285 * Returns the shard with the primary key or returns <code>null</code> if it could not be found. 286 * 287 * @param shardId the primary key of the shard 288 * @return the shard, or <code>null</code> if a shard with the primary key could not be found 289 */ 290 public static com.liferay.portal.model.Shard fetchByPrimaryKey(long shardId) { 291 return getPersistence().fetchByPrimaryKey(shardId); 292 } 293 294 public static java.util.Map<java.io.Serializable, com.liferay.portal.model.Shard> fetchByPrimaryKeys( 295 java.util.Set<java.io.Serializable> primaryKeys) { 296 return getPersistence().fetchByPrimaryKeys(primaryKeys); 297 } 298 299 /** 300 * Returns all the shards. 301 * 302 * @return the shards 303 */ 304 public static java.util.List<com.liferay.portal.model.Shard> findAll() { 305 return getPersistence().findAll(); 306 } 307 308 /** 309 * Returns a range of all the shards. 310 * 311 * <p> 312 * 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. 313 * </p> 314 * 315 * @param start the lower bound of the range of shards 316 * @param end the upper bound of the range of shards (not inclusive) 317 * @return the range of shards 318 */ 319 public static java.util.List<com.liferay.portal.model.Shard> findAll( 320 int start, int end) { 321 return getPersistence().findAll(start, end); 322 } 323 324 /** 325 * Returns an ordered range of all the shards. 326 * 327 * <p> 328 * 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. 329 * </p> 330 * 331 * @param start the lower bound of the range of shards 332 * @param end the upper bound of the range of shards (not inclusive) 333 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 334 * @return the ordered range of shards 335 */ 336 public static java.util.List<com.liferay.portal.model.Shard> findAll( 337 int start, int end, 338 com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.model.Shard> orderByComparator) { 339 return getPersistence().findAll(start, end, orderByComparator); 340 } 341 342 /** 343 * Removes all the shards from the database. 344 */ 345 public static void removeAll() { 346 getPersistence().removeAll(); 347 } 348 349 /** 350 * Returns the number of shards. 351 * 352 * @return the number of shards 353 */ 354 public static int countAll() { 355 return getPersistence().countAll(); 356 } 357 358 public static ShardPersistence getPersistence() { 359 if (_persistence == null) { 360 _persistence = (ShardPersistence)PortalBeanLocatorUtil.locate(ShardPersistence.class.getName()); 361 362 ReferenceRegistry.registerReference(ShardUtil.class, "_persistence"); 363 } 364 365 return _persistence; 366 } 367 368 /** 369 * @deprecated As of 6.2.0 370 */ 371 @Deprecated 372 public void setPersistence(ShardPersistence persistence) { 373 } 374 375 private static ShardPersistence _persistence; 376 }