001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchLockException;
018    import com.liferay.portal.NoSuchModelException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.CalendarUtil;
032    import com.liferay.portal.kernel.util.GetterUtil;
033    import com.liferay.portal.kernel.util.InstanceFactory;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
038    import com.liferay.portal.kernel.util.Validator;
039    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040    import com.liferay.portal.model.CacheModel;
041    import com.liferay.portal.model.Lock;
042    import com.liferay.portal.model.ModelListener;
043    import com.liferay.portal.model.impl.LockImpl;
044    import com.liferay.portal.model.impl.LockModelImpl;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.Date;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the lock service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see LockPersistence
063     * @see LockUtil
064     * @generated
065     */
066    public class LockPersistenceImpl extends BasePersistenceImpl<Lock>
067            implements LockPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link LockUtil} to access the lock persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = LockImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
079                            LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
081                            new String[] {
082                                    String.class.getName(),
083                                    
084                            "java.lang.Integer", "java.lang.Integer",
085                                    "com.liferay.portal.kernel.util.OrderByComparator"
086                            });
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
088                            LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
090                            new String[] { String.class.getName() },
091                            LockModelImpl.UUID_COLUMN_BITMASK);
092            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
093                            LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
095                            new String[] { String.class.getName() });
096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTEXPIRATIONDATE =
097                    new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
098                            LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtExpirationDate",
100                            new String[] {
101                                    Date.class.getName(),
102                                    
103                            "java.lang.Integer", "java.lang.Integer",
104                                    "com.liferay.portal.kernel.util.OrderByComparator"
105                            });
106            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LTEXPIRATIONDATE =
107                    new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
108                            LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
110                            "findByLtExpirationDate", new String[] { Date.class.getName() },
111                            LockModelImpl.EXPIRATIONDATE_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_LTEXPIRATIONDATE = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
113                            LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
115                            "countByLtExpirationDate", new String[] { Date.class.getName() });
116            public static final FinderPath FINDER_PATH_FETCH_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
117                            LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
118                            FINDER_CLASS_NAME_ENTITY, "fetchByC_K",
119                            new String[] { String.class.getName(), String.class.getName() },
120                            LockModelImpl.CLASSNAME_COLUMN_BITMASK |
121                            LockModelImpl.KEY_COLUMN_BITMASK);
122            public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
123                            LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K",
125                            new String[] { String.class.getName(), String.class.getName() });
126            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
127                            LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
129            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
130                            LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
131                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
132            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
133                            LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
134                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
135    
136            /**
137             * Caches the lock in the entity cache if it is enabled.
138             *
139             * @param lock the lock
140             */
141            public void cacheResult(Lock lock) {
142                    EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
143                            LockImpl.class, lock.getPrimaryKey(), lock);
144    
145                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
146                            new Object[] { lock.getClassName(), lock.getKey() }, lock);
147    
148                    lock.resetOriginalValues();
149            }
150    
151            /**
152             * Caches the locks in the entity cache if it is enabled.
153             *
154             * @param locks the locks
155             */
156            public void cacheResult(List<Lock> locks) {
157                    for (Lock lock : locks) {
158                            if (EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
159                                                    LockImpl.class, lock.getPrimaryKey()) == null) {
160                                    cacheResult(lock);
161                            }
162                            else {
163                                    lock.resetOriginalValues();
164                            }
165                    }
166            }
167    
168            /**
169             * Clears the cache for all locks.
170             *
171             * <p>
172             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
173             * </p>
174             */
175            @Override
176            public void clearCache() {
177                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
178                            CacheRegistryUtil.clear(LockImpl.class.getName());
179                    }
180    
181                    EntityCacheUtil.clearCache(LockImpl.class.getName());
182    
183                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
184                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
185                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
186            }
187    
188            /**
189             * Clears the cache for the lock.
190             *
191             * <p>
192             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
193             * </p>
194             */
195            @Override
196            public void clearCache(Lock lock) {
197                    EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
198                            LockImpl.class, lock.getPrimaryKey());
199    
200                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
201                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
202    
203                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
204                            new Object[] { lock.getClassName(), lock.getKey() });
205            }
206    
207            /**
208             * Creates a new lock with the primary key. Does not add the lock to the database.
209             *
210             * @param lockId the primary key for the new lock
211             * @return the new lock
212             */
213            public Lock create(long lockId) {
214                    Lock lock = new LockImpl();
215    
216                    lock.setNew(true);
217                    lock.setPrimaryKey(lockId);
218    
219                    String uuid = PortalUUIDUtil.generate();
220    
221                    lock.setUuid(uuid);
222    
223                    return lock;
224            }
225    
226            /**
227             * Removes the lock with the primary key from the database. Also notifies the appropriate model listeners.
228             *
229             * @param primaryKey the primary key of the lock
230             * @return the lock that was removed
231             * @throws com.liferay.portal.NoSuchModelException if a lock with the primary key could not be found
232             * @throws SystemException if a system exception occurred
233             */
234            @Override
235            public Lock remove(Serializable primaryKey)
236                    throws NoSuchModelException, SystemException {
237                    return remove(((Long)primaryKey).longValue());
238            }
239    
240            /**
241             * Removes the lock with the primary key from the database. Also notifies the appropriate model listeners.
242             *
243             * @param lockId the primary key of the lock
244             * @return the lock that was removed
245             * @throws com.liferay.portal.NoSuchLockException if a lock with the primary key could not be found
246             * @throws SystemException if a system exception occurred
247             */
248            public Lock remove(long lockId) throws NoSuchLockException, SystemException {
249                    Session session = null;
250    
251                    try {
252                            session = openSession();
253    
254                            Lock lock = (Lock)session.get(LockImpl.class, Long.valueOf(lockId));
255    
256                            if (lock == null) {
257                                    if (_log.isWarnEnabled()) {
258                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + lockId);
259                                    }
260    
261                                    throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
262                                            lockId);
263                            }
264    
265                            return lockPersistence.remove(lock);
266                    }
267                    catch (NoSuchLockException nsee) {
268                            throw nsee;
269                    }
270                    catch (Exception e) {
271                            throw processException(e);
272                    }
273                    finally {
274                            closeSession(session);
275                    }
276            }
277    
278            /**
279             * Removes the lock from the database. Also notifies the appropriate model listeners.
280             *
281             * @param lock the lock
282             * @return the lock that was removed
283             * @throws SystemException if a system exception occurred
284             */
285            @Override
286            public Lock remove(Lock lock) throws SystemException {
287                    return super.remove(lock);
288            }
289    
290            @Override
291            protected Lock removeImpl(Lock lock) throws SystemException {
292                    lock = toUnwrappedModel(lock);
293    
294                    Session session = null;
295    
296                    try {
297                            session = openSession();
298    
299                            BatchSessionUtil.delete(session, lock);
300                    }
301                    catch (Exception e) {
302                            throw processException(e);
303                    }
304                    finally {
305                            closeSession(session);
306                    }
307    
308                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
309                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
310    
311                    LockModelImpl lockModelImpl = (LockModelImpl)lock;
312    
313                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
314                            new Object[] { lockModelImpl.getClassName(), lockModelImpl.getKey() });
315    
316                    EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
317                            LockImpl.class, lock.getPrimaryKey());
318    
319                    return lock;
320            }
321    
322            @Override
323            public Lock updateImpl(com.liferay.portal.model.Lock lock, boolean merge)
324                    throws SystemException {
325                    lock = toUnwrappedModel(lock);
326    
327                    boolean isNew = lock.isNew();
328    
329                    LockModelImpl lockModelImpl = (LockModelImpl)lock;
330    
331                    if (Validator.isNull(lock.getUuid())) {
332                            String uuid = PortalUUIDUtil.generate();
333    
334                            lock.setUuid(uuid);
335                    }
336    
337                    Session session = null;
338    
339                    try {
340                            session = openSession();
341    
342                            BatchSessionUtil.update(session, lock, merge);
343    
344                            lock.setNew(false);
345                    }
346                    catch (Exception e) {
347                            throw processException(e);
348                    }
349                    finally {
350                            closeSession(session);
351                    }
352    
353                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
354    
355                    if (isNew || !LockModelImpl.COLUMN_BITMASK_ENABLED) {
356                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
357                    }
358    
359                    else {
360                            if ((lockModelImpl.getColumnBitmask() &
361                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
362                                    Object[] args = new Object[] { lockModelImpl.getOriginalUuid() };
363    
364                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
365                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
366                                            args);
367    
368                                    args = new Object[] { lockModelImpl.getUuid() };
369    
370                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
371                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
372                                            args);
373                            }
374    
375                            if ((lockModelImpl.getColumnBitmask() &
376                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LTEXPIRATIONDATE.getColumnBitmask()) != 0) {
377                                    Object[] args = new Object[] {
378                                                    lockModelImpl.getOriginalExpirationDate()
379                                            };
380    
381                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LTEXPIRATIONDATE,
382                                            args);
383                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LTEXPIRATIONDATE,
384                                            args);
385    
386                                    args = new Object[] { lockModelImpl.getExpirationDate() };
387    
388                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LTEXPIRATIONDATE,
389                                            args);
390                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LTEXPIRATIONDATE,
391                                            args);
392                            }
393                    }
394    
395                    EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
396                            LockImpl.class, lock.getPrimaryKey(), lock);
397    
398                    if (isNew) {
399                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
400                                    new Object[] { lock.getClassName(), lock.getKey() }, lock);
401                    }
402                    else {
403                            if ((lockModelImpl.getColumnBitmask() &
404                                            FINDER_PATH_FETCH_BY_C_K.getColumnBitmask()) != 0) {
405                                    Object[] args = new Object[] {
406                                                    lockModelImpl.getOriginalClassName(),
407                                                    
408                                                    lockModelImpl.getOriginalKey()
409                                            };
410    
411                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
412                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K, args);
413    
414                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
415                                            new Object[] { lock.getClassName(), lock.getKey() }, lock);
416                            }
417                    }
418    
419                    return lock;
420            }
421    
422            protected Lock toUnwrappedModel(Lock lock) {
423                    if (lock instanceof LockImpl) {
424                            return lock;
425                    }
426    
427                    LockImpl lockImpl = new LockImpl();
428    
429                    lockImpl.setNew(lock.isNew());
430                    lockImpl.setPrimaryKey(lock.getPrimaryKey());
431    
432                    lockImpl.setUuid(lock.getUuid());
433                    lockImpl.setLockId(lock.getLockId());
434                    lockImpl.setCompanyId(lock.getCompanyId());
435                    lockImpl.setUserId(lock.getUserId());
436                    lockImpl.setUserName(lock.getUserName());
437                    lockImpl.setCreateDate(lock.getCreateDate());
438                    lockImpl.setClassName(lock.getClassName());
439                    lockImpl.setKey(lock.getKey());
440                    lockImpl.setOwner(lock.getOwner());
441                    lockImpl.setInheritable(lock.isInheritable());
442                    lockImpl.setExpirationDate(lock.getExpirationDate());
443    
444                    return lockImpl;
445            }
446    
447            /**
448             * Returns the lock with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
449             *
450             * @param primaryKey the primary key of the lock
451             * @return the lock
452             * @throws com.liferay.portal.NoSuchModelException if a lock with the primary key could not be found
453             * @throws SystemException if a system exception occurred
454             */
455            @Override
456            public Lock findByPrimaryKey(Serializable primaryKey)
457                    throws NoSuchModelException, SystemException {
458                    return findByPrimaryKey(((Long)primaryKey).longValue());
459            }
460    
461            /**
462             * Returns the lock with the primary key or throws a {@link com.liferay.portal.NoSuchLockException} if it could not be found.
463             *
464             * @param lockId the primary key of the lock
465             * @return the lock
466             * @throws com.liferay.portal.NoSuchLockException if a lock with the primary key could not be found
467             * @throws SystemException if a system exception occurred
468             */
469            public Lock findByPrimaryKey(long lockId)
470                    throws NoSuchLockException, SystemException {
471                    Lock lock = fetchByPrimaryKey(lockId);
472    
473                    if (lock == null) {
474                            if (_log.isWarnEnabled()) {
475                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + lockId);
476                            }
477    
478                            throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
479                                    lockId);
480                    }
481    
482                    return lock;
483            }
484    
485            /**
486             * Returns the lock with the primary key or returns <code>null</code> if it could not be found.
487             *
488             * @param primaryKey the primary key of the lock
489             * @return the lock, or <code>null</code> if a lock with the primary key could not be found
490             * @throws SystemException if a system exception occurred
491             */
492            @Override
493            public Lock fetchByPrimaryKey(Serializable primaryKey)
494                    throws SystemException {
495                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
496            }
497    
498            /**
499             * Returns the lock with the primary key or returns <code>null</code> if it could not be found.
500             *
501             * @param lockId the primary key of the lock
502             * @return the lock, or <code>null</code> if a lock with the primary key could not be found
503             * @throws SystemException if a system exception occurred
504             */
505            public Lock fetchByPrimaryKey(long lockId) throws SystemException {
506                    Lock lock = (Lock)EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
507                                    LockImpl.class, lockId);
508    
509                    if (lock == _nullLock) {
510                            return null;
511                    }
512    
513                    if (lock == null) {
514                            Session session = null;
515    
516                            boolean hasException = false;
517    
518                            try {
519                                    session = openSession();
520    
521                                    lock = (Lock)session.get(LockImpl.class, Long.valueOf(lockId));
522                            }
523                            catch (Exception e) {
524                                    hasException = true;
525    
526                                    throw processException(e);
527                            }
528                            finally {
529                                    if (lock != null) {
530                                            cacheResult(lock);
531                                    }
532                                    else if (!hasException) {
533                                            EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
534                                                    LockImpl.class, lockId, _nullLock);
535                                    }
536    
537                                    closeSession(session);
538                            }
539                    }
540    
541                    return lock;
542            }
543    
544            /**
545             * Returns all the locks where uuid = &#63;.
546             *
547             * @param uuid the uuid
548             * @return the matching locks
549             * @throws SystemException if a system exception occurred
550             */
551            public List<Lock> findByUuid(String uuid) throws SystemException {
552                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
553            }
554    
555            /**
556             * Returns a range of all the locks where uuid = &#63;.
557             *
558             * <p>
559             * 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.
560             * </p>
561             *
562             * @param uuid the uuid
563             * @param start the lower bound of the range of locks
564             * @param end the upper bound of the range of locks (not inclusive)
565             * @return the range of matching locks
566             * @throws SystemException if a system exception occurred
567             */
568            public List<Lock> findByUuid(String uuid, int start, int end)
569                    throws SystemException {
570                    return findByUuid(uuid, start, end, null);
571            }
572    
573            /**
574             * Returns an ordered range of all the locks where uuid = &#63;.
575             *
576             * <p>
577             * 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.
578             * </p>
579             *
580             * @param uuid the uuid
581             * @param start the lower bound of the range of locks
582             * @param end the upper bound of the range of locks (not inclusive)
583             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
584             * @return the ordered range of matching locks
585             * @throws SystemException if a system exception occurred
586             */
587            public List<Lock> findByUuid(String uuid, int start, int end,
588                    OrderByComparator orderByComparator) throws SystemException {
589                    FinderPath finderPath = null;
590                    Object[] finderArgs = null;
591    
592                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
593                                    (orderByComparator == null)) {
594                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
595                            finderArgs = new Object[] { uuid };
596                    }
597                    else {
598                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
599                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
600                    }
601    
602                    List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
603                                    finderArgs, this);
604    
605                    if (list == null) {
606                            StringBundler query = null;
607    
608                            if (orderByComparator != null) {
609                                    query = new StringBundler(3 +
610                                                    (orderByComparator.getOrderByFields().length * 3));
611                            }
612                            else {
613                                    query = new StringBundler(2);
614                            }
615    
616                            query.append(_SQL_SELECT_LOCK_WHERE);
617    
618                            if (uuid == null) {
619                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
620                            }
621                            else {
622                                    if (uuid.equals(StringPool.BLANK)) {
623                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
624                                    }
625                                    else {
626                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
627                                    }
628                            }
629    
630                            if (orderByComparator != null) {
631                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
632                                            orderByComparator);
633                            }
634    
635                            String sql = query.toString();
636    
637                            Session session = null;
638    
639                            try {
640                                    session = openSession();
641    
642                                    Query q = session.createQuery(sql);
643    
644                                    QueryPos qPos = QueryPos.getInstance(q);
645    
646                                    if (uuid != null) {
647                                            qPos.add(uuid);
648                                    }
649    
650                                    list = (List<Lock>)QueryUtil.list(q, getDialect(), start, end);
651                            }
652                            catch (Exception e) {
653                                    throw processException(e);
654                            }
655                            finally {
656                                    if (list == null) {
657                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
658                                    }
659                                    else {
660                                            cacheResult(list);
661    
662                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
663                                    }
664    
665                                    closeSession(session);
666                            }
667                    }
668    
669                    return list;
670            }
671    
672            /**
673             * Returns the first lock in the ordered set where uuid = &#63;.
674             *
675             * <p>
676             * 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.
677             * </p>
678             *
679             * @param uuid the uuid
680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
681             * @return the first matching lock
682             * @throws com.liferay.portal.NoSuchLockException if a matching lock could not be found
683             * @throws SystemException if a system exception occurred
684             */
685            public Lock findByUuid_First(String uuid,
686                    OrderByComparator orderByComparator)
687                    throws NoSuchLockException, SystemException {
688                    List<Lock> list = findByUuid(uuid, 0, 1, orderByComparator);
689    
690                    if (list.isEmpty()) {
691                            StringBundler msg = new StringBundler(4);
692    
693                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
694    
695                            msg.append("uuid=");
696                            msg.append(uuid);
697    
698                            msg.append(StringPool.CLOSE_CURLY_BRACE);
699    
700                            throw new NoSuchLockException(msg.toString());
701                    }
702                    else {
703                            return list.get(0);
704                    }
705            }
706    
707            /**
708             * Returns the last lock in the ordered set where uuid = &#63;.
709             *
710             * <p>
711             * 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.
712             * </p>
713             *
714             * @param uuid the uuid
715             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
716             * @return the last matching lock
717             * @throws com.liferay.portal.NoSuchLockException if a matching lock could not be found
718             * @throws SystemException if a system exception occurred
719             */
720            public Lock findByUuid_Last(String uuid, OrderByComparator orderByComparator)
721                    throws NoSuchLockException, SystemException {
722                    int count = countByUuid(uuid);
723    
724                    List<Lock> list = findByUuid(uuid, count - 1, count, orderByComparator);
725    
726                    if (list.isEmpty()) {
727                            StringBundler msg = new StringBundler(4);
728    
729                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
730    
731                            msg.append("uuid=");
732                            msg.append(uuid);
733    
734                            msg.append(StringPool.CLOSE_CURLY_BRACE);
735    
736                            throw new NoSuchLockException(msg.toString());
737                    }
738                    else {
739                            return list.get(0);
740                    }
741            }
742    
743            /**
744             * Returns the locks before and after the current lock in the ordered set where uuid = &#63;.
745             *
746             * <p>
747             * 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.
748             * </p>
749             *
750             * @param lockId the primary key of the current lock
751             * @param uuid the uuid
752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
753             * @return the previous, current, and next lock
754             * @throws com.liferay.portal.NoSuchLockException if a lock with the primary key could not be found
755             * @throws SystemException if a system exception occurred
756             */
757            public Lock[] findByUuid_PrevAndNext(long lockId, String uuid,
758                    OrderByComparator orderByComparator)
759                    throws NoSuchLockException, SystemException {
760                    Lock lock = findByPrimaryKey(lockId);
761    
762                    Session session = null;
763    
764                    try {
765                            session = openSession();
766    
767                            Lock[] array = new LockImpl[3];
768    
769                            array[0] = getByUuid_PrevAndNext(session, lock, uuid,
770                                            orderByComparator, true);
771    
772                            array[1] = lock;
773    
774                            array[2] = getByUuid_PrevAndNext(session, lock, uuid,
775                                            orderByComparator, false);
776    
777                            return array;
778                    }
779                    catch (Exception e) {
780                            throw processException(e);
781                    }
782                    finally {
783                            closeSession(session);
784                    }
785            }
786    
787            protected Lock getByUuid_PrevAndNext(Session session, Lock lock,
788                    String uuid, OrderByComparator orderByComparator, boolean previous) {
789                    StringBundler query = null;
790    
791                    if (orderByComparator != null) {
792                            query = new StringBundler(6 +
793                                            (orderByComparator.getOrderByFields().length * 6));
794                    }
795                    else {
796                            query = new StringBundler(3);
797                    }
798    
799                    query.append(_SQL_SELECT_LOCK_WHERE);
800    
801                    if (uuid == null) {
802                            query.append(_FINDER_COLUMN_UUID_UUID_1);
803                    }
804                    else {
805                            if (uuid.equals(StringPool.BLANK)) {
806                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
807                            }
808                            else {
809                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
810                            }
811                    }
812    
813                    if (orderByComparator != null) {
814                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
815    
816                            if (orderByConditionFields.length > 0) {
817                                    query.append(WHERE_AND);
818                            }
819    
820                            for (int i = 0; i < orderByConditionFields.length; i++) {
821                                    query.append(_ORDER_BY_ENTITY_ALIAS);
822                                    query.append(orderByConditionFields[i]);
823    
824                                    if ((i + 1) < orderByConditionFields.length) {
825                                            if (orderByComparator.isAscending() ^ previous) {
826                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
827                                            }
828                                            else {
829                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
830                                            }
831                                    }
832                                    else {
833                                            if (orderByComparator.isAscending() ^ previous) {
834                                                    query.append(WHERE_GREATER_THAN);
835                                            }
836                                            else {
837                                                    query.append(WHERE_LESSER_THAN);
838                                            }
839                                    }
840                            }
841    
842                            query.append(ORDER_BY_CLAUSE);
843    
844                            String[] orderByFields = orderByComparator.getOrderByFields();
845    
846                            for (int i = 0; i < orderByFields.length; i++) {
847                                    query.append(_ORDER_BY_ENTITY_ALIAS);
848                                    query.append(orderByFields[i]);
849    
850                                    if ((i + 1) < orderByFields.length) {
851                                            if (orderByComparator.isAscending() ^ previous) {
852                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
853                                            }
854                                            else {
855                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
856                                            }
857                                    }
858                                    else {
859                                            if (orderByComparator.isAscending() ^ previous) {
860                                                    query.append(ORDER_BY_ASC);
861                                            }
862                                            else {
863                                                    query.append(ORDER_BY_DESC);
864                                            }
865                                    }
866                            }
867                    }
868    
869                    String sql = query.toString();
870    
871                    Query q = session.createQuery(sql);
872    
873                    q.setFirstResult(0);
874                    q.setMaxResults(2);
875    
876                    QueryPos qPos = QueryPos.getInstance(q);
877    
878                    if (uuid != null) {
879                            qPos.add(uuid);
880                    }
881    
882                    if (orderByComparator != null) {
883                            Object[] values = orderByComparator.getOrderByConditionValues(lock);
884    
885                            for (Object value : values) {
886                                    qPos.add(value);
887                            }
888                    }
889    
890                    List<Lock> list = q.list();
891    
892                    if (list.size() == 2) {
893                            return list.get(1);
894                    }
895                    else {
896                            return null;
897                    }
898            }
899    
900            /**
901             * Returns all the locks where expirationDate &lt; &#63;.
902             *
903             * @param expirationDate the expiration date
904             * @return the matching locks
905             * @throws SystemException if a system exception occurred
906             */
907            public List<Lock> findByLtExpirationDate(Date expirationDate)
908                    throws SystemException {
909                    return findByLtExpirationDate(expirationDate, QueryUtil.ALL_POS,
910                            QueryUtil.ALL_POS, null);
911            }
912    
913            /**
914             * Returns a range of all the locks where expirationDate &lt; &#63;.
915             *
916             * <p>
917             * 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.
918             * </p>
919             *
920             * @param expirationDate the expiration date
921             * @param start the lower bound of the range of locks
922             * @param end the upper bound of the range of locks (not inclusive)
923             * @return the range of matching locks
924             * @throws SystemException if a system exception occurred
925             */
926            public List<Lock> findByLtExpirationDate(Date expirationDate, int start,
927                    int end) throws SystemException {
928                    return findByLtExpirationDate(expirationDate, start, end, null);
929            }
930    
931            /**
932             * Returns an ordered range of all the locks where expirationDate &lt; &#63;.
933             *
934             * <p>
935             * 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.
936             * </p>
937             *
938             * @param expirationDate the expiration date
939             * @param start the lower bound of the range of locks
940             * @param end the upper bound of the range of locks (not inclusive)
941             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
942             * @return the ordered range of matching locks
943             * @throws SystemException if a system exception occurred
944             */
945            public List<Lock> findByLtExpirationDate(Date expirationDate, int start,
946                    int end, OrderByComparator orderByComparator) throws SystemException {
947                    FinderPath finderPath = null;
948                    Object[] finderArgs = null;
949    
950                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
951                                    (orderByComparator == null)) {
952                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LTEXPIRATIONDATE;
953                            finderArgs = new Object[] { expirationDate };
954                    }
955                    else {
956                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTEXPIRATIONDATE;
957                            finderArgs = new Object[] {
958                                            expirationDate,
959                                            
960                                            start, end, orderByComparator
961                                    };
962                    }
963    
964                    List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
965                                    finderArgs, this);
966    
967                    if (list == null) {
968                            StringBundler query = null;
969    
970                            if (orderByComparator != null) {
971                                    query = new StringBundler(3 +
972                                                    (orderByComparator.getOrderByFields().length * 3));
973                            }
974                            else {
975                                    query = new StringBundler(2);
976                            }
977    
978                            query.append(_SQL_SELECT_LOCK_WHERE);
979    
980                            if (expirationDate == null) {
981                                    query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
982                            }
983                            else {
984                                    query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
985                            }
986    
987                            if (orderByComparator != null) {
988                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
989                                            orderByComparator);
990                            }
991    
992                            String sql = query.toString();
993    
994                            Session session = null;
995    
996                            try {
997                                    session = openSession();
998    
999                                    Query q = session.createQuery(sql);
1000    
1001                                    QueryPos qPos = QueryPos.getInstance(q);
1002    
1003                                    if (expirationDate != null) {
1004                                            qPos.add(CalendarUtil.getTimestamp(expirationDate));
1005                                    }
1006    
1007                                    list = (List<Lock>)QueryUtil.list(q, getDialect(), start, end);
1008                            }
1009                            catch (Exception e) {
1010                                    throw processException(e);
1011                            }
1012                            finally {
1013                                    if (list == null) {
1014                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1015                                    }
1016                                    else {
1017                                            cacheResult(list);
1018    
1019                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1020                                    }
1021    
1022                                    closeSession(session);
1023                            }
1024                    }
1025    
1026                    return list;
1027            }
1028    
1029            /**
1030             * Returns the first lock in the ordered set where expirationDate &lt; &#63;.
1031             *
1032             * <p>
1033             * 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.
1034             * </p>
1035             *
1036             * @param expirationDate the expiration date
1037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1038             * @return the first matching lock
1039             * @throws com.liferay.portal.NoSuchLockException if a matching lock could not be found
1040             * @throws SystemException if a system exception occurred
1041             */
1042            public Lock findByLtExpirationDate_First(Date expirationDate,
1043                    OrderByComparator orderByComparator)
1044                    throws NoSuchLockException, SystemException {
1045                    List<Lock> list = findByLtExpirationDate(expirationDate, 0, 1,
1046                                    orderByComparator);
1047    
1048                    if (list.isEmpty()) {
1049                            StringBundler msg = new StringBundler(4);
1050    
1051                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1052    
1053                            msg.append("expirationDate=");
1054                            msg.append(expirationDate);
1055    
1056                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1057    
1058                            throw new NoSuchLockException(msg.toString());
1059                    }
1060                    else {
1061                            return list.get(0);
1062                    }
1063            }
1064    
1065            /**
1066             * Returns the last lock in the ordered set where expirationDate &lt; &#63;.
1067             *
1068             * <p>
1069             * 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.
1070             * </p>
1071             *
1072             * @param expirationDate the expiration date
1073             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1074             * @return the last matching lock
1075             * @throws com.liferay.portal.NoSuchLockException if a matching lock could not be found
1076             * @throws SystemException if a system exception occurred
1077             */
1078            public Lock findByLtExpirationDate_Last(Date expirationDate,
1079                    OrderByComparator orderByComparator)
1080                    throws NoSuchLockException, SystemException {
1081                    int count = countByLtExpirationDate(expirationDate);
1082    
1083                    List<Lock> list = findByLtExpirationDate(expirationDate, count - 1,
1084                                    count, orderByComparator);
1085    
1086                    if (list.isEmpty()) {
1087                            StringBundler msg = new StringBundler(4);
1088    
1089                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1090    
1091                            msg.append("expirationDate=");
1092                            msg.append(expirationDate);
1093    
1094                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1095    
1096                            throw new NoSuchLockException(msg.toString());
1097                    }
1098                    else {
1099                            return list.get(0);
1100                    }
1101            }
1102    
1103            /**
1104             * Returns the locks before and after the current lock in the ordered set where expirationDate &lt; &#63;.
1105             *
1106             * <p>
1107             * 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.
1108             * </p>
1109             *
1110             * @param lockId the primary key of the current lock
1111             * @param expirationDate the expiration date
1112             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1113             * @return the previous, current, and next lock
1114             * @throws com.liferay.portal.NoSuchLockException if a lock with the primary key could not be found
1115             * @throws SystemException if a system exception occurred
1116             */
1117            public Lock[] findByLtExpirationDate_PrevAndNext(long lockId,
1118                    Date expirationDate, OrderByComparator orderByComparator)
1119                    throws NoSuchLockException, SystemException {
1120                    Lock lock = findByPrimaryKey(lockId);
1121    
1122                    Session session = null;
1123    
1124                    try {
1125                            session = openSession();
1126    
1127                            Lock[] array = new LockImpl[3];
1128    
1129                            array[0] = getByLtExpirationDate_PrevAndNext(session, lock,
1130                                            expirationDate, orderByComparator, true);
1131    
1132                            array[1] = lock;
1133    
1134                            array[2] = getByLtExpirationDate_PrevAndNext(session, lock,
1135                                            expirationDate, orderByComparator, false);
1136    
1137                            return array;
1138                    }
1139                    catch (Exception e) {
1140                            throw processException(e);
1141                    }
1142                    finally {
1143                            closeSession(session);
1144                    }
1145            }
1146    
1147            protected Lock getByLtExpirationDate_PrevAndNext(Session session,
1148                    Lock lock, Date expirationDate, OrderByComparator orderByComparator,
1149                    boolean previous) {
1150                    StringBundler query = null;
1151    
1152                    if (orderByComparator != null) {
1153                            query = new StringBundler(6 +
1154                                            (orderByComparator.getOrderByFields().length * 6));
1155                    }
1156                    else {
1157                            query = new StringBundler(3);
1158                    }
1159    
1160                    query.append(_SQL_SELECT_LOCK_WHERE);
1161    
1162                    if (expirationDate == null) {
1163                            query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1164                    }
1165                    else {
1166                            query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1167                    }
1168    
1169                    if (orderByComparator != null) {
1170                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1171    
1172                            if (orderByConditionFields.length > 0) {
1173                                    query.append(WHERE_AND);
1174                            }
1175    
1176                            for (int i = 0; i < orderByConditionFields.length; i++) {
1177                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1178                                    query.append(orderByConditionFields[i]);
1179    
1180                                    if ((i + 1) < orderByConditionFields.length) {
1181                                            if (orderByComparator.isAscending() ^ previous) {
1182                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1183                                            }
1184                                            else {
1185                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1186                                            }
1187                                    }
1188                                    else {
1189                                            if (orderByComparator.isAscending() ^ previous) {
1190                                                    query.append(WHERE_GREATER_THAN);
1191                                            }
1192                                            else {
1193                                                    query.append(WHERE_LESSER_THAN);
1194                                            }
1195                                    }
1196                            }
1197    
1198                            query.append(ORDER_BY_CLAUSE);
1199    
1200                            String[] orderByFields = orderByComparator.getOrderByFields();
1201    
1202                            for (int i = 0; i < orderByFields.length; i++) {
1203                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1204                                    query.append(orderByFields[i]);
1205    
1206                                    if ((i + 1) < orderByFields.length) {
1207                                            if (orderByComparator.isAscending() ^ previous) {
1208                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1209                                            }
1210                                            else {
1211                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1212                                            }
1213                                    }
1214                                    else {
1215                                            if (orderByComparator.isAscending() ^ previous) {
1216                                                    query.append(ORDER_BY_ASC);
1217                                            }
1218                                            else {
1219                                                    query.append(ORDER_BY_DESC);
1220                                            }
1221                                    }
1222                            }
1223                    }
1224    
1225                    String sql = query.toString();
1226    
1227                    Query q = session.createQuery(sql);
1228    
1229                    q.setFirstResult(0);
1230                    q.setMaxResults(2);
1231    
1232                    QueryPos qPos = QueryPos.getInstance(q);
1233    
1234                    if (expirationDate != null) {
1235                            qPos.add(CalendarUtil.getTimestamp(expirationDate));
1236                    }
1237    
1238                    if (orderByComparator != null) {
1239                            Object[] values = orderByComparator.getOrderByConditionValues(lock);
1240    
1241                            for (Object value : values) {
1242                                    qPos.add(value);
1243                            }
1244                    }
1245    
1246                    List<Lock> list = q.list();
1247    
1248                    if (list.size() == 2) {
1249                            return list.get(1);
1250                    }
1251                    else {
1252                            return null;
1253                    }
1254            }
1255    
1256            /**
1257             * Returns the lock where className = &#63; and key = &#63; or throws a {@link com.liferay.portal.NoSuchLockException} if it could not be found.
1258             *
1259             * @param className the class name
1260             * @param key the key
1261             * @return the matching lock
1262             * @throws com.liferay.portal.NoSuchLockException if a matching lock could not be found
1263             * @throws SystemException if a system exception occurred
1264             */
1265            public Lock findByC_K(String className, String key)
1266                    throws NoSuchLockException, SystemException {
1267                    Lock lock = fetchByC_K(className, key);
1268    
1269                    if (lock == null) {
1270                            StringBundler msg = new StringBundler(6);
1271    
1272                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1273    
1274                            msg.append("className=");
1275                            msg.append(className);
1276    
1277                            msg.append(", key=");
1278                            msg.append(key);
1279    
1280                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1281    
1282                            if (_log.isWarnEnabled()) {
1283                                    _log.warn(msg.toString());
1284                            }
1285    
1286                            throw new NoSuchLockException(msg.toString());
1287                    }
1288    
1289                    return lock;
1290            }
1291    
1292            /**
1293             * Returns the lock where className = &#63; and key = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1294             *
1295             * @param className the class name
1296             * @param key the key
1297             * @return the matching lock, or <code>null</code> if a matching lock could not be found
1298             * @throws SystemException if a system exception occurred
1299             */
1300            public Lock fetchByC_K(String className, String key)
1301                    throws SystemException {
1302                    return fetchByC_K(className, key, true);
1303            }
1304    
1305            /**
1306             * Returns the lock where className = &#63; and key = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1307             *
1308             * @param className the class name
1309             * @param key the key
1310             * @param retrieveFromCache whether to use the finder cache
1311             * @return the matching lock, or <code>null</code> if a matching lock could not be found
1312             * @throws SystemException if a system exception occurred
1313             */
1314            public Lock fetchByC_K(String className, String key,
1315                    boolean retrieveFromCache) throws SystemException {
1316                    Object[] finderArgs = new Object[] { className, key };
1317    
1318                    Object result = null;
1319    
1320                    if (retrieveFromCache) {
1321                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_K,
1322                                            finderArgs, this);
1323                    }
1324    
1325                    if (result == null) {
1326                            StringBundler query = new StringBundler(3);
1327    
1328                            query.append(_SQL_SELECT_LOCK_WHERE);
1329    
1330                            if (className == null) {
1331                                    query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
1332                            }
1333                            else {
1334                                    if (className.equals(StringPool.BLANK)) {
1335                                            query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
1336                                    }
1337                                    else {
1338                                            query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
1339                                    }
1340                            }
1341    
1342                            if (key == null) {
1343                                    query.append(_FINDER_COLUMN_C_K_KEY_1);
1344                            }
1345                            else {
1346                                    if (key.equals(StringPool.BLANK)) {
1347                                            query.append(_FINDER_COLUMN_C_K_KEY_3);
1348                                    }
1349                                    else {
1350                                            query.append(_FINDER_COLUMN_C_K_KEY_2);
1351                                    }
1352                            }
1353    
1354                            String sql = query.toString();
1355    
1356                            Session session = null;
1357    
1358                            try {
1359                                    session = openSession();
1360    
1361                                    Query q = session.createQuery(sql);
1362    
1363                                    QueryPos qPos = QueryPos.getInstance(q);
1364    
1365                                    if (className != null) {
1366                                            qPos.add(className);
1367                                    }
1368    
1369                                    if (key != null) {
1370                                            qPos.add(key);
1371                                    }
1372    
1373                                    List<Lock> list = q.list();
1374    
1375                                    result = list;
1376    
1377                                    Lock lock = null;
1378    
1379                                    if (list.isEmpty()) {
1380                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1381                                                    finderArgs, list);
1382                                    }
1383                                    else {
1384                                            lock = list.get(0);
1385    
1386                                            cacheResult(lock);
1387    
1388                                            if ((lock.getClassName() == null) ||
1389                                                            !lock.getClassName().equals(className) ||
1390                                                            (lock.getKey() == null) ||
1391                                                            !lock.getKey().equals(key)) {
1392                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1393                                                            finderArgs, lock);
1394                                            }
1395                                    }
1396    
1397                                    return lock;
1398                            }
1399                            catch (Exception e) {
1400                                    throw processException(e);
1401                            }
1402                            finally {
1403                                    if (result == null) {
1404                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
1405                                                    finderArgs);
1406                                    }
1407    
1408                                    closeSession(session);
1409                            }
1410                    }
1411                    else {
1412                            if (result instanceof List<?>) {
1413                                    return null;
1414                            }
1415                            else {
1416                                    return (Lock)result;
1417                            }
1418                    }
1419            }
1420    
1421            /**
1422             * Returns all the locks.
1423             *
1424             * @return the locks
1425             * @throws SystemException if a system exception occurred
1426             */
1427            public List<Lock> findAll() throws SystemException {
1428                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1429            }
1430    
1431            /**
1432             * Returns a range of all the locks.
1433             *
1434             * <p>
1435             * 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.
1436             * </p>
1437             *
1438             * @param start the lower bound of the range of locks
1439             * @param end the upper bound of the range of locks (not inclusive)
1440             * @return the range of locks
1441             * @throws SystemException if a system exception occurred
1442             */
1443            public List<Lock> findAll(int start, int end) throws SystemException {
1444                    return findAll(start, end, null);
1445            }
1446    
1447            /**
1448             * Returns an ordered range of all the locks.
1449             *
1450             * <p>
1451             * 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.
1452             * </p>
1453             *
1454             * @param start the lower bound of the range of locks
1455             * @param end the upper bound of the range of locks (not inclusive)
1456             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1457             * @return the ordered range of locks
1458             * @throws SystemException if a system exception occurred
1459             */
1460            public List<Lock> findAll(int start, int end,
1461                    OrderByComparator orderByComparator) throws SystemException {
1462                    FinderPath finderPath = null;
1463                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1464    
1465                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1466                                    (orderByComparator == null)) {
1467                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1468                            finderArgs = FINDER_ARGS_EMPTY;
1469                    }
1470                    else {
1471                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1472                            finderArgs = new Object[] { start, end, orderByComparator };
1473                    }
1474    
1475                    List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
1476                                    finderArgs, this);
1477    
1478                    if (list == null) {
1479                            StringBundler query = null;
1480                            String sql = null;
1481    
1482                            if (orderByComparator != null) {
1483                                    query = new StringBundler(2 +
1484                                                    (orderByComparator.getOrderByFields().length * 3));
1485    
1486                                    query.append(_SQL_SELECT_LOCK);
1487    
1488                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1489                                            orderByComparator);
1490    
1491                                    sql = query.toString();
1492                            }
1493                            else {
1494                                    sql = _SQL_SELECT_LOCK;
1495                            }
1496    
1497                            Session session = null;
1498    
1499                            try {
1500                                    session = openSession();
1501    
1502                                    Query q = session.createQuery(sql);
1503    
1504                                    if (orderByComparator == null) {
1505                                            list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1506                                                            end, false);
1507    
1508                                            Collections.sort(list);
1509                                    }
1510                                    else {
1511                                            list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1512                                                            end);
1513                                    }
1514                            }
1515                            catch (Exception e) {
1516                                    throw processException(e);
1517                            }
1518                            finally {
1519                                    if (list == null) {
1520                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1521                                    }
1522                                    else {
1523                                            cacheResult(list);
1524    
1525                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1526                                    }
1527    
1528                                    closeSession(session);
1529                            }
1530                    }
1531    
1532                    return list;
1533            }
1534    
1535            /**
1536             * Removes all the locks where uuid = &#63; from the database.
1537             *
1538             * @param uuid the uuid
1539             * @throws SystemException if a system exception occurred
1540             */
1541            public void removeByUuid(String uuid) throws SystemException {
1542                    for (Lock lock : findByUuid(uuid)) {
1543                            lockPersistence.remove(lock);
1544                    }
1545            }
1546    
1547            /**
1548             * Removes all the locks where expirationDate &lt; &#63; from the database.
1549             *
1550             * @param expirationDate the expiration date
1551             * @throws SystemException if a system exception occurred
1552             */
1553            public void removeByLtExpirationDate(Date expirationDate)
1554                    throws SystemException {
1555                    for (Lock lock : findByLtExpirationDate(expirationDate)) {
1556                            lockPersistence.remove(lock);
1557                    }
1558            }
1559    
1560            /**
1561             * Removes the lock where className = &#63; and key = &#63; from the database.
1562             *
1563             * @param className the class name
1564             * @param key the key
1565             * @throws SystemException if a system exception occurred
1566             */
1567            public void removeByC_K(String className, String key)
1568                    throws NoSuchLockException, SystemException {
1569                    Lock lock = findByC_K(className, key);
1570    
1571                    lockPersistence.remove(lock);
1572            }
1573    
1574            /**
1575             * Removes all the locks from the database.
1576             *
1577             * @throws SystemException if a system exception occurred
1578             */
1579            public void removeAll() throws SystemException {
1580                    for (Lock lock : findAll()) {
1581                            lockPersistence.remove(lock);
1582                    }
1583            }
1584    
1585            /**
1586             * Returns the number of locks where uuid = &#63;.
1587             *
1588             * @param uuid the uuid
1589             * @return the number of matching locks
1590             * @throws SystemException if a system exception occurred
1591             */
1592            public int countByUuid(String uuid) throws SystemException {
1593                    Object[] finderArgs = new Object[] { uuid };
1594    
1595                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1596                                    finderArgs, this);
1597    
1598                    if (count == null) {
1599                            StringBundler query = new StringBundler(2);
1600    
1601                            query.append(_SQL_COUNT_LOCK_WHERE);
1602    
1603                            if (uuid == null) {
1604                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1605                            }
1606                            else {
1607                                    if (uuid.equals(StringPool.BLANK)) {
1608                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1609                                    }
1610                                    else {
1611                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1612                                    }
1613                            }
1614    
1615                            String sql = query.toString();
1616    
1617                            Session session = null;
1618    
1619                            try {
1620                                    session = openSession();
1621    
1622                                    Query q = session.createQuery(sql);
1623    
1624                                    QueryPos qPos = QueryPos.getInstance(q);
1625    
1626                                    if (uuid != null) {
1627                                            qPos.add(uuid);
1628                                    }
1629    
1630                                    count = (Long)q.uniqueResult();
1631                            }
1632                            catch (Exception e) {
1633                                    throw processException(e);
1634                            }
1635                            finally {
1636                                    if (count == null) {
1637                                            count = Long.valueOf(0);
1638                                    }
1639    
1640                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1641                                            finderArgs, count);
1642    
1643                                    closeSession(session);
1644                            }
1645                    }
1646    
1647                    return count.intValue();
1648            }
1649    
1650            /**
1651             * Returns the number of locks where expirationDate &lt; &#63;.
1652             *
1653             * @param expirationDate the expiration date
1654             * @return the number of matching locks
1655             * @throws SystemException if a system exception occurred
1656             */
1657            public int countByLtExpirationDate(Date expirationDate)
1658                    throws SystemException {
1659                    Object[] finderArgs = new Object[] { expirationDate };
1660    
1661                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LTEXPIRATIONDATE,
1662                                    finderArgs, this);
1663    
1664                    if (count == null) {
1665                            StringBundler query = new StringBundler(2);
1666    
1667                            query.append(_SQL_COUNT_LOCK_WHERE);
1668    
1669                            if (expirationDate == null) {
1670                                    query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1671                            }
1672                            else {
1673                                    query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1674                            }
1675    
1676                            String sql = query.toString();
1677    
1678                            Session session = null;
1679    
1680                            try {
1681                                    session = openSession();
1682    
1683                                    Query q = session.createQuery(sql);
1684    
1685                                    QueryPos qPos = QueryPos.getInstance(q);
1686    
1687                                    if (expirationDate != null) {
1688                                            qPos.add(CalendarUtil.getTimestamp(expirationDate));
1689                                    }
1690    
1691                                    count = (Long)q.uniqueResult();
1692                            }
1693                            catch (Exception e) {
1694                                    throw processException(e);
1695                            }
1696                            finally {
1697                                    if (count == null) {
1698                                            count = Long.valueOf(0);
1699                                    }
1700    
1701                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LTEXPIRATIONDATE,
1702                                            finderArgs, count);
1703    
1704                                    closeSession(session);
1705                            }
1706                    }
1707    
1708                    return count.intValue();
1709            }
1710    
1711            /**
1712             * Returns the number of locks where className = &#63; and key = &#63;.
1713             *
1714             * @param className the class name
1715             * @param key the key
1716             * @return the number of matching locks
1717             * @throws SystemException if a system exception occurred
1718             */
1719            public int countByC_K(String className, String key)
1720                    throws SystemException {
1721                    Object[] finderArgs = new Object[] { className, key };
1722    
1723                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1724                                    finderArgs, this);
1725    
1726                    if (count == null) {
1727                            StringBundler query = new StringBundler(3);
1728    
1729                            query.append(_SQL_COUNT_LOCK_WHERE);
1730    
1731                            if (className == null) {
1732                                    query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
1733                            }
1734                            else {
1735                                    if (className.equals(StringPool.BLANK)) {
1736                                            query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
1737                                    }
1738                                    else {
1739                                            query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
1740                                    }
1741                            }
1742    
1743                            if (key == null) {
1744                                    query.append(_FINDER_COLUMN_C_K_KEY_1);
1745                            }
1746                            else {
1747                                    if (key.equals(StringPool.BLANK)) {
1748                                            query.append(_FINDER_COLUMN_C_K_KEY_3);
1749                                    }
1750                                    else {
1751                                            query.append(_FINDER_COLUMN_C_K_KEY_2);
1752                                    }
1753                            }
1754    
1755                            String sql = query.toString();
1756    
1757                            Session session = null;
1758    
1759                            try {
1760                                    session = openSession();
1761    
1762                                    Query q = session.createQuery(sql);
1763    
1764                                    QueryPos qPos = QueryPos.getInstance(q);
1765    
1766                                    if (className != null) {
1767                                            qPos.add(className);
1768                                    }
1769    
1770                                    if (key != null) {
1771                                            qPos.add(key);
1772                                    }
1773    
1774                                    count = (Long)q.uniqueResult();
1775                            }
1776                            catch (Exception e) {
1777                                    throw processException(e);
1778                            }
1779                            finally {
1780                                    if (count == null) {
1781                                            count = Long.valueOf(0);
1782                                    }
1783    
1784                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
1785                                            count);
1786    
1787                                    closeSession(session);
1788                            }
1789                    }
1790    
1791                    return count.intValue();
1792            }
1793    
1794            /**
1795             * Returns the number of locks.
1796             *
1797             * @return the number of locks
1798             * @throws SystemException if a system exception occurred
1799             */
1800            public int countAll() throws SystemException {
1801                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1802                                    FINDER_ARGS_EMPTY, this);
1803    
1804                    if (count == null) {
1805                            Session session = null;
1806    
1807                            try {
1808                                    session = openSession();
1809    
1810                                    Query q = session.createQuery(_SQL_COUNT_LOCK);
1811    
1812                                    count = (Long)q.uniqueResult();
1813                            }
1814                            catch (Exception e) {
1815                                    throw processException(e);
1816                            }
1817                            finally {
1818                                    if (count == null) {
1819                                            count = Long.valueOf(0);
1820                                    }
1821    
1822                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1823                                            FINDER_ARGS_EMPTY, count);
1824    
1825                                    closeSession(session);
1826                            }
1827                    }
1828    
1829                    return count.intValue();
1830            }
1831    
1832            /**
1833             * Initializes the lock persistence.
1834             */
1835            public void afterPropertiesSet() {
1836                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1837                                            com.liferay.portal.util.PropsUtil.get(
1838                                                    "value.object.listener.com.liferay.portal.model.Lock")));
1839    
1840                    if (listenerClassNames.length > 0) {
1841                            try {
1842                                    List<ModelListener<Lock>> listenersList = new ArrayList<ModelListener<Lock>>();
1843    
1844                                    for (String listenerClassName : listenerClassNames) {
1845                                            listenersList.add((ModelListener<Lock>)InstanceFactory.newInstance(
1846                                                            listenerClassName));
1847                                    }
1848    
1849                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1850                            }
1851                            catch (Exception e) {
1852                                    _log.error(e);
1853                            }
1854                    }
1855            }
1856    
1857            public void destroy() {
1858                    EntityCacheUtil.removeCache(LockImpl.class.getName());
1859                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1860                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1861            }
1862    
1863            @BeanReference(type = AccountPersistence.class)
1864            protected AccountPersistence accountPersistence;
1865            @BeanReference(type = AddressPersistence.class)
1866            protected AddressPersistence addressPersistence;
1867            @BeanReference(type = BrowserTrackerPersistence.class)
1868            protected BrowserTrackerPersistence browserTrackerPersistence;
1869            @BeanReference(type = ClassNamePersistence.class)
1870            protected ClassNamePersistence classNamePersistence;
1871            @BeanReference(type = ClusterGroupPersistence.class)
1872            protected ClusterGroupPersistence clusterGroupPersistence;
1873            @BeanReference(type = CompanyPersistence.class)
1874            protected CompanyPersistence companyPersistence;
1875            @BeanReference(type = ContactPersistence.class)
1876            protected ContactPersistence contactPersistence;
1877            @BeanReference(type = CountryPersistence.class)
1878            protected CountryPersistence countryPersistence;
1879            @BeanReference(type = EmailAddressPersistence.class)
1880            protected EmailAddressPersistence emailAddressPersistence;
1881            @BeanReference(type = GroupPersistence.class)
1882            protected GroupPersistence groupPersistence;
1883            @BeanReference(type = ImagePersistence.class)
1884            protected ImagePersistence imagePersistence;
1885            @BeanReference(type = LayoutPersistence.class)
1886            protected LayoutPersistence layoutPersistence;
1887            @BeanReference(type = LayoutBranchPersistence.class)
1888            protected LayoutBranchPersistence layoutBranchPersistence;
1889            @BeanReference(type = LayoutPrototypePersistence.class)
1890            protected LayoutPrototypePersistence layoutPrototypePersistence;
1891            @BeanReference(type = LayoutRevisionPersistence.class)
1892            protected LayoutRevisionPersistence layoutRevisionPersistence;
1893            @BeanReference(type = LayoutSetPersistence.class)
1894            protected LayoutSetPersistence layoutSetPersistence;
1895            @BeanReference(type = LayoutSetBranchPersistence.class)
1896            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1897            @BeanReference(type = LayoutSetPrototypePersistence.class)
1898            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1899            @BeanReference(type = ListTypePersistence.class)
1900            protected ListTypePersistence listTypePersistence;
1901            @BeanReference(type = LockPersistence.class)
1902            protected LockPersistence lockPersistence;
1903            @BeanReference(type = MembershipRequestPersistence.class)
1904            protected MembershipRequestPersistence membershipRequestPersistence;
1905            @BeanReference(type = OrganizationPersistence.class)
1906            protected OrganizationPersistence organizationPersistence;
1907            @BeanReference(type = OrgGroupPermissionPersistence.class)
1908            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1909            @BeanReference(type = OrgGroupRolePersistence.class)
1910            protected OrgGroupRolePersistence orgGroupRolePersistence;
1911            @BeanReference(type = OrgLaborPersistence.class)
1912            protected OrgLaborPersistence orgLaborPersistence;
1913            @BeanReference(type = PasswordPolicyPersistence.class)
1914            protected PasswordPolicyPersistence passwordPolicyPersistence;
1915            @BeanReference(type = PasswordPolicyRelPersistence.class)
1916            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1917            @BeanReference(type = PasswordTrackerPersistence.class)
1918            protected PasswordTrackerPersistence passwordTrackerPersistence;
1919            @BeanReference(type = PermissionPersistence.class)
1920            protected PermissionPersistence permissionPersistence;
1921            @BeanReference(type = PhonePersistence.class)
1922            protected PhonePersistence phonePersistence;
1923            @BeanReference(type = PluginSettingPersistence.class)
1924            protected PluginSettingPersistence pluginSettingPersistence;
1925            @BeanReference(type = PortalPreferencesPersistence.class)
1926            protected PortalPreferencesPersistence portalPreferencesPersistence;
1927            @BeanReference(type = PortletPersistence.class)
1928            protected PortletPersistence portletPersistence;
1929            @BeanReference(type = PortletItemPersistence.class)
1930            protected PortletItemPersistence portletItemPersistence;
1931            @BeanReference(type = PortletPreferencesPersistence.class)
1932            protected PortletPreferencesPersistence portletPreferencesPersistence;
1933            @BeanReference(type = RegionPersistence.class)
1934            protected RegionPersistence regionPersistence;
1935            @BeanReference(type = ReleasePersistence.class)
1936            protected ReleasePersistence releasePersistence;
1937            @BeanReference(type = RepositoryPersistence.class)
1938            protected RepositoryPersistence repositoryPersistence;
1939            @BeanReference(type = RepositoryEntryPersistence.class)
1940            protected RepositoryEntryPersistence repositoryEntryPersistence;
1941            @BeanReference(type = ResourcePersistence.class)
1942            protected ResourcePersistence resourcePersistence;
1943            @BeanReference(type = ResourceActionPersistence.class)
1944            protected ResourceActionPersistence resourceActionPersistence;
1945            @BeanReference(type = ResourceBlockPersistence.class)
1946            protected ResourceBlockPersistence resourceBlockPersistence;
1947            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1948            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1949            @BeanReference(type = ResourceCodePersistence.class)
1950            protected ResourceCodePersistence resourceCodePersistence;
1951            @BeanReference(type = ResourcePermissionPersistence.class)
1952            protected ResourcePermissionPersistence resourcePermissionPersistence;
1953            @BeanReference(type = ResourceTypePermissionPersistence.class)
1954            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1955            @BeanReference(type = RolePersistence.class)
1956            protected RolePersistence rolePersistence;
1957            @BeanReference(type = ServiceComponentPersistence.class)
1958            protected ServiceComponentPersistence serviceComponentPersistence;
1959            @BeanReference(type = ShardPersistence.class)
1960            protected ShardPersistence shardPersistence;
1961            @BeanReference(type = SubscriptionPersistence.class)
1962            protected SubscriptionPersistence subscriptionPersistence;
1963            @BeanReference(type = TeamPersistence.class)
1964            protected TeamPersistence teamPersistence;
1965            @BeanReference(type = TicketPersistence.class)
1966            protected TicketPersistence ticketPersistence;
1967            @BeanReference(type = UserPersistence.class)
1968            protected UserPersistence userPersistence;
1969            @BeanReference(type = UserGroupPersistence.class)
1970            protected UserGroupPersistence userGroupPersistence;
1971            @BeanReference(type = UserGroupGroupRolePersistence.class)
1972            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1973            @BeanReference(type = UserGroupRolePersistence.class)
1974            protected UserGroupRolePersistence userGroupRolePersistence;
1975            @BeanReference(type = UserIdMapperPersistence.class)
1976            protected UserIdMapperPersistence userIdMapperPersistence;
1977            @BeanReference(type = UserNotificationEventPersistence.class)
1978            protected UserNotificationEventPersistence userNotificationEventPersistence;
1979            @BeanReference(type = UserTrackerPersistence.class)
1980            protected UserTrackerPersistence userTrackerPersistence;
1981            @BeanReference(type = UserTrackerPathPersistence.class)
1982            protected UserTrackerPathPersistence userTrackerPathPersistence;
1983            @BeanReference(type = VirtualHostPersistence.class)
1984            protected VirtualHostPersistence virtualHostPersistence;
1985            @BeanReference(type = WebDAVPropsPersistence.class)
1986            protected WebDAVPropsPersistence webDAVPropsPersistence;
1987            @BeanReference(type = WebsitePersistence.class)
1988            protected WebsitePersistence websitePersistence;
1989            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1990            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1991            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1992            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1993            private static final String _SQL_SELECT_LOCK = "SELECT lock FROM Lock lock";
1994            private static final String _SQL_SELECT_LOCK_WHERE = "SELECT lock FROM Lock lock WHERE ";
1995            private static final String _SQL_COUNT_LOCK = "SELECT COUNT(lock) FROM Lock lock";
1996            private static final String _SQL_COUNT_LOCK_WHERE = "SELECT COUNT(lock) FROM Lock lock WHERE ";
1997            private static final String _FINDER_COLUMN_UUID_UUID_1 = "lock.uuid IS NULL";
1998            private static final String _FINDER_COLUMN_UUID_UUID_2 = "lock.uuid = ?";
1999            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(lock.uuid IS NULL OR lock.uuid = ?)";
2000            private static final String _FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1 =
2001                    "lock.expirationDate < NULL";
2002            private static final String _FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2 =
2003                    "lock.expirationDate < ?";
2004            private static final String _FINDER_COLUMN_C_K_CLASSNAME_1 = "lock.className IS NULL AND ";
2005            private static final String _FINDER_COLUMN_C_K_CLASSNAME_2 = "lock.className = ? AND ";
2006            private static final String _FINDER_COLUMN_C_K_CLASSNAME_3 = "(lock.className IS NULL OR lock.className = ?) AND ";
2007            private static final String _FINDER_COLUMN_C_K_KEY_1 = "lock.key IS NULL";
2008            private static final String _FINDER_COLUMN_C_K_KEY_2 = "lock.key = ?";
2009            private static final String _FINDER_COLUMN_C_K_KEY_3 = "(lock.key IS NULL OR lock.key = ?)";
2010            private static final String _ORDER_BY_ENTITY_ALIAS = "lock.";
2011            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Lock exists with the primary key ";
2012            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Lock exists with the key {";
2013            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2014            private static Log _log = LogFactoryUtil.getLog(LockPersistenceImpl.class);
2015            private static Lock _nullLock = new LockImpl() {
2016                            @Override
2017                            public Object clone() {
2018                                    return this;
2019                            }
2020    
2021                            @Override
2022                            public CacheModel<Lock> toCacheModel() {
2023                                    return _nullLockCacheModel;
2024                            }
2025                    };
2026    
2027            private static CacheModel<Lock> _nullLockCacheModel = new CacheModel<Lock>() {
2028                            public Lock toEntityModel() {
2029                                    return _nullLock;
2030                            }
2031                    };
2032    }