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.counter.service.persistence; 016 017 import aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.counter.model.Counter; 020 021 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; 022 import com.liferay.portal.kernel.dao.orm.DynamicQuery; 023 import com.liferay.portal.kernel.util.OrderByComparator; 024 import com.liferay.portal.kernel.util.ReferenceRegistry; 025 import com.liferay.portal.service.ServiceContext; 026 027 import java.util.List; 028 029 /** 030 * The persistence utility for the counter service. This utility wraps {@link CounterPersistenceImpl} 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 CounterPersistence 038 * @see CounterPersistenceImpl 039 * @generated 040 */ 041 @ProviderType 042 public class CounterUtil { 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(Counter counter) { 060 getPersistence().clearCache(counter); 061 } 062 063 /** 064 * @see com.liferay.portal.service.persistence.BasePersistence#countWithDynamicQuery(DynamicQuery) 065 */ 066 public static long countWithDynamicQuery(DynamicQuery dynamicQuery) { 067 return getPersistence().countWithDynamicQuery(dynamicQuery); 068 } 069 070 /** 071 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery) 072 */ 073 public static List<Counter> findWithDynamicQuery(DynamicQuery dynamicQuery) { 074 return getPersistence().findWithDynamicQuery(dynamicQuery); 075 } 076 077 /** 078 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int) 079 */ 080 public static List<Counter> findWithDynamicQuery( 081 DynamicQuery dynamicQuery, int start, int end) { 082 return getPersistence().findWithDynamicQuery(dynamicQuery, start, end); 083 } 084 085 /** 086 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int, OrderByComparator) 087 */ 088 public static List<Counter> findWithDynamicQuery( 089 DynamicQuery dynamicQuery, int start, int end, 090 OrderByComparator<Counter> orderByComparator) { 091 return getPersistence() 092 .findWithDynamicQuery(dynamicQuery, start, end, 093 orderByComparator); 094 } 095 096 /** 097 * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel) 098 */ 099 public static Counter update(Counter counter) { 100 return getPersistence().update(counter); 101 } 102 103 /** 104 * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, ServiceContext) 105 */ 106 public static Counter update(Counter counter, ServiceContext serviceContext) { 107 return getPersistence().update(counter, serviceContext); 108 } 109 110 /** 111 * Caches the counter in the entity cache if it is enabled. 112 * 113 * @param counter the counter 114 */ 115 public static void cacheResult(com.liferay.counter.model.Counter counter) { 116 getPersistence().cacheResult(counter); 117 } 118 119 /** 120 * Caches the counters in the entity cache if it is enabled. 121 * 122 * @param counters the counters 123 */ 124 public static void cacheResult( 125 java.util.List<com.liferay.counter.model.Counter> counters) { 126 getPersistence().cacheResult(counters); 127 } 128 129 /** 130 * Creates a new counter with the primary key. Does not add the counter to the database. 131 * 132 * @param name the primary key for the new counter 133 * @return the new counter 134 */ 135 public static com.liferay.counter.model.Counter create( 136 java.lang.String name) { 137 return getPersistence().create(name); 138 } 139 140 /** 141 * Removes the counter with the primary key from the database. Also notifies the appropriate model listeners. 142 * 143 * @param name the primary key of the counter 144 * @return the counter that was removed 145 * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found 146 */ 147 public static com.liferay.counter.model.Counter remove( 148 java.lang.String name) 149 throws com.liferay.counter.NoSuchCounterException { 150 return getPersistence().remove(name); 151 } 152 153 public static com.liferay.counter.model.Counter updateImpl( 154 com.liferay.counter.model.Counter counter) { 155 return getPersistence().updateImpl(counter); 156 } 157 158 /** 159 * Returns the counter with the primary key or throws a {@link com.liferay.counter.NoSuchCounterException} if it could not be found. 160 * 161 * @param name the primary key of the counter 162 * @return the counter 163 * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found 164 */ 165 public static com.liferay.counter.model.Counter findByPrimaryKey( 166 java.lang.String name) 167 throws com.liferay.counter.NoSuchCounterException { 168 return getPersistence().findByPrimaryKey(name); 169 } 170 171 /** 172 * Returns the counter with the primary key or returns <code>null</code> if it could not be found. 173 * 174 * @param name the primary key of the counter 175 * @return the counter, or <code>null</code> if a counter with the primary key could not be found 176 */ 177 public static com.liferay.counter.model.Counter fetchByPrimaryKey( 178 java.lang.String name) { 179 return getPersistence().fetchByPrimaryKey(name); 180 } 181 182 public static java.util.Map<java.io.Serializable, com.liferay.counter.model.Counter> fetchByPrimaryKeys( 183 java.util.Set<java.io.Serializable> primaryKeys) { 184 return getPersistence().fetchByPrimaryKeys(primaryKeys); 185 } 186 187 /** 188 * Returns all the counters. 189 * 190 * @return the counters 191 */ 192 public static java.util.List<com.liferay.counter.model.Counter> findAll() { 193 return getPersistence().findAll(); 194 } 195 196 /** 197 * Returns a range of all the counters. 198 * 199 * <p> 200 * 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.counter.model.impl.CounterModelImpl}. 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. 201 * </p> 202 * 203 * @param start the lower bound of the range of counters 204 * @param end the upper bound of the range of counters (not inclusive) 205 * @return the range of counters 206 */ 207 public static java.util.List<com.liferay.counter.model.Counter> findAll( 208 int start, int end) { 209 return getPersistence().findAll(start, end); 210 } 211 212 /** 213 * Returns an ordered range of all the counters. 214 * 215 * <p> 216 * 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.counter.model.impl.CounterModelImpl}. 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. 217 * </p> 218 * 219 * @param start the lower bound of the range of counters 220 * @param end the upper bound of the range of counters (not inclusive) 221 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 222 * @return the ordered range of counters 223 */ 224 public static java.util.List<com.liferay.counter.model.Counter> findAll( 225 int start, int end, 226 com.liferay.portal.kernel.util.OrderByComparator<com.liferay.counter.model.Counter> orderByComparator) { 227 return getPersistence().findAll(start, end, orderByComparator); 228 } 229 230 /** 231 * Removes all the counters from the database. 232 */ 233 public static void removeAll() { 234 getPersistence().removeAll(); 235 } 236 237 /** 238 * Returns the number of counters. 239 * 240 * @return the number of counters 241 */ 242 public static int countAll() { 243 return getPersistence().countAll(); 244 } 245 246 public static CounterPersistence getPersistence() { 247 if (_persistence == null) { 248 _persistence = (CounterPersistence)PortalBeanLocatorUtil.locate(CounterPersistence.class.getName()); 249 250 ReferenceRegistry.registerReference(CounterUtil.class, 251 "_persistence"); 252 } 253 254 return _persistence; 255 } 256 257 /** 258 * @deprecated As of 6.2.0 259 */ 260 @Deprecated 261 public void setPersistence(CounterPersistence persistence) { 262 } 263 264 private static CounterPersistence _persistence; 265 }