1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchReleaseException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.Session;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringUtil;
41 import com.liferay.portal.model.ModelListener;
42 import com.liferay.portal.model.Release;
43 import com.liferay.portal.model.impl.ReleaseImpl;
44 import com.liferay.portal.model.impl.ReleaseModelImpl;
45 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
46
47 import java.util.ArrayList;
48 import java.util.Collections;
49 import java.util.List;
50
51
57 public class ReleasePersistenceImpl extends BasePersistenceImpl
58 implements ReleasePersistence {
59 public static final String FINDER_CLASS_NAME_ENTITY = ReleaseImpl.class.getName();
60 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
61 ".List";
62 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ReleaseModelImpl.ENTITY_CACHE_ENABLED,
63 ReleaseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
64 "findAll", new String[0]);
65 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ReleaseModelImpl.ENTITY_CACHE_ENABLED,
66 ReleaseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
67 "countAll", new String[0]);
68
69 public void cacheResult(Release release) {
70 EntityCacheUtil.putResult(ReleaseModelImpl.ENTITY_CACHE_ENABLED,
71 ReleaseImpl.class, release.getPrimaryKey(), release);
72 }
73
74 public void cacheResult(List<Release> releases) {
75 for (Release release : releases) {
76 if (EntityCacheUtil.getResult(
77 ReleaseModelImpl.ENTITY_CACHE_ENABLED,
78 ReleaseImpl.class, release.getPrimaryKey(), this) == null) {
79 cacheResult(release);
80 }
81 }
82 }
83
84 public void clearCache() {
85 CacheRegistry.clear(ReleaseImpl.class.getName());
86 EntityCacheUtil.clearCache(ReleaseImpl.class.getName());
87 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
88 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
89 }
90
91 public Release create(long releaseId) {
92 Release release = new ReleaseImpl();
93
94 release.setNew(true);
95 release.setPrimaryKey(releaseId);
96
97 return release;
98 }
99
100 public Release remove(long releaseId)
101 throws NoSuchReleaseException, SystemException {
102 Session session = null;
103
104 try {
105 session = openSession();
106
107 Release release = (Release)session.get(ReleaseImpl.class,
108 new Long(releaseId));
109
110 if (release == null) {
111 if (_log.isWarnEnabled()) {
112 _log.warn("No Release exists with the primary key " +
113 releaseId);
114 }
115
116 throw new NoSuchReleaseException(
117 "No Release exists with the primary key " + releaseId);
118 }
119
120 return remove(release);
121 }
122 catch (NoSuchReleaseException nsee) {
123 throw nsee;
124 }
125 catch (Exception e) {
126 throw processException(e);
127 }
128 finally {
129 closeSession(session);
130 }
131 }
132
133 public Release remove(Release release) throws SystemException {
134 for (ModelListener<Release> listener : listeners) {
135 listener.onBeforeRemove(release);
136 }
137
138 release = removeImpl(release);
139
140 for (ModelListener<Release> listener : listeners) {
141 listener.onAfterRemove(release);
142 }
143
144 return release;
145 }
146
147 protected Release removeImpl(Release release) throws SystemException {
148 Session session = null;
149
150 try {
151 session = openSession();
152
153 if (release.isCachedModel() || BatchSessionUtil.isEnabled()) {
154 Object staleObject = session.get(ReleaseImpl.class,
155 release.getPrimaryKeyObj());
156
157 if (staleObject != null) {
158 session.evict(staleObject);
159 }
160 }
161
162 session.delete(release);
163
164 session.flush();
165 }
166 catch (Exception e) {
167 throw processException(e);
168 }
169 finally {
170 closeSession(session);
171 }
172
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
174
175 EntityCacheUtil.removeResult(ReleaseModelImpl.ENTITY_CACHE_ENABLED,
176 ReleaseImpl.class, release.getPrimaryKey());
177
178 return release;
179 }
180
181
184 public Release update(Release release) throws SystemException {
185 if (_log.isWarnEnabled()) {
186 _log.warn(
187 "Using the deprecated update(Release release) method. Use update(Release release, boolean merge) instead.");
188 }
189
190 return update(release, false);
191 }
192
193
206 public Release update(Release release, boolean merge)
207 throws SystemException {
208 boolean isNew = release.isNew();
209
210 for (ModelListener<Release> listener : listeners) {
211 if (isNew) {
212 listener.onBeforeCreate(release);
213 }
214 else {
215 listener.onBeforeUpdate(release);
216 }
217 }
218
219 release = updateImpl(release, merge);
220
221 for (ModelListener<Release> listener : listeners) {
222 if (isNew) {
223 listener.onAfterCreate(release);
224 }
225 else {
226 listener.onAfterUpdate(release);
227 }
228 }
229
230 return release;
231 }
232
233 public Release updateImpl(com.liferay.portal.model.Release release,
234 boolean merge) throws SystemException {
235 Session session = null;
236
237 try {
238 session = openSession();
239
240 BatchSessionUtil.update(session, release, merge);
241
242 release.setNew(false);
243 }
244 catch (Exception e) {
245 throw processException(e);
246 }
247 finally {
248 closeSession(session);
249 }
250
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
252
253 EntityCacheUtil.putResult(ReleaseModelImpl.ENTITY_CACHE_ENABLED,
254 ReleaseImpl.class, release.getPrimaryKey(), release);
255
256 return release;
257 }
258
259 public Release findByPrimaryKey(long releaseId)
260 throws NoSuchReleaseException, SystemException {
261 Release release = fetchByPrimaryKey(releaseId);
262
263 if (release == null) {
264 if (_log.isWarnEnabled()) {
265 _log.warn("No Release exists with the primary key " +
266 releaseId);
267 }
268
269 throw new NoSuchReleaseException(
270 "No Release exists with the primary key " + releaseId);
271 }
272
273 return release;
274 }
275
276 public Release fetchByPrimaryKey(long releaseId) throws SystemException {
277 Release release = (Release)EntityCacheUtil.getResult(ReleaseModelImpl.ENTITY_CACHE_ENABLED,
278 ReleaseImpl.class, releaseId, this);
279
280 if (release == null) {
281 Session session = null;
282
283 try {
284 session = openSession();
285
286 release = (Release)session.get(ReleaseImpl.class,
287 new Long(releaseId));
288 }
289 catch (Exception e) {
290 throw processException(e);
291 }
292 finally {
293 if (release != null) {
294 cacheResult(release);
295 }
296
297 closeSession(session);
298 }
299 }
300
301 return release;
302 }
303
304 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
305 throws SystemException {
306 Session session = null;
307
308 try {
309 session = openSession();
310
311 dynamicQuery.compile(session);
312
313 return dynamicQuery.list();
314 }
315 catch (Exception e) {
316 throw processException(e);
317 }
318 finally {
319 closeSession(session);
320 }
321 }
322
323 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
324 int start, int end) throws SystemException {
325 Session session = null;
326
327 try {
328 session = openSession();
329
330 dynamicQuery.setLimit(start, end);
331
332 dynamicQuery.compile(session);
333
334 return dynamicQuery.list();
335 }
336 catch (Exception e) {
337 throw processException(e);
338 }
339 finally {
340 closeSession(session);
341 }
342 }
343
344 public List<Release> findAll() throws SystemException {
345 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
346 }
347
348 public List<Release> findAll(int start, int end) throws SystemException {
349 return findAll(start, end, null);
350 }
351
352 public List<Release> findAll(int start, int end, OrderByComparator obc)
353 throws SystemException {
354 Object[] finderArgs = new Object[] {
355 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
356 };
357
358 List<Release> list = (List<Release>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
359 finderArgs, this);
360
361 if (list == null) {
362 Session session = null;
363
364 try {
365 session = openSession();
366
367 StringBuilder query = new StringBuilder();
368
369 query.append("FROM com.liferay.portal.model.Release ");
370
371 if (obc != null) {
372 query.append("ORDER BY ");
373 query.append(obc.getOrderBy());
374 }
375
376 Query q = session.createQuery(query.toString());
377
378 if (obc == null) {
379 list = (List<Release>)QueryUtil.list(q, getDialect(),
380 start, end, false);
381
382 Collections.sort(list);
383 }
384 else {
385 list = (List<Release>)QueryUtil.list(q, getDialect(),
386 start, end);
387 }
388 }
389 catch (Exception e) {
390 throw processException(e);
391 }
392 finally {
393 if (list == null) {
394 list = new ArrayList<Release>();
395 }
396
397 cacheResult(list);
398
399 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
400
401 closeSession(session);
402 }
403 }
404
405 return list;
406 }
407
408 public void removeAll() throws SystemException {
409 for (Release release : findAll()) {
410 remove(release);
411 }
412 }
413
414 public int countAll() throws SystemException {
415 Object[] finderArgs = new Object[0];
416
417 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
418 finderArgs, this);
419
420 if (count == null) {
421 Session session = null;
422
423 try {
424 session = openSession();
425
426 Query q = session.createQuery(
427 "SELECT COUNT(*) FROM com.liferay.portal.model.Release");
428
429 count = (Long)q.uniqueResult();
430 }
431 catch (Exception e) {
432 throw processException(e);
433 }
434 finally {
435 if (count == null) {
436 count = Long.valueOf(0);
437 }
438
439 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
440 count);
441
442 closeSession(session);
443 }
444 }
445
446 return count.intValue();
447 }
448
449 public void afterPropertiesSet() {
450 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
451 com.liferay.portal.util.PropsUtil.get(
452 "value.object.listener.com.liferay.portal.model.Release")));
453
454 if (listenerClassNames.length > 0) {
455 try {
456 List<ModelListener<Release>> listenersList = new ArrayList<ModelListener<Release>>();
457
458 for (String listenerClassName : listenerClassNames) {
459 listenersList.add((ModelListener<Release>)Class.forName(
460 listenerClassName).newInstance());
461 }
462
463 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
464 }
465 catch (Exception e) {
466 _log.error(e);
467 }
468 }
469 }
470
471 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
472 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
473 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
474 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
475 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
476 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
477 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
478 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
479 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
480 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
481 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
482 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
483 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
484 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
485 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
486 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
487 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
488 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
489 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
490 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
491 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
492 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
493 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
494 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
495 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
496 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
497 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
498 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
499 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
500 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
501 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
502 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
503 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
504 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
505 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
506 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
507 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
508 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
509 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
510 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
511 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
512 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
513 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
514 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
515 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
516 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
517 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
518 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
519 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
520 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
521 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
522 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
523 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
524 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
525 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
526 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
527 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
528 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
529 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
530 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
531 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
532 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
533 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
534 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
535 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
536 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
537 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
538 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
539 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
540 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
541 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
542 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
543 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
544 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
545 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
546 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
547 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
548 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
549 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
550 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
551 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
552 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
553 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
554 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
555 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
556 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
557 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
558 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
559 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
560 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
561 private static Log _log = LogFactoryUtil.getLog(ReleasePersistenceImpl.class);
562 }