1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchLockException;
18  import com.liferay.portal.NoSuchModelException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderPath;
24  import com.liferay.portal.kernel.dao.orm.Query;
25  import com.liferay.portal.kernel.dao.orm.QueryPos;
26  import com.liferay.portal.kernel.dao.orm.QueryUtil;
27  import com.liferay.portal.kernel.dao.orm.Session;
28  import com.liferay.portal.kernel.exception.SystemException;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.CalendarUtil;
32  import com.liferay.portal.kernel.util.GetterUtil;
33  import com.liferay.portal.kernel.util.InstanceFactory;
34  import com.liferay.portal.kernel.util.OrderByComparator;
35  import com.liferay.portal.kernel.util.StringBundler;
36  import com.liferay.portal.kernel.util.StringPool;
37  import com.liferay.portal.kernel.util.StringUtil;
38  import com.liferay.portal.kernel.util.Validator;
39  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
40  import com.liferay.portal.model.Lock;
41  import com.liferay.portal.model.ModelListener;
42  import com.liferay.portal.model.impl.LockImpl;
43  import com.liferay.portal.model.impl.LockModelImpl;
44  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45  
46  import java.io.Serializable;
47  
48  import java.util.ArrayList;
49  import java.util.Collections;
50  import java.util.Date;
51  import java.util.List;
52  
53  /**
54   * <a href="LockPersistenceImpl.java.html"><b><i>View Source</i></b></a>
55   *
56   * <p>
57   * ServiceBuilder generated this class. Modifications in this class will be
58   * overwritten the next time is generated.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       LockPersistence
63   * @see       LockUtil
64   * @generated
65   */
66  public class LockPersistenceImpl extends BasePersistenceImpl<Lock>
67      implements LockPersistence {
68      public static final String FINDER_CLASS_NAME_ENTITY = LockImpl.class.getName();
69      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
70          ".List";
71      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
72              LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
73              "findByUuid",
74              new String[] {
75                  String.class.getName(),
76                  
77              "java.lang.Integer", "java.lang.Integer",
78                  "com.liferay.portal.kernel.util.OrderByComparator"
79              });
80      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
81              LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
82              "countByUuid", new String[] { String.class.getName() });
83      public static final FinderPath FINDER_PATH_FIND_BY_EXPIRATIONDATE = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
84              LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85              "findByExpirationDate",
86              new String[] {
87                  Date.class.getName(),
88                  
89              "java.lang.Integer", "java.lang.Integer",
90                  "com.liferay.portal.kernel.util.OrderByComparator"
91              });
92      public static final FinderPath FINDER_PATH_COUNT_BY_EXPIRATIONDATE = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
93              LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94              "countByExpirationDate", new String[] { Date.class.getName() });
95      public static final FinderPath FINDER_PATH_FETCH_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
96              LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
97              "fetchByC_K",
98              new String[] { String.class.getName(), String.class.getName() });
99      public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
100             LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101             "countByC_K",
102             new String[] { String.class.getName(), String.class.getName() });
103     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
104             LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105             "findAll", new String[0]);
106     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
107             LockModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108             "countAll", new String[0]);
109 
110     public void cacheResult(Lock lock) {
111         EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
112             LockImpl.class, lock.getPrimaryKey(), lock);
113 
114         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
115             new Object[] { lock.getClassName(), lock.getKey() }, lock);
116     }
117 
118     public void cacheResult(List<Lock> locks) {
119         for (Lock lock : locks) {
120             if (EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
121                         LockImpl.class, lock.getPrimaryKey(), this) == null) {
122                 cacheResult(lock);
123             }
124         }
125     }
126 
127     public void clearCache() {
128         CacheRegistry.clear(LockImpl.class.getName());
129         EntityCacheUtil.clearCache(LockImpl.class.getName());
130         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
131         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
132     }
133 
134     public void clearCache(Lock lock) {
135         EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
136             LockImpl.class, lock.getPrimaryKey());
137 
138         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
139             new Object[] { lock.getClassName(), lock.getKey() });
140     }
141 
142     public Lock create(long lockId) {
143         Lock lock = new LockImpl();
144 
145         lock.setNew(true);
146         lock.setPrimaryKey(lockId);
147 
148         String uuid = PortalUUIDUtil.generate();
149 
150         lock.setUuid(uuid);
151 
152         return lock;
153     }
154 
155     public Lock remove(Serializable primaryKey)
156         throws NoSuchModelException, SystemException {
157         return remove(((Long)primaryKey).longValue());
158     }
159 
160     public Lock remove(long lockId) throws NoSuchLockException, SystemException {
161         Session session = null;
162 
163         try {
164             session = openSession();
165 
166             Lock lock = (Lock)session.get(LockImpl.class, new Long(lockId));
167 
168             if (lock == null) {
169                 if (_log.isWarnEnabled()) {
170                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + lockId);
171                 }
172 
173                 throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
174                     lockId);
175             }
176 
177             return remove(lock);
178         }
179         catch (NoSuchLockException nsee) {
180             throw nsee;
181         }
182         catch (Exception e) {
183             throw processException(e);
184         }
185         finally {
186             closeSession(session);
187         }
188     }
189 
190     public Lock remove(Lock lock) throws SystemException {
191         for (ModelListener<Lock> listener : listeners) {
192             listener.onBeforeRemove(lock);
193         }
194 
195         lock = removeImpl(lock);
196 
197         for (ModelListener<Lock> listener : listeners) {
198             listener.onAfterRemove(lock);
199         }
200 
201         return lock;
202     }
203 
204     protected Lock removeImpl(Lock lock) throws SystemException {
205         lock = toUnwrappedModel(lock);
206 
207         Session session = null;
208 
209         try {
210             session = openSession();
211 
212             if (lock.isCachedModel() || BatchSessionUtil.isEnabled()) {
213                 Object staleObject = session.get(LockImpl.class,
214                         lock.getPrimaryKeyObj());
215 
216                 if (staleObject != null) {
217                     session.evict(staleObject);
218                 }
219             }
220 
221             session.delete(lock);
222 
223             session.flush();
224         }
225         catch (Exception e) {
226             throw processException(e);
227         }
228         finally {
229             closeSession(session);
230         }
231 
232         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
233 
234         LockModelImpl lockModelImpl = (LockModelImpl)lock;
235 
236         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
237             new Object[] {
238                 lockModelImpl.getOriginalClassName(),
239                 
240             lockModelImpl.getOriginalKey()
241             });
242 
243         EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
244             LockImpl.class, lock.getPrimaryKey());
245 
246         return lock;
247     }
248 
249     public Lock updateImpl(com.liferay.portal.model.Lock lock, boolean merge)
250         throws SystemException {
251         lock = toUnwrappedModel(lock);
252 
253         boolean isNew = lock.isNew();
254 
255         LockModelImpl lockModelImpl = (LockModelImpl)lock;
256 
257         if (Validator.isNull(lock.getUuid())) {
258             String uuid = PortalUUIDUtil.generate();
259 
260             lock.setUuid(uuid);
261         }
262 
263         Session session = null;
264 
265         try {
266             session = openSession();
267 
268             BatchSessionUtil.update(session, lock, merge);
269 
270             lock.setNew(false);
271         }
272         catch (Exception e) {
273             throw processException(e);
274         }
275         finally {
276             closeSession(session);
277         }
278 
279         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
280 
281         EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
282             LockImpl.class, lock.getPrimaryKey(), lock);
283 
284         if (!isNew &&
285                 (!Validator.equals(lock.getClassName(),
286                     lockModelImpl.getOriginalClassName()) ||
287                 !Validator.equals(lock.getKey(), lockModelImpl.getOriginalKey()))) {
288             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
289                 new Object[] {
290                     lockModelImpl.getOriginalClassName(),
291                     
292                 lockModelImpl.getOriginalKey()
293                 });
294         }
295 
296         if (isNew ||
297                 (!Validator.equals(lock.getClassName(),
298                     lockModelImpl.getOriginalClassName()) ||
299                 !Validator.equals(lock.getKey(), lockModelImpl.getOriginalKey()))) {
300             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
301                 new Object[] { lock.getClassName(), lock.getKey() }, lock);
302         }
303 
304         return lock;
305     }
306 
307     protected Lock toUnwrappedModel(Lock lock) {
308         if (lock instanceof LockImpl) {
309             return lock;
310         }
311 
312         LockImpl lockImpl = new LockImpl();
313 
314         lockImpl.setNew(lock.isNew());
315         lockImpl.setPrimaryKey(lock.getPrimaryKey());
316 
317         lockImpl.setUuid(lock.getUuid());
318         lockImpl.setLockId(lock.getLockId());
319         lockImpl.setCompanyId(lock.getCompanyId());
320         lockImpl.setUserId(lock.getUserId());
321         lockImpl.setUserName(lock.getUserName());
322         lockImpl.setCreateDate(lock.getCreateDate());
323         lockImpl.setClassName(lock.getClassName());
324         lockImpl.setKey(lock.getKey());
325         lockImpl.setOwner(lock.getOwner());
326         lockImpl.setInheritable(lock.isInheritable());
327         lockImpl.setExpirationDate(lock.getExpirationDate());
328 
329         return lockImpl;
330     }
331 
332     public Lock findByPrimaryKey(Serializable primaryKey)
333         throws NoSuchModelException, SystemException {
334         return findByPrimaryKey(((Long)primaryKey).longValue());
335     }
336 
337     public Lock findByPrimaryKey(long lockId)
338         throws NoSuchLockException, SystemException {
339         Lock lock = fetchByPrimaryKey(lockId);
340 
341         if (lock == null) {
342             if (_log.isWarnEnabled()) {
343                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + lockId);
344             }
345 
346             throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
347                 lockId);
348         }
349 
350         return lock;
351     }
352 
353     public Lock fetchByPrimaryKey(Serializable primaryKey)
354         throws SystemException {
355         return fetchByPrimaryKey(((Long)primaryKey).longValue());
356     }
357 
358     public Lock fetchByPrimaryKey(long lockId) throws SystemException {
359         Lock lock = (Lock)EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
360                 LockImpl.class, lockId, this);
361 
362         if (lock == null) {
363             Session session = null;
364 
365             try {
366                 session = openSession();
367 
368                 lock = (Lock)session.get(LockImpl.class, new Long(lockId));
369             }
370             catch (Exception e) {
371                 throw processException(e);
372             }
373             finally {
374                 if (lock != null) {
375                     cacheResult(lock);
376                 }
377 
378                 closeSession(session);
379             }
380         }
381 
382         return lock;
383     }
384 
385     public List<Lock> findByUuid(String uuid) throws SystemException {
386         return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
387     }
388 
389     public List<Lock> findByUuid(String uuid, int start, int end)
390         throws SystemException {
391         return findByUuid(uuid, start, end, null);
392     }
393 
394     public List<Lock> findByUuid(String uuid, int start, int end,
395         OrderByComparator orderByComparator) throws SystemException {
396         Object[] finderArgs = new Object[] {
397                 uuid,
398                 
399                 String.valueOf(start), String.valueOf(end),
400                 String.valueOf(orderByComparator)
401             };
402 
403         List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
404                 finderArgs, this);
405 
406         if (list == null) {
407             Session session = null;
408 
409             try {
410                 session = openSession();
411 
412                 StringBundler query = null;
413 
414                 if (orderByComparator != null) {
415                     query = new StringBundler(3 +
416                             (orderByComparator.getOrderByFields().length * 3));
417                 }
418                 else {
419                     query = new StringBundler(2);
420                 }
421 
422                 query.append(_SQL_SELECT_LOCK_WHERE);
423 
424                 if (uuid == null) {
425                     query.append(_FINDER_COLUMN_UUID_UUID_1);
426                 }
427                 else {
428                     if (uuid.equals(StringPool.BLANK)) {
429                         query.append(_FINDER_COLUMN_UUID_UUID_3);
430                     }
431                     else {
432                         query.append(_FINDER_COLUMN_UUID_UUID_2);
433                     }
434                 }
435 
436                 if (orderByComparator != null) {
437                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
438                         orderByComparator);
439                 }
440 
441                 String sql = query.toString();
442 
443                 Query q = session.createQuery(sql);
444 
445                 QueryPos qPos = QueryPos.getInstance(q);
446 
447                 if (uuid != null) {
448                     qPos.add(uuid);
449                 }
450 
451                 list = (List<Lock>)QueryUtil.list(q, getDialect(), start, end);
452             }
453             catch (Exception e) {
454                 throw processException(e);
455             }
456             finally {
457                 if (list == null) {
458                     list = new ArrayList<Lock>();
459                 }
460 
461                 cacheResult(list);
462 
463                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
464                     list);
465 
466                 closeSession(session);
467             }
468         }
469 
470         return list;
471     }
472 
473     public Lock findByUuid_First(String uuid,
474         OrderByComparator orderByComparator)
475         throws NoSuchLockException, SystemException {
476         List<Lock> list = findByUuid(uuid, 0, 1, orderByComparator);
477 
478         if (list.isEmpty()) {
479             StringBundler msg = new StringBundler(4);
480 
481             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
482 
483             msg.append("uuid=");
484             msg.append(uuid);
485 
486             msg.append(StringPool.CLOSE_CURLY_BRACE);
487 
488             throw new NoSuchLockException(msg.toString());
489         }
490         else {
491             return list.get(0);
492         }
493     }
494 
495     public Lock findByUuid_Last(String uuid, OrderByComparator orderByComparator)
496         throws NoSuchLockException, SystemException {
497         int count = countByUuid(uuid);
498 
499         List<Lock> list = findByUuid(uuid, count - 1, count, orderByComparator);
500 
501         if (list.isEmpty()) {
502             StringBundler msg = new StringBundler(4);
503 
504             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
505 
506             msg.append("uuid=");
507             msg.append(uuid);
508 
509             msg.append(StringPool.CLOSE_CURLY_BRACE);
510 
511             throw new NoSuchLockException(msg.toString());
512         }
513         else {
514             return list.get(0);
515         }
516     }
517 
518     public Lock[] findByUuid_PrevAndNext(long lockId, String uuid,
519         OrderByComparator orderByComparator)
520         throws NoSuchLockException, SystemException {
521         Lock lock = findByPrimaryKey(lockId);
522 
523         Session session = null;
524 
525         try {
526             session = openSession();
527 
528             Lock[] array = new LockImpl[3];
529 
530             array[0] = getByUuid_PrevAndNext(session, lock, uuid,
531                     orderByComparator, true);
532 
533             array[1] = lock;
534 
535             array[2] = getByUuid_PrevAndNext(session, lock, uuid,
536                     orderByComparator, false);
537 
538             return array;
539         }
540         catch (Exception e) {
541             throw processException(e);
542         }
543         finally {
544             closeSession(session);
545         }
546     }
547 
548     protected Lock getByUuid_PrevAndNext(Session session, Lock lock,
549         String uuid, OrderByComparator orderByComparator, boolean previous) {
550         StringBundler query = null;
551 
552         if (orderByComparator != null) {
553             query = new StringBundler(6 +
554                     (orderByComparator.getOrderByFields().length * 6));
555         }
556         else {
557             query = new StringBundler(3);
558         }
559 
560         query.append(_SQL_SELECT_LOCK_WHERE);
561 
562         if (uuid == null) {
563             query.append(_FINDER_COLUMN_UUID_UUID_1);
564         }
565         else {
566             if (uuid.equals(StringPool.BLANK)) {
567                 query.append(_FINDER_COLUMN_UUID_UUID_3);
568             }
569             else {
570                 query.append(_FINDER_COLUMN_UUID_UUID_2);
571             }
572         }
573 
574         if (orderByComparator != null) {
575             String[] orderByFields = orderByComparator.getOrderByFields();
576 
577             if (orderByFields.length > 0) {
578                 query.append(WHERE_AND);
579             }
580 
581             for (int i = 0; i < orderByFields.length; i++) {
582                 query.append(_ORDER_BY_ENTITY_ALIAS);
583                 query.append(orderByFields[i]);
584 
585                 if ((i + 1) < orderByFields.length) {
586                     if (orderByComparator.isAscending() ^ previous) {
587                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
588                     }
589                     else {
590                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
591                     }
592                 }
593                 else {
594                     if (orderByComparator.isAscending() ^ previous) {
595                         query.append(WHERE_GREATER_THAN);
596                     }
597                     else {
598                         query.append(WHERE_LESSER_THAN);
599                     }
600                 }
601             }
602 
603             query.append(ORDER_BY_CLAUSE);
604 
605             for (int i = 0; i < orderByFields.length; i++) {
606                 query.append(_ORDER_BY_ENTITY_ALIAS);
607                 query.append(orderByFields[i]);
608 
609                 if ((i + 1) < orderByFields.length) {
610                     if (orderByComparator.isAscending() ^ previous) {
611                         query.append(ORDER_BY_ASC_HAS_NEXT);
612                     }
613                     else {
614                         query.append(ORDER_BY_DESC_HAS_NEXT);
615                     }
616                 }
617                 else {
618                     if (orderByComparator.isAscending() ^ previous) {
619                         query.append(ORDER_BY_ASC);
620                     }
621                     else {
622                         query.append(ORDER_BY_DESC);
623                     }
624                 }
625             }
626         }
627 
628         String sql = query.toString();
629 
630         Query q = session.createQuery(sql);
631 
632         q.setFirstResult(0);
633         q.setMaxResults(2);
634 
635         QueryPos qPos = QueryPos.getInstance(q);
636 
637         if (uuid != null) {
638             qPos.add(uuid);
639         }
640 
641         if (orderByComparator != null) {
642             Object[] values = orderByComparator.getOrderByValues(lock);
643 
644             for (Object value : values) {
645                 qPos.add(value);
646             }
647         }
648 
649         List<Lock> list = q.list();
650 
651         if (list.size() == 2) {
652             return list.get(1);
653         }
654         else {
655             return null;
656         }
657     }
658 
659     public List<Lock> findByExpirationDate(Date expirationDate)
660         throws SystemException {
661         return findByExpirationDate(expirationDate, QueryUtil.ALL_POS,
662             QueryUtil.ALL_POS, null);
663     }
664 
665     public List<Lock> findByExpirationDate(Date expirationDate, int start,
666         int end) throws SystemException {
667         return findByExpirationDate(expirationDate, start, end, null);
668     }
669 
670     public List<Lock> findByExpirationDate(Date expirationDate, int start,
671         int end, OrderByComparator orderByComparator) throws SystemException {
672         Object[] finderArgs = new Object[] {
673                 expirationDate,
674                 
675                 String.valueOf(start), String.valueOf(end),
676                 String.valueOf(orderByComparator)
677             };
678 
679         List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_EXPIRATIONDATE,
680                 finderArgs, this);
681 
682         if (list == null) {
683             Session session = null;
684 
685             try {
686                 session = openSession();
687 
688                 StringBundler query = null;
689 
690                 if (orderByComparator != null) {
691                     query = new StringBundler(3 +
692                             (orderByComparator.getOrderByFields().length * 3));
693                 }
694                 else {
695                     query = new StringBundler(2);
696                 }
697 
698                 query.append(_SQL_SELECT_LOCK_WHERE);
699 
700                 if (expirationDate == null) {
701                     query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
702                 }
703                 else {
704                     query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
705                 }
706 
707                 if (orderByComparator != null) {
708                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
709                         orderByComparator);
710                 }
711 
712                 String sql = query.toString();
713 
714                 Query q = session.createQuery(sql);
715 
716                 QueryPos qPos = QueryPos.getInstance(q);
717 
718                 if (expirationDate != null) {
719                     qPos.add(CalendarUtil.getTimestamp(expirationDate));
720                 }
721 
722                 list = (List<Lock>)QueryUtil.list(q, getDialect(), start, end);
723             }
724             catch (Exception e) {
725                 throw processException(e);
726             }
727             finally {
728                 if (list == null) {
729                     list = new ArrayList<Lock>();
730                 }
731 
732                 cacheResult(list);
733 
734                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_EXPIRATIONDATE,
735                     finderArgs, list);
736 
737                 closeSession(session);
738             }
739         }
740 
741         return list;
742     }
743 
744     public Lock findByExpirationDate_First(Date expirationDate,
745         OrderByComparator orderByComparator)
746         throws NoSuchLockException, SystemException {
747         List<Lock> list = findByExpirationDate(expirationDate, 0, 1,
748                 orderByComparator);
749 
750         if (list.isEmpty()) {
751             StringBundler msg = new StringBundler(4);
752 
753             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
754 
755             msg.append("expirationDate=");
756             msg.append(expirationDate);
757 
758             msg.append(StringPool.CLOSE_CURLY_BRACE);
759 
760             throw new NoSuchLockException(msg.toString());
761         }
762         else {
763             return list.get(0);
764         }
765     }
766 
767     public Lock findByExpirationDate_Last(Date expirationDate,
768         OrderByComparator orderByComparator)
769         throws NoSuchLockException, SystemException {
770         int count = countByExpirationDate(expirationDate);
771 
772         List<Lock> list = findByExpirationDate(expirationDate, count - 1,
773                 count, orderByComparator);
774 
775         if (list.isEmpty()) {
776             StringBundler msg = new StringBundler(4);
777 
778             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
779 
780             msg.append("expirationDate=");
781             msg.append(expirationDate);
782 
783             msg.append(StringPool.CLOSE_CURLY_BRACE);
784 
785             throw new NoSuchLockException(msg.toString());
786         }
787         else {
788             return list.get(0);
789         }
790     }
791 
792     public Lock[] findByExpirationDate_PrevAndNext(long lockId,
793         Date expirationDate, OrderByComparator orderByComparator)
794         throws NoSuchLockException, SystemException {
795         Lock lock = findByPrimaryKey(lockId);
796 
797         Session session = null;
798 
799         try {
800             session = openSession();
801 
802             Lock[] array = new LockImpl[3];
803 
804             array[0] = getByExpirationDate_PrevAndNext(session, lock,
805                     expirationDate, orderByComparator, true);
806 
807             array[1] = lock;
808 
809             array[2] = getByExpirationDate_PrevAndNext(session, lock,
810                     expirationDate, orderByComparator, false);
811 
812             return array;
813         }
814         catch (Exception e) {
815             throw processException(e);
816         }
817         finally {
818             closeSession(session);
819         }
820     }
821 
822     protected Lock getByExpirationDate_PrevAndNext(Session session, Lock lock,
823         Date expirationDate, OrderByComparator orderByComparator,
824         boolean previous) {
825         StringBundler query = null;
826 
827         if (orderByComparator != null) {
828             query = new StringBundler(6 +
829                     (orderByComparator.getOrderByFields().length * 6));
830         }
831         else {
832             query = new StringBundler(3);
833         }
834 
835         query.append(_SQL_SELECT_LOCK_WHERE);
836 
837         if (expirationDate == null) {
838             query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
839         }
840         else {
841             query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
842         }
843 
844         if (orderByComparator != null) {
845             String[] orderByFields = orderByComparator.getOrderByFields();
846 
847             if (orderByFields.length > 0) {
848                 query.append(WHERE_AND);
849             }
850 
851             for (int i = 0; i < orderByFields.length; i++) {
852                 query.append(_ORDER_BY_ENTITY_ALIAS);
853                 query.append(orderByFields[i]);
854 
855                 if ((i + 1) < orderByFields.length) {
856                     if (orderByComparator.isAscending() ^ previous) {
857                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
858                     }
859                     else {
860                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
861                     }
862                 }
863                 else {
864                     if (orderByComparator.isAscending() ^ previous) {
865                         query.append(WHERE_GREATER_THAN);
866                     }
867                     else {
868                         query.append(WHERE_LESSER_THAN);
869                     }
870                 }
871             }
872 
873             query.append(ORDER_BY_CLAUSE);
874 
875             for (int i = 0; i < orderByFields.length; i++) {
876                 query.append(_ORDER_BY_ENTITY_ALIAS);
877                 query.append(orderByFields[i]);
878 
879                 if ((i + 1) < orderByFields.length) {
880                     if (orderByComparator.isAscending() ^ previous) {
881                         query.append(ORDER_BY_ASC_HAS_NEXT);
882                     }
883                     else {
884                         query.append(ORDER_BY_DESC_HAS_NEXT);
885                     }
886                 }
887                 else {
888                     if (orderByComparator.isAscending() ^ previous) {
889                         query.append(ORDER_BY_ASC);
890                     }
891                     else {
892                         query.append(ORDER_BY_DESC);
893                     }
894                 }
895             }
896         }
897 
898         String sql = query.toString();
899 
900         Query q = session.createQuery(sql);
901 
902         q.setFirstResult(0);
903         q.setMaxResults(2);
904 
905         QueryPos qPos = QueryPos.getInstance(q);
906 
907         if (expirationDate != null) {
908             qPos.add(CalendarUtil.getTimestamp(expirationDate));
909         }
910 
911         if (orderByComparator != null) {
912             Object[] values = orderByComparator.getOrderByValues(lock);
913 
914             for (Object value : values) {
915                 qPos.add(value);
916             }
917         }
918 
919         List<Lock> list = q.list();
920 
921         if (list.size() == 2) {
922             return list.get(1);
923         }
924         else {
925             return null;
926         }
927     }
928 
929     public Lock findByC_K(String className, String key)
930         throws NoSuchLockException, SystemException {
931         Lock lock = fetchByC_K(className, key);
932 
933         if (lock == null) {
934             StringBundler msg = new StringBundler(6);
935 
936             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
937 
938             msg.append("className=");
939             msg.append(className);
940 
941             msg.append(", key=");
942             msg.append(key);
943 
944             msg.append(StringPool.CLOSE_CURLY_BRACE);
945 
946             if (_log.isWarnEnabled()) {
947                 _log.warn(msg.toString());
948             }
949 
950             throw new NoSuchLockException(msg.toString());
951         }
952 
953         return lock;
954     }
955 
956     public Lock fetchByC_K(String className, String key)
957         throws SystemException {
958         return fetchByC_K(className, key, true);
959     }
960 
961     public Lock fetchByC_K(String className, String key,
962         boolean retrieveFromCache) throws SystemException {
963         Object[] finderArgs = new Object[] { className, key };
964 
965         Object result = null;
966 
967         if (retrieveFromCache) {
968             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_K,
969                     finderArgs, this);
970         }
971 
972         if (result == null) {
973             Session session = null;
974 
975             try {
976                 session = openSession();
977 
978                 StringBundler query = new StringBundler(3);
979 
980                 query.append(_SQL_SELECT_LOCK_WHERE);
981 
982                 if (className == null) {
983                     query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
984                 }
985                 else {
986                     if (className.equals(StringPool.BLANK)) {
987                         query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
988                     }
989                     else {
990                         query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
991                     }
992                 }
993 
994                 if (key == null) {
995                     query.append(_FINDER_COLUMN_C_K_KEY_1);
996                 }
997                 else {
998                     if (key.equals(StringPool.BLANK)) {
999                         query.append(_FINDER_COLUMN_C_K_KEY_3);
1000                    }
1001                    else {
1002                        query.append(_FINDER_COLUMN_C_K_KEY_2);
1003                    }
1004                }
1005
1006                String sql = query.toString();
1007
1008                Query q = session.createQuery(sql);
1009
1010                QueryPos qPos = QueryPos.getInstance(q);
1011
1012                if (className != null) {
1013                    qPos.add(className);
1014                }
1015
1016                if (key != null) {
1017                    qPos.add(key);
1018                }
1019
1020                List<Lock> list = q.list();
1021
1022                result = list;
1023
1024                Lock lock = null;
1025
1026                if (list.isEmpty()) {
1027                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1028                        finderArgs, list);
1029                }
1030                else {
1031                    lock = list.get(0);
1032
1033                    cacheResult(lock);
1034
1035                    if ((lock.getClassName() == null) ||
1036                            !lock.getClassName().equals(className) ||
1037                            (lock.getKey() == null) ||
1038                            !lock.getKey().equals(key)) {
1039                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1040                            finderArgs, lock);
1041                    }
1042                }
1043
1044                return lock;
1045            }
1046            catch (Exception e) {
1047                throw processException(e);
1048            }
1049            finally {
1050                if (result == null) {
1051                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1052                        finderArgs, new ArrayList<Lock>());
1053                }
1054
1055                closeSession(session);
1056            }
1057        }
1058        else {
1059            if (result instanceof List<?>) {
1060                return null;
1061            }
1062            else {
1063                return (Lock)result;
1064            }
1065        }
1066    }
1067
1068    public List<Lock> findAll() throws SystemException {
1069        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1070    }
1071
1072    public List<Lock> findAll(int start, int end) throws SystemException {
1073        return findAll(start, end, null);
1074    }
1075
1076    public List<Lock> findAll(int start, int end,
1077        OrderByComparator orderByComparator) throws SystemException {
1078        Object[] finderArgs = new Object[] {
1079                String.valueOf(start), String.valueOf(end),
1080                String.valueOf(orderByComparator)
1081            };
1082
1083        List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1084                finderArgs, this);
1085
1086        if (list == null) {
1087            Session session = null;
1088
1089            try {
1090                session = openSession();
1091
1092                StringBundler query = null;
1093                String sql = null;
1094
1095                if (orderByComparator != null) {
1096                    query = new StringBundler(2 +
1097                            (orderByComparator.getOrderByFields().length * 3));
1098
1099                    query.append(_SQL_SELECT_LOCK);
1100
1101                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1102                        orderByComparator);
1103
1104                    sql = query.toString();
1105                }
1106
1107                sql = _SQL_SELECT_LOCK;
1108
1109                Query q = session.createQuery(sql);
1110
1111                if (orderByComparator == null) {
1112                    list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1113                            end, false);
1114
1115                    Collections.sort(list);
1116                }
1117                else {
1118                    list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1119                            end);
1120                }
1121            }
1122            catch (Exception e) {
1123                throw processException(e);
1124            }
1125            finally {
1126                if (list == null) {
1127                    list = new ArrayList<Lock>();
1128                }
1129
1130                cacheResult(list);
1131
1132                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1133
1134                closeSession(session);
1135            }
1136        }
1137
1138        return list;
1139    }
1140
1141    public void removeByUuid(String uuid) throws SystemException {
1142        for (Lock lock : findByUuid(uuid)) {
1143            remove(lock);
1144        }
1145    }
1146
1147    public void removeByExpirationDate(Date expirationDate)
1148        throws SystemException {
1149        for (Lock lock : findByExpirationDate(expirationDate)) {
1150            remove(lock);
1151        }
1152    }
1153
1154    public void removeByC_K(String className, String key)
1155        throws NoSuchLockException, SystemException {
1156        Lock lock = findByC_K(className, key);
1157
1158        remove(lock);
1159    }
1160
1161    public void removeAll() throws SystemException {
1162        for (Lock lock : findAll()) {
1163            remove(lock);
1164        }
1165    }
1166
1167    public int countByUuid(String uuid) throws SystemException {
1168        Object[] finderArgs = new Object[] { uuid };
1169
1170        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1171                finderArgs, this);
1172
1173        if (count == null) {
1174            Session session = null;
1175
1176            try {
1177                session = openSession();
1178
1179                StringBundler query = new StringBundler(2);
1180
1181                query.append(_SQL_COUNT_LOCK_WHERE);
1182
1183                if (uuid == null) {
1184                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1185                }
1186                else {
1187                    if (uuid.equals(StringPool.BLANK)) {
1188                        query.append(_FINDER_COLUMN_UUID_UUID_3);
1189                    }
1190                    else {
1191                        query.append(_FINDER_COLUMN_UUID_UUID_2);
1192                    }
1193                }
1194
1195                String sql = query.toString();
1196
1197                Query q = session.createQuery(sql);
1198
1199                QueryPos qPos = QueryPos.getInstance(q);
1200
1201                if (uuid != null) {
1202                    qPos.add(uuid);
1203                }
1204
1205                count = (Long)q.uniqueResult();
1206            }
1207            catch (Exception e) {
1208                throw processException(e);
1209            }
1210            finally {
1211                if (count == null) {
1212                    count = Long.valueOf(0);
1213                }
1214
1215                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1216                    finderArgs, count);
1217
1218                closeSession(session);
1219            }
1220        }
1221
1222        return count.intValue();
1223    }
1224
1225    public int countByExpirationDate(Date expirationDate)
1226        throws SystemException {
1227        Object[] finderArgs = new Object[] { expirationDate };
1228
1229        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
1230                finderArgs, this);
1231
1232        if (count == null) {
1233            Session session = null;
1234
1235            try {
1236                session = openSession();
1237
1238                StringBundler query = new StringBundler(2);
1239
1240                query.append(_SQL_COUNT_LOCK_WHERE);
1241
1242                if (expirationDate == null) {
1243                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1244                }
1245                else {
1246                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1247                }
1248
1249                String sql = query.toString();
1250
1251                Query q = session.createQuery(sql);
1252
1253                QueryPos qPos = QueryPos.getInstance(q);
1254
1255                if (expirationDate != null) {
1256                    qPos.add(CalendarUtil.getTimestamp(expirationDate));
1257                }
1258
1259                count = (Long)q.uniqueResult();
1260            }
1261            catch (Exception e) {
1262                throw processException(e);
1263            }
1264            finally {
1265                if (count == null) {
1266                    count = Long.valueOf(0);
1267                }
1268
1269                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
1270                    finderArgs, count);
1271
1272                closeSession(session);
1273            }
1274        }
1275
1276        return count.intValue();
1277    }
1278
1279    public int countByC_K(String className, String key)
1280        throws SystemException {
1281        Object[] finderArgs = new Object[] { className, key };
1282
1283        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1284                finderArgs, this);
1285
1286        if (count == null) {
1287            Session session = null;
1288
1289            try {
1290                session = openSession();
1291
1292                StringBundler query = new StringBundler(3);
1293
1294                query.append(_SQL_COUNT_LOCK_WHERE);
1295
1296                if (className == null) {
1297                    query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
1298                }
1299                else {
1300                    if (className.equals(StringPool.BLANK)) {
1301                        query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
1302                    }
1303                    else {
1304                        query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
1305                    }
1306                }
1307
1308                if (key == null) {
1309                    query.append(_FINDER_COLUMN_C_K_KEY_1);
1310                }
1311                else {
1312                    if (key.equals(StringPool.BLANK)) {
1313                        query.append(_FINDER_COLUMN_C_K_KEY_3);
1314                    }
1315                    else {
1316                        query.append(_FINDER_COLUMN_C_K_KEY_2);
1317                    }
1318                }
1319
1320                String sql = query.toString();
1321
1322                Query q = session.createQuery(sql);
1323
1324                QueryPos qPos = QueryPos.getInstance(q);
1325
1326                if (className != null) {
1327                    qPos.add(className);
1328                }
1329
1330                if (key != null) {
1331                    qPos.add(key);
1332                }
1333
1334                count = (Long)q.uniqueResult();
1335            }
1336            catch (Exception e) {
1337                throw processException(e);
1338            }
1339            finally {
1340                if (count == null) {
1341                    count = Long.valueOf(0);
1342                }
1343
1344                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
1345                    count);
1346
1347                closeSession(session);
1348            }
1349        }
1350
1351        return count.intValue();
1352    }
1353
1354    public int countAll() throws SystemException {
1355        Object[] finderArgs = new Object[0];
1356
1357        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1358                finderArgs, this);
1359
1360        if (count == null) {
1361            Session session = null;
1362
1363            try {
1364                session = openSession();
1365
1366                Query q = session.createQuery(_SQL_COUNT_LOCK);
1367
1368                count = (Long)q.uniqueResult();
1369            }
1370            catch (Exception e) {
1371                throw processException(e);
1372            }
1373            finally {
1374                if (count == null) {
1375                    count = Long.valueOf(0);
1376                }
1377
1378                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1379                    count);
1380
1381                closeSession(session);
1382            }
1383        }
1384
1385        return count.intValue();
1386    }
1387
1388    public void afterPropertiesSet() {
1389        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1390                    com.liferay.portal.util.PropsUtil.get(
1391                        "value.object.listener.com.liferay.portal.model.Lock")));
1392
1393        if (listenerClassNames.length > 0) {
1394            try {
1395                List<ModelListener<Lock>> listenersList = new ArrayList<ModelListener<Lock>>();
1396
1397                for (String listenerClassName : listenerClassNames) {
1398                    listenersList.add((ModelListener<Lock>)InstanceFactory.newInstance(
1399                            listenerClassName));
1400                }
1401
1402                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1403            }
1404            catch (Exception e) {
1405                _log.error(e);
1406            }
1407        }
1408    }
1409
1410    @BeanReference(type = AccountPersistence.class)
1411    protected AccountPersistence accountPersistence;
1412    @BeanReference(type = AddressPersistence.class)
1413    protected AddressPersistence addressPersistence;
1414    @BeanReference(type = BrowserTrackerPersistence.class)
1415    protected BrowserTrackerPersistence browserTrackerPersistence;
1416    @BeanReference(type = ClassNamePersistence.class)
1417    protected ClassNamePersistence classNamePersistence;
1418    @BeanReference(type = CompanyPersistence.class)
1419    protected CompanyPersistence companyPersistence;
1420    @BeanReference(type = ContactPersistence.class)
1421    protected ContactPersistence contactPersistence;
1422    @BeanReference(type = CountryPersistence.class)
1423    protected CountryPersistence countryPersistence;
1424    @BeanReference(type = EmailAddressPersistence.class)
1425    protected EmailAddressPersistence emailAddressPersistence;
1426    @BeanReference(type = GroupPersistence.class)
1427    protected GroupPersistence groupPersistence;
1428    @BeanReference(type = ImagePersistence.class)
1429    protected ImagePersistence imagePersistence;
1430    @BeanReference(type = LayoutPersistence.class)
1431    protected LayoutPersistence layoutPersistence;
1432    @BeanReference(type = LayoutPrototypePersistence.class)
1433    protected LayoutPrototypePersistence layoutPrototypePersistence;
1434    @BeanReference(type = LayoutSetPersistence.class)
1435    protected LayoutSetPersistence layoutSetPersistence;
1436    @BeanReference(type = LayoutSetPrototypePersistence.class)
1437    protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1438    @BeanReference(type = ListTypePersistence.class)
1439    protected ListTypePersistence listTypePersistence;
1440    @BeanReference(type = LockPersistence.class)
1441    protected LockPersistence lockPersistence;
1442    @BeanReference(type = MembershipRequestPersistence.class)
1443    protected MembershipRequestPersistence membershipRequestPersistence;
1444    @BeanReference(type = OrganizationPersistence.class)
1445    protected OrganizationPersistence organizationPersistence;
1446    @BeanReference(type = OrgGroupPermissionPersistence.class)
1447    protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1448    @BeanReference(type = OrgGroupRolePersistence.class)
1449    protected OrgGroupRolePersistence orgGroupRolePersistence;
1450    @BeanReference(type = OrgLaborPersistence.class)
1451    protected OrgLaborPersistence orgLaborPersistence;
1452    @BeanReference(type = PasswordPolicyPersistence.class)
1453    protected PasswordPolicyPersistence passwordPolicyPersistence;
1454    @BeanReference(type = PasswordPolicyRelPersistence.class)
1455    protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1456    @BeanReference(type = PasswordTrackerPersistence.class)
1457    protected PasswordTrackerPersistence passwordTrackerPersistence;
1458    @BeanReference(type = PermissionPersistence.class)
1459    protected PermissionPersistence permissionPersistence;
1460    @BeanReference(type = PhonePersistence.class)
1461    protected PhonePersistence phonePersistence;
1462    @BeanReference(type = PluginSettingPersistence.class)
1463    protected PluginSettingPersistence pluginSettingPersistence;
1464    @BeanReference(type = PortletPersistence.class)
1465    protected PortletPersistence portletPersistence;
1466    @BeanReference(type = PortletItemPersistence.class)
1467    protected PortletItemPersistence portletItemPersistence;
1468    @BeanReference(type = PortletPreferencesPersistence.class)
1469    protected PortletPreferencesPersistence portletPreferencesPersistence;
1470    @BeanReference(type = RegionPersistence.class)
1471    protected RegionPersistence regionPersistence;
1472    @BeanReference(type = ReleasePersistence.class)
1473    protected ReleasePersistence releasePersistence;
1474    @BeanReference(type = ResourcePersistence.class)
1475    protected ResourcePersistence resourcePersistence;
1476    @BeanReference(type = ResourceActionPersistence.class)
1477    protected ResourceActionPersistence resourceActionPersistence;
1478    @BeanReference(type = ResourceCodePersistence.class)
1479    protected ResourceCodePersistence resourceCodePersistence;
1480    @BeanReference(type = ResourcePermissionPersistence.class)
1481    protected ResourcePermissionPersistence resourcePermissionPersistence;
1482    @BeanReference(type = RolePersistence.class)
1483    protected RolePersistence rolePersistence;
1484    @BeanReference(type = ServiceComponentPersistence.class)
1485    protected ServiceComponentPersistence serviceComponentPersistence;
1486    @BeanReference(type = ShardPersistence.class)
1487    protected ShardPersistence shardPersistence;
1488    @BeanReference(type = SubscriptionPersistence.class)
1489    protected SubscriptionPersistence subscriptionPersistence;
1490    @BeanReference(type = TicketPersistence.class)
1491    protected TicketPersistence ticketPersistence;
1492    @BeanReference(type = TeamPersistence.class)
1493    protected TeamPersistence teamPersistence;
1494    @BeanReference(type = UserPersistence.class)
1495    protected UserPersistence userPersistence;
1496    @BeanReference(type = UserGroupPersistence.class)
1497    protected UserGroupPersistence userGroupPersistence;
1498    @BeanReference(type = UserGroupGroupRolePersistence.class)
1499    protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1500    @BeanReference(type = UserGroupRolePersistence.class)
1501    protected UserGroupRolePersistence userGroupRolePersistence;
1502    @BeanReference(type = UserIdMapperPersistence.class)
1503    protected UserIdMapperPersistence userIdMapperPersistence;
1504    @BeanReference(type = UserTrackerPersistence.class)
1505    protected UserTrackerPersistence userTrackerPersistence;
1506    @BeanReference(type = UserTrackerPathPersistence.class)
1507    protected UserTrackerPathPersistence userTrackerPathPersistence;
1508    @BeanReference(type = WebDAVPropsPersistence.class)
1509    protected WebDAVPropsPersistence webDAVPropsPersistence;
1510    @BeanReference(type = WebsitePersistence.class)
1511    protected WebsitePersistence websitePersistence;
1512    @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1513    protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1514    @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1515    protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1516    private static final String _SQL_SELECT_LOCK = "SELECT lock FROM Lock lock";
1517    private static final String _SQL_SELECT_LOCK_WHERE = "SELECT lock FROM Lock lock WHERE ";
1518    private static final String _SQL_COUNT_LOCK = "SELECT COUNT(lock) FROM Lock lock";
1519    private static final String _SQL_COUNT_LOCK_WHERE = "SELECT COUNT(lock) FROM Lock lock WHERE ";
1520    private static final String _FINDER_COLUMN_UUID_UUID_1 = "lock.uuid IS NULL";
1521    private static final String _FINDER_COLUMN_UUID_UUID_2 = "lock.uuid = ?";
1522    private static final String _FINDER_COLUMN_UUID_UUID_3 = "(lock.uuid IS NULL OR lock.uuid = ?)";
1523    private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1 = "lock.expirationDate < NULL";
1524    private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2 = "lock.expirationDate < ?";
1525    private static final String _FINDER_COLUMN_C_K_CLASSNAME_1 = "lock.className IS NULL AND ";
1526    private static final String _FINDER_COLUMN_C_K_CLASSNAME_2 = "lock.className = ? AND ";
1527    private static final String _FINDER_COLUMN_C_K_CLASSNAME_3 = "(lock.className IS NULL OR lock.className = ?) AND ";
1528    private static final String _FINDER_COLUMN_C_K_KEY_1 = "lock.key IS NULL";
1529    private static final String _FINDER_COLUMN_C_K_KEY_2 = "lock.key = ?";
1530    private static final String _FINDER_COLUMN_C_K_KEY_3 = "(lock.key IS NULL OR lock.key = ?)";
1531    private static final String _ORDER_BY_ENTITY_ALIAS = "lock.";
1532    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Lock exists with the primary key ";
1533    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Lock exists with the key {";
1534    private static Log _log = LogFactoryUtil.getLog(LockPersistenceImpl.class);
1535}