001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLockException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.CalendarUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.SetUtil;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.UnmodifiableList;
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 import java.util.Set;
054
055
067 public class LockPersistenceImpl extends BasePersistenceImpl<Lock>
068 implements LockPersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = LockImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
080 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
081 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
083 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
086 LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
089 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
090 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
091 new String[] {
092 String.class.getName(),
093
094 Integer.class.getName(), Integer.class.getName(),
095 OrderByComparator.class.getName()
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
098 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
100 new String[] { String.class.getName() },
101 LockModelImpl.UUID_COLUMN_BITMASK);
102 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
103 LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
105 new String[] { String.class.getName() });
106
107
114 @Override
115 public List<Lock> findByUuid(String uuid) throws SystemException {
116 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
117 }
118
119
132 @Override
133 public List<Lock> findByUuid(String uuid, int start, int end)
134 throws SystemException {
135 return findByUuid(uuid, start, end, null);
136 }
137
138
152 @Override
153 public List<Lock> findByUuid(String uuid, int start, int end,
154 OrderByComparator orderByComparator) throws SystemException {
155 boolean pagination = true;
156 FinderPath finderPath = null;
157 Object[] finderArgs = null;
158
159 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
160 (orderByComparator == null)) {
161 pagination = false;
162 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
163 finderArgs = new Object[] { uuid };
164 }
165 else {
166 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
167 finderArgs = new Object[] { uuid, start, end, orderByComparator };
168 }
169
170 List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
171 finderArgs, this);
172
173 if ((list != null) && !list.isEmpty()) {
174 for (Lock lock : list) {
175 if (!Validator.equals(uuid, lock.getUuid())) {
176 list = null;
177
178 break;
179 }
180 }
181 }
182
183 if (list == null) {
184 StringBundler query = null;
185
186 if (orderByComparator != null) {
187 query = new StringBundler(3 +
188 (orderByComparator.getOrderByFields().length * 3));
189 }
190 else {
191 query = new StringBundler(3);
192 }
193
194 query.append(_SQL_SELECT_LOCK_WHERE);
195
196 boolean bindUuid = false;
197
198 if (uuid == null) {
199 query.append(_FINDER_COLUMN_UUID_UUID_1);
200 }
201 else if (uuid.equals(StringPool.BLANK)) {
202 query.append(_FINDER_COLUMN_UUID_UUID_3);
203 }
204 else {
205 bindUuid = true;
206
207 query.append(_FINDER_COLUMN_UUID_UUID_2);
208 }
209
210 if (orderByComparator != null) {
211 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
212 orderByComparator);
213 }
214 else
215 if (pagination) {
216 query.append(LockModelImpl.ORDER_BY_JPQL);
217 }
218
219 String sql = query.toString();
220
221 Session session = null;
222
223 try {
224 session = openSession();
225
226 Query q = session.createQuery(sql);
227
228 QueryPos qPos = QueryPos.getInstance(q);
229
230 if (bindUuid) {
231 qPos.add(uuid);
232 }
233
234 if (!pagination) {
235 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
236 end, false);
237
238 Collections.sort(list);
239
240 list = new UnmodifiableList<Lock>(list);
241 }
242 else {
243 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
244 end);
245 }
246
247 cacheResult(list);
248
249 FinderCacheUtil.putResult(finderPath, finderArgs, list);
250 }
251 catch (Exception e) {
252 FinderCacheUtil.removeResult(finderPath, finderArgs);
253
254 throw processException(e);
255 }
256 finally {
257 closeSession(session);
258 }
259 }
260
261 return list;
262 }
263
264
273 @Override
274 public Lock findByUuid_First(String uuid,
275 OrderByComparator orderByComparator)
276 throws NoSuchLockException, SystemException {
277 Lock lock = fetchByUuid_First(uuid, orderByComparator);
278
279 if (lock != null) {
280 return lock;
281 }
282
283 StringBundler msg = new StringBundler(4);
284
285 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
286
287 msg.append("uuid=");
288 msg.append(uuid);
289
290 msg.append(StringPool.CLOSE_CURLY_BRACE);
291
292 throw new NoSuchLockException(msg.toString());
293 }
294
295
303 @Override
304 public Lock fetchByUuid_First(String uuid,
305 OrderByComparator orderByComparator) throws SystemException {
306 List<Lock> list = findByUuid(uuid, 0, 1, orderByComparator);
307
308 if (!list.isEmpty()) {
309 return list.get(0);
310 }
311
312 return null;
313 }
314
315
324 @Override
325 public Lock findByUuid_Last(String uuid, OrderByComparator orderByComparator)
326 throws NoSuchLockException, SystemException {
327 Lock lock = fetchByUuid_Last(uuid, orderByComparator);
328
329 if (lock != null) {
330 return lock;
331 }
332
333 StringBundler msg = new StringBundler(4);
334
335 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336
337 msg.append("uuid=");
338 msg.append(uuid);
339
340 msg.append(StringPool.CLOSE_CURLY_BRACE);
341
342 throw new NoSuchLockException(msg.toString());
343 }
344
345
353 @Override
354 public Lock fetchByUuid_Last(String uuid,
355 OrderByComparator orderByComparator) throws SystemException {
356 int count = countByUuid(uuid);
357
358 if (count == 0) {
359 return null;
360 }
361
362 List<Lock> list = findByUuid(uuid, count - 1, count, orderByComparator);
363
364 if (!list.isEmpty()) {
365 return list.get(0);
366 }
367
368 return null;
369 }
370
371
381 @Override
382 public Lock[] findByUuid_PrevAndNext(long lockId, String uuid,
383 OrderByComparator orderByComparator)
384 throws NoSuchLockException, SystemException {
385 Lock lock = findByPrimaryKey(lockId);
386
387 Session session = null;
388
389 try {
390 session = openSession();
391
392 Lock[] array = new LockImpl[3];
393
394 array[0] = getByUuid_PrevAndNext(session, lock, uuid,
395 orderByComparator, true);
396
397 array[1] = lock;
398
399 array[2] = getByUuid_PrevAndNext(session, lock, uuid,
400 orderByComparator, false);
401
402 return array;
403 }
404 catch (Exception e) {
405 throw processException(e);
406 }
407 finally {
408 closeSession(session);
409 }
410 }
411
412 protected Lock getByUuid_PrevAndNext(Session session, Lock lock,
413 String uuid, OrderByComparator orderByComparator, boolean previous) {
414 StringBundler query = null;
415
416 if (orderByComparator != null) {
417 query = new StringBundler(6 +
418 (orderByComparator.getOrderByFields().length * 6));
419 }
420 else {
421 query = new StringBundler(3);
422 }
423
424 query.append(_SQL_SELECT_LOCK_WHERE);
425
426 boolean bindUuid = false;
427
428 if (uuid == null) {
429 query.append(_FINDER_COLUMN_UUID_UUID_1);
430 }
431 else if (uuid.equals(StringPool.BLANK)) {
432 query.append(_FINDER_COLUMN_UUID_UUID_3);
433 }
434 else {
435 bindUuid = true;
436
437 query.append(_FINDER_COLUMN_UUID_UUID_2);
438 }
439
440 if (orderByComparator != null) {
441 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
442
443 if (orderByConditionFields.length > 0) {
444 query.append(WHERE_AND);
445 }
446
447 for (int i = 0; i < orderByConditionFields.length; i++) {
448 query.append(_ORDER_BY_ENTITY_ALIAS);
449 query.append(orderByConditionFields[i]);
450
451 if ((i + 1) < orderByConditionFields.length) {
452 if (orderByComparator.isAscending() ^ previous) {
453 query.append(WHERE_GREATER_THAN_HAS_NEXT);
454 }
455 else {
456 query.append(WHERE_LESSER_THAN_HAS_NEXT);
457 }
458 }
459 else {
460 if (orderByComparator.isAscending() ^ previous) {
461 query.append(WHERE_GREATER_THAN);
462 }
463 else {
464 query.append(WHERE_LESSER_THAN);
465 }
466 }
467 }
468
469 query.append(ORDER_BY_CLAUSE);
470
471 String[] orderByFields = orderByComparator.getOrderByFields();
472
473 for (int i = 0; i < orderByFields.length; i++) {
474 query.append(_ORDER_BY_ENTITY_ALIAS);
475 query.append(orderByFields[i]);
476
477 if ((i + 1) < orderByFields.length) {
478 if (orderByComparator.isAscending() ^ previous) {
479 query.append(ORDER_BY_ASC_HAS_NEXT);
480 }
481 else {
482 query.append(ORDER_BY_DESC_HAS_NEXT);
483 }
484 }
485 else {
486 if (orderByComparator.isAscending() ^ previous) {
487 query.append(ORDER_BY_ASC);
488 }
489 else {
490 query.append(ORDER_BY_DESC);
491 }
492 }
493 }
494 }
495 else {
496 query.append(LockModelImpl.ORDER_BY_JPQL);
497 }
498
499 String sql = query.toString();
500
501 Query q = session.createQuery(sql);
502
503 q.setFirstResult(0);
504 q.setMaxResults(2);
505
506 QueryPos qPos = QueryPos.getInstance(q);
507
508 if (bindUuid) {
509 qPos.add(uuid);
510 }
511
512 if (orderByComparator != null) {
513 Object[] values = orderByComparator.getOrderByConditionValues(lock);
514
515 for (Object value : values) {
516 qPos.add(value);
517 }
518 }
519
520 List<Lock> list = q.list();
521
522 if (list.size() == 2) {
523 return list.get(1);
524 }
525 else {
526 return null;
527 }
528 }
529
530
536 @Override
537 public void removeByUuid(String uuid) throws SystemException {
538 for (Lock lock : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
539 null)) {
540 remove(lock);
541 }
542 }
543
544
551 @Override
552 public int countByUuid(String uuid) throws SystemException {
553 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
554
555 Object[] finderArgs = new Object[] { uuid };
556
557 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
558 this);
559
560 if (count == null) {
561 StringBundler query = new StringBundler(2);
562
563 query.append(_SQL_COUNT_LOCK_WHERE);
564
565 boolean bindUuid = false;
566
567 if (uuid == null) {
568 query.append(_FINDER_COLUMN_UUID_UUID_1);
569 }
570 else if (uuid.equals(StringPool.BLANK)) {
571 query.append(_FINDER_COLUMN_UUID_UUID_3);
572 }
573 else {
574 bindUuid = true;
575
576 query.append(_FINDER_COLUMN_UUID_UUID_2);
577 }
578
579 String sql = query.toString();
580
581 Session session = null;
582
583 try {
584 session = openSession();
585
586 Query q = session.createQuery(sql);
587
588 QueryPos qPos = QueryPos.getInstance(q);
589
590 if (bindUuid) {
591 qPos.add(uuid);
592 }
593
594 count = (Long)q.uniqueResult();
595
596 FinderCacheUtil.putResult(finderPath, finderArgs, count);
597 }
598 catch (Exception e) {
599 FinderCacheUtil.removeResult(finderPath, finderArgs);
600
601 throw processException(e);
602 }
603 finally {
604 closeSession(session);
605 }
606 }
607
608 return count.intValue();
609 }
610
611 private static final String _FINDER_COLUMN_UUID_UUID_1 = "lock.uuid IS NULL";
612 private static final String _FINDER_COLUMN_UUID_UUID_2 = "lock.uuid = ?";
613 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(lock.uuid IS NULL OR lock.uuid = '')";
614 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
615 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
616 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
617 new String[] {
618 String.class.getName(), Long.class.getName(),
619
620 Integer.class.getName(), Integer.class.getName(),
621 OrderByComparator.class.getName()
622 });
623 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
624 new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
625 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
626 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
627 new String[] { String.class.getName(), Long.class.getName() },
628 LockModelImpl.UUID_COLUMN_BITMASK |
629 LockModelImpl.COMPANYID_COLUMN_BITMASK);
630 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
631 LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
632 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
633 new String[] { String.class.getName(), Long.class.getName() });
634
635
643 @Override
644 public List<Lock> findByUuid_C(String uuid, long companyId)
645 throws SystemException {
646 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
647 QueryUtil.ALL_POS, null);
648 }
649
650
664 @Override
665 public List<Lock> findByUuid_C(String uuid, long companyId, int start,
666 int end) throws SystemException {
667 return findByUuid_C(uuid, companyId, start, end, null);
668 }
669
670
685 @Override
686 public List<Lock> findByUuid_C(String uuid, long companyId, int start,
687 int end, OrderByComparator orderByComparator) throws SystemException {
688 boolean pagination = true;
689 FinderPath finderPath = null;
690 Object[] finderArgs = null;
691
692 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
693 (orderByComparator == null)) {
694 pagination = false;
695 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
696 finderArgs = new Object[] { uuid, companyId };
697 }
698 else {
699 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
700 finderArgs = new Object[] {
701 uuid, companyId,
702
703 start, end, orderByComparator
704 };
705 }
706
707 List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
708 finderArgs, this);
709
710 if ((list != null) && !list.isEmpty()) {
711 for (Lock lock : list) {
712 if (!Validator.equals(uuid, lock.getUuid()) ||
713 (companyId != lock.getCompanyId())) {
714 list = null;
715
716 break;
717 }
718 }
719 }
720
721 if (list == null) {
722 StringBundler query = null;
723
724 if (orderByComparator != null) {
725 query = new StringBundler(4 +
726 (orderByComparator.getOrderByFields().length * 3));
727 }
728 else {
729 query = new StringBundler(4);
730 }
731
732 query.append(_SQL_SELECT_LOCK_WHERE);
733
734 boolean bindUuid = false;
735
736 if (uuid == null) {
737 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
738 }
739 else if (uuid.equals(StringPool.BLANK)) {
740 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
741 }
742 else {
743 bindUuid = true;
744
745 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
746 }
747
748 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
749
750 if (orderByComparator != null) {
751 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
752 orderByComparator);
753 }
754 else
755 if (pagination) {
756 query.append(LockModelImpl.ORDER_BY_JPQL);
757 }
758
759 String sql = query.toString();
760
761 Session session = null;
762
763 try {
764 session = openSession();
765
766 Query q = session.createQuery(sql);
767
768 QueryPos qPos = QueryPos.getInstance(q);
769
770 if (bindUuid) {
771 qPos.add(uuid);
772 }
773
774 qPos.add(companyId);
775
776 if (!pagination) {
777 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
778 end, false);
779
780 Collections.sort(list);
781
782 list = new UnmodifiableList<Lock>(list);
783 }
784 else {
785 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
786 end);
787 }
788
789 cacheResult(list);
790
791 FinderCacheUtil.putResult(finderPath, finderArgs, list);
792 }
793 catch (Exception e) {
794 FinderCacheUtil.removeResult(finderPath, finderArgs);
795
796 throw processException(e);
797 }
798 finally {
799 closeSession(session);
800 }
801 }
802
803 return list;
804 }
805
806
816 @Override
817 public Lock findByUuid_C_First(String uuid, long companyId,
818 OrderByComparator orderByComparator)
819 throws NoSuchLockException, SystemException {
820 Lock lock = fetchByUuid_C_First(uuid, companyId, orderByComparator);
821
822 if (lock != null) {
823 return lock;
824 }
825
826 StringBundler msg = new StringBundler(6);
827
828 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
829
830 msg.append("uuid=");
831 msg.append(uuid);
832
833 msg.append(", companyId=");
834 msg.append(companyId);
835
836 msg.append(StringPool.CLOSE_CURLY_BRACE);
837
838 throw new NoSuchLockException(msg.toString());
839 }
840
841
850 @Override
851 public Lock fetchByUuid_C_First(String uuid, long companyId,
852 OrderByComparator orderByComparator) throws SystemException {
853 List<Lock> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator);
854
855 if (!list.isEmpty()) {
856 return list.get(0);
857 }
858
859 return null;
860 }
861
862
872 @Override
873 public Lock findByUuid_C_Last(String uuid, long companyId,
874 OrderByComparator orderByComparator)
875 throws NoSuchLockException, SystemException {
876 Lock lock = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
877
878 if (lock != null) {
879 return lock;
880 }
881
882 StringBundler msg = new StringBundler(6);
883
884 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
885
886 msg.append("uuid=");
887 msg.append(uuid);
888
889 msg.append(", companyId=");
890 msg.append(companyId);
891
892 msg.append(StringPool.CLOSE_CURLY_BRACE);
893
894 throw new NoSuchLockException(msg.toString());
895 }
896
897
906 @Override
907 public Lock fetchByUuid_C_Last(String uuid, long companyId,
908 OrderByComparator orderByComparator) throws SystemException {
909 int count = countByUuid_C(uuid, companyId);
910
911 if (count == 0) {
912 return null;
913 }
914
915 List<Lock> list = findByUuid_C(uuid, companyId, count - 1, count,
916 orderByComparator);
917
918 if (!list.isEmpty()) {
919 return list.get(0);
920 }
921
922 return null;
923 }
924
925
936 @Override
937 public Lock[] findByUuid_C_PrevAndNext(long lockId, String uuid,
938 long companyId, OrderByComparator orderByComparator)
939 throws NoSuchLockException, SystemException {
940 Lock lock = findByPrimaryKey(lockId);
941
942 Session session = null;
943
944 try {
945 session = openSession();
946
947 Lock[] array = new LockImpl[3];
948
949 array[0] = getByUuid_C_PrevAndNext(session, lock, uuid, companyId,
950 orderByComparator, true);
951
952 array[1] = lock;
953
954 array[2] = getByUuid_C_PrevAndNext(session, lock, uuid, companyId,
955 orderByComparator, false);
956
957 return array;
958 }
959 catch (Exception e) {
960 throw processException(e);
961 }
962 finally {
963 closeSession(session);
964 }
965 }
966
967 protected Lock getByUuid_C_PrevAndNext(Session session, Lock lock,
968 String uuid, long companyId, OrderByComparator orderByComparator,
969 boolean previous) {
970 StringBundler query = null;
971
972 if (orderByComparator != null) {
973 query = new StringBundler(6 +
974 (orderByComparator.getOrderByFields().length * 6));
975 }
976 else {
977 query = new StringBundler(3);
978 }
979
980 query.append(_SQL_SELECT_LOCK_WHERE);
981
982 boolean bindUuid = false;
983
984 if (uuid == null) {
985 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
986 }
987 else if (uuid.equals(StringPool.BLANK)) {
988 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
989 }
990 else {
991 bindUuid = true;
992
993 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
994 }
995
996 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
997
998 if (orderByComparator != null) {
999 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1000
1001 if (orderByConditionFields.length > 0) {
1002 query.append(WHERE_AND);
1003 }
1004
1005 for (int i = 0; i < orderByConditionFields.length; i++) {
1006 query.append(_ORDER_BY_ENTITY_ALIAS);
1007 query.append(orderByConditionFields[i]);
1008
1009 if ((i + 1) < orderByConditionFields.length) {
1010 if (orderByComparator.isAscending() ^ previous) {
1011 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1012 }
1013 else {
1014 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1015 }
1016 }
1017 else {
1018 if (orderByComparator.isAscending() ^ previous) {
1019 query.append(WHERE_GREATER_THAN);
1020 }
1021 else {
1022 query.append(WHERE_LESSER_THAN);
1023 }
1024 }
1025 }
1026
1027 query.append(ORDER_BY_CLAUSE);
1028
1029 String[] orderByFields = orderByComparator.getOrderByFields();
1030
1031 for (int i = 0; i < orderByFields.length; i++) {
1032 query.append(_ORDER_BY_ENTITY_ALIAS);
1033 query.append(orderByFields[i]);
1034
1035 if ((i + 1) < orderByFields.length) {
1036 if (orderByComparator.isAscending() ^ previous) {
1037 query.append(ORDER_BY_ASC_HAS_NEXT);
1038 }
1039 else {
1040 query.append(ORDER_BY_DESC_HAS_NEXT);
1041 }
1042 }
1043 else {
1044 if (orderByComparator.isAscending() ^ previous) {
1045 query.append(ORDER_BY_ASC);
1046 }
1047 else {
1048 query.append(ORDER_BY_DESC);
1049 }
1050 }
1051 }
1052 }
1053 else {
1054 query.append(LockModelImpl.ORDER_BY_JPQL);
1055 }
1056
1057 String sql = query.toString();
1058
1059 Query q = session.createQuery(sql);
1060
1061 q.setFirstResult(0);
1062 q.setMaxResults(2);
1063
1064 QueryPos qPos = QueryPos.getInstance(q);
1065
1066 if (bindUuid) {
1067 qPos.add(uuid);
1068 }
1069
1070 qPos.add(companyId);
1071
1072 if (orderByComparator != null) {
1073 Object[] values = orderByComparator.getOrderByConditionValues(lock);
1074
1075 for (Object value : values) {
1076 qPos.add(value);
1077 }
1078 }
1079
1080 List<Lock> list = q.list();
1081
1082 if (list.size() == 2) {
1083 return list.get(1);
1084 }
1085 else {
1086 return null;
1087 }
1088 }
1089
1090
1097 @Override
1098 public void removeByUuid_C(String uuid, long companyId)
1099 throws SystemException {
1100 for (Lock lock : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1101 QueryUtil.ALL_POS, null)) {
1102 remove(lock);
1103 }
1104 }
1105
1106
1114 @Override
1115 public int countByUuid_C(String uuid, long companyId)
1116 throws SystemException {
1117 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1118
1119 Object[] finderArgs = new Object[] { uuid, companyId };
1120
1121 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1122 this);
1123
1124 if (count == null) {
1125 StringBundler query = new StringBundler(3);
1126
1127 query.append(_SQL_COUNT_LOCK_WHERE);
1128
1129 boolean bindUuid = false;
1130
1131 if (uuid == null) {
1132 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1133 }
1134 else if (uuid.equals(StringPool.BLANK)) {
1135 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1136 }
1137 else {
1138 bindUuid = true;
1139
1140 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1141 }
1142
1143 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1144
1145 String sql = query.toString();
1146
1147 Session session = null;
1148
1149 try {
1150 session = openSession();
1151
1152 Query q = session.createQuery(sql);
1153
1154 QueryPos qPos = QueryPos.getInstance(q);
1155
1156 if (bindUuid) {
1157 qPos.add(uuid);
1158 }
1159
1160 qPos.add(companyId);
1161
1162 count = (Long)q.uniqueResult();
1163
1164 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1165 }
1166 catch (Exception e) {
1167 FinderCacheUtil.removeResult(finderPath, finderArgs);
1168
1169 throw processException(e);
1170 }
1171 finally {
1172 closeSession(session);
1173 }
1174 }
1175
1176 return count.intValue();
1177 }
1178
1179 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "lock.uuid IS NULL AND ";
1180 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "lock.uuid = ? AND ";
1181 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(lock.uuid IS NULL OR lock.uuid = '') AND ";
1182 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "lock.companyId = ?";
1183 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTEXPIRATIONDATE =
1184 new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
1185 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
1186 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtExpirationDate",
1187 new String[] {
1188 Date.class.getName(),
1189
1190 Integer.class.getName(), Integer.class.getName(),
1191 OrderByComparator.class.getName()
1192 });
1193 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTEXPIRATIONDATE =
1194 new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
1195 LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
1196 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtExpirationDate",
1197 new String[] { Date.class.getName() });
1198
1199
1206 @Override
1207 public List<Lock> findByLtExpirationDate(Date expirationDate)
1208 throws SystemException {
1209 return findByLtExpirationDate(expirationDate, QueryUtil.ALL_POS,
1210 QueryUtil.ALL_POS, null);
1211 }
1212
1213
1226 @Override
1227 public List<Lock> findByLtExpirationDate(Date expirationDate, int start,
1228 int end) throws SystemException {
1229 return findByLtExpirationDate(expirationDate, start, end, null);
1230 }
1231
1232
1246 @Override
1247 public List<Lock> findByLtExpirationDate(Date expirationDate, int start,
1248 int end, OrderByComparator orderByComparator) throws SystemException {
1249 boolean pagination = true;
1250 FinderPath finderPath = null;
1251 Object[] finderArgs = null;
1252
1253 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTEXPIRATIONDATE;
1254 finderArgs = new Object[] { expirationDate, start, end, orderByComparator };
1255
1256 List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
1257 finderArgs, this);
1258
1259 if ((list != null) && !list.isEmpty()) {
1260 for (Lock lock : list) {
1261 if ((expirationDate.getTime() <= lock.getExpirationDate()
1262 .getTime())) {
1263 list = null;
1264
1265 break;
1266 }
1267 }
1268 }
1269
1270 if (list == null) {
1271 StringBundler query = null;
1272
1273 if (orderByComparator != null) {
1274 query = new StringBundler(3 +
1275 (orderByComparator.getOrderByFields().length * 3));
1276 }
1277 else {
1278 query = new StringBundler(3);
1279 }
1280
1281 query.append(_SQL_SELECT_LOCK_WHERE);
1282
1283 boolean bindExpirationDate = false;
1284
1285 if (expirationDate == null) {
1286 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1287 }
1288 else {
1289 bindExpirationDate = true;
1290
1291 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1292 }
1293
1294 if (orderByComparator != null) {
1295 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1296 orderByComparator);
1297 }
1298 else
1299 if (pagination) {
1300 query.append(LockModelImpl.ORDER_BY_JPQL);
1301 }
1302
1303 String sql = query.toString();
1304
1305 Session session = null;
1306
1307 try {
1308 session = openSession();
1309
1310 Query q = session.createQuery(sql);
1311
1312 QueryPos qPos = QueryPos.getInstance(q);
1313
1314 if (bindExpirationDate) {
1315 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1316 }
1317
1318 if (!pagination) {
1319 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1320 end, false);
1321
1322 Collections.sort(list);
1323
1324 list = new UnmodifiableList<Lock>(list);
1325 }
1326 else {
1327 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1328 end);
1329 }
1330
1331 cacheResult(list);
1332
1333 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1334 }
1335 catch (Exception e) {
1336 FinderCacheUtil.removeResult(finderPath, finderArgs);
1337
1338 throw processException(e);
1339 }
1340 finally {
1341 closeSession(session);
1342 }
1343 }
1344
1345 return list;
1346 }
1347
1348
1357 @Override
1358 public Lock findByLtExpirationDate_First(Date expirationDate,
1359 OrderByComparator orderByComparator)
1360 throws NoSuchLockException, SystemException {
1361 Lock lock = fetchByLtExpirationDate_First(expirationDate,
1362 orderByComparator);
1363
1364 if (lock != null) {
1365 return lock;
1366 }
1367
1368 StringBundler msg = new StringBundler(4);
1369
1370 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1371
1372 msg.append("expirationDate=");
1373 msg.append(expirationDate);
1374
1375 msg.append(StringPool.CLOSE_CURLY_BRACE);
1376
1377 throw new NoSuchLockException(msg.toString());
1378 }
1379
1380
1388 @Override
1389 public Lock fetchByLtExpirationDate_First(Date expirationDate,
1390 OrderByComparator orderByComparator) throws SystemException {
1391 List<Lock> list = findByLtExpirationDate(expirationDate, 0, 1,
1392 orderByComparator);
1393
1394 if (!list.isEmpty()) {
1395 return list.get(0);
1396 }
1397
1398 return null;
1399 }
1400
1401
1410 @Override
1411 public Lock findByLtExpirationDate_Last(Date expirationDate,
1412 OrderByComparator orderByComparator)
1413 throws NoSuchLockException, SystemException {
1414 Lock lock = fetchByLtExpirationDate_Last(expirationDate,
1415 orderByComparator);
1416
1417 if (lock != null) {
1418 return lock;
1419 }
1420
1421 StringBundler msg = new StringBundler(4);
1422
1423 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1424
1425 msg.append("expirationDate=");
1426 msg.append(expirationDate);
1427
1428 msg.append(StringPool.CLOSE_CURLY_BRACE);
1429
1430 throw new NoSuchLockException(msg.toString());
1431 }
1432
1433
1441 @Override
1442 public Lock fetchByLtExpirationDate_Last(Date expirationDate,
1443 OrderByComparator orderByComparator) throws SystemException {
1444 int count = countByLtExpirationDate(expirationDate);
1445
1446 if (count == 0) {
1447 return null;
1448 }
1449
1450 List<Lock> list = findByLtExpirationDate(expirationDate, count - 1,
1451 count, orderByComparator);
1452
1453 if (!list.isEmpty()) {
1454 return list.get(0);
1455 }
1456
1457 return null;
1458 }
1459
1460
1470 @Override
1471 public Lock[] findByLtExpirationDate_PrevAndNext(long lockId,
1472 Date expirationDate, OrderByComparator orderByComparator)
1473 throws NoSuchLockException, SystemException {
1474 Lock lock = findByPrimaryKey(lockId);
1475
1476 Session session = null;
1477
1478 try {
1479 session = openSession();
1480
1481 Lock[] array = new LockImpl[3];
1482
1483 array[0] = getByLtExpirationDate_PrevAndNext(session, lock,
1484 expirationDate, orderByComparator, true);
1485
1486 array[1] = lock;
1487
1488 array[2] = getByLtExpirationDate_PrevAndNext(session, lock,
1489 expirationDate, orderByComparator, false);
1490
1491 return array;
1492 }
1493 catch (Exception e) {
1494 throw processException(e);
1495 }
1496 finally {
1497 closeSession(session);
1498 }
1499 }
1500
1501 protected Lock getByLtExpirationDate_PrevAndNext(Session session,
1502 Lock lock, Date expirationDate, OrderByComparator orderByComparator,
1503 boolean previous) {
1504 StringBundler query = null;
1505
1506 if (orderByComparator != null) {
1507 query = new StringBundler(6 +
1508 (orderByComparator.getOrderByFields().length * 6));
1509 }
1510 else {
1511 query = new StringBundler(3);
1512 }
1513
1514 query.append(_SQL_SELECT_LOCK_WHERE);
1515
1516 boolean bindExpirationDate = false;
1517
1518 if (expirationDate == null) {
1519 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1520 }
1521 else {
1522 bindExpirationDate = true;
1523
1524 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1525 }
1526
1527 if (orderByComparator != null) {
1528 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1529
1530 if (orderByConditionFields.length > 0) {
1531 query.append(WHERE_AND);
1532 }
1533
1534 for (int i = 0; i < orderByConditionFields.length; i++) {
1535 query.append(_ORDER_BY_ENTITY_ALIAS);
1536 query.append(orderByConditionFields[i]);
1537
1538 if ((i + 1) < orderByConditionFields.length) {
1539 if (orderByComparator.isAscending() ^ previous) {
1540 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1541 }
1542 else {
1543 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1544 }
1545 }
1546 else {
1547 if (orderByComparator.isAscending() ^ previous) {
1548 query.append(WHERE_GREATER_THAN);
1549 }
1550 else {
1551 query.append(WHERE_LESSER_THAN);
1552 }
1553 }
1554 }
1555
1556 query.append(ORDER_BY_CLAUSE);
1557
1558 String[] orderByFields = orderByComparator.getOrderByFields();
1559
1560 for (int i = 0; i < orderByFields.length; i++) {
1561 query.append(_ORDER_BY_ENTITY_ALIAS);
1562 query.append(orderByFields[i]);
1563
1564 if ((i + 1) < orderByFields.length) {
1565 if (orderByComparator.isAscending() ^ previous) {
1566 query.append(ORDER_BY_ASC_HAS_NEXT);
1567 }
1568 else {
1569 query.append(ORDER_BY_DESC_HAS_NEXT);
1570 }
1571 }
1572 else {
1573 if (orderByComparator.isAscending() ^ previous) {
1574 query.append(ORDER_BY_ASC);
1575 }
1576 else {
1577 query.append(ORDER_BY_DESC);
1578 }
1579 }
1580 }
1581 }
1582 else {
1583 query.append(LockModelImpl.ORDER_BY_JPQL);
1584 }
1585
1586 String sql = query.toString();
1587
1588 Query q = session.createQuery(sql);
1589
1590 q.setFirstResult(0);
1591 q.setMaxResults(2);
1592
1593 QueryPos qPos = QueryPos.getInstance(q);
1594
1595 if (bindExpirationDate) {
1596 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1597 }
1598
1599 if (orderByComparator != null) {
1600 Object[] values = orderByComparator.getOrderByConditionValues(lock);
1601
1602 for (Object value : values) {
1603 qPos.add(value);
1604 }
1605 }
1606
1607 List<Lock> list = q.list();
1608
1609 if (list.size() == 2) {
1610 return list.get(1);
1611 }
1612 else {
1613 return null;
1614 }
1615 }
1616
1617
1623 @Override
1624 public void removeByLtExpirationDate(Date expirationDate)
1625 throws SystemException {
1626 for (Lock lock : findByLtExpirationDate(expirationDate,
1627 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1628 remove(lock);
1629 }
1630 }
1631
1632
1639 @Override
1640 public int countByLtExpirationDate(Date expirationDate)
1641 throws SystemException {
1642 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTEXPIRATIONDATE;
1643
1644 Object[] finderArgs = new Object[] { expirationDate };
1645
1646 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1647 this);
1648
1649 if (count == null) {
1650 StringBundler query = new StringBundler(2);
1651
1652 query.append(_SQL_COUNT_LOCK_WHERE);
1653
1654 boolean bindExpirationDate = false;
1655
1656 if (expirationDate == null) {
1657 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1658 }
1659 else {
1660 bindExpirationDate = true;
1661
1662 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1663 }
1664
1665 String sql = query.toString();
1666
1667 Session session = null;
1668
1669 try {
1670 session = openSession();
1671
1672 Query q = session.createQuery(sql);
1673
1674 QueryPos qPos = QueryPos.getInstance(q);
1675
1676 if (bindExpirationDate) {
1677 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1678 }
1679
1680 count = (Long)q.uniqueResult();
1681
1682 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1683 }
1684 catch (Exception e) {
1685 FinderCacheUtil.removeResult(finderPath, finderArgs);
1686
1687 throw processException(e);
1688 }
1689 finally {
1690 closeSession(session);
1691 }
1692 }
1693
1694 return count.intValue();
1695 }
1696
1697 private static final String _FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1 =
1698 "lock.expirationDate < NULL";
1699 private static final String _FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2 =
1700 "lock.expirationDate < ?";
1701 public static final FinderPath FINDER_PATH_FETCH_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
1702 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
1703 FINDER_CLASS_NAME_ENTITY, "fetchByC_K",
1704 new String[] { String.class.getName(), String.class.getName() },
1705 LockModelImpl.CLASSNAME_COLUMN_BITMASK |
1706 LockModelImpl.KEY_COLUMN_BITMASK);
1707 public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
1708 LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
1709 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K",
1710 new String[] { String.class.getName(), String.class.getName() });
1711
1712
1721 @Override
1722 public Lock findByC_K(String className, String key)
1723 throws NoSuchLockException, SystemException {
1724 Lock lock = fetchByC_K(className, key);
1725
1726 if (lock == null) {
1727 StringBundler msg = new StringBundler(6);
1728
1729 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1730
1731 msg.append("className=");
1732 msg.append(className);
1733
1734 msg.append(", key=");
1735 msg.append(key);
1736
1737 msg.append(StringPool.CLOSE_CURLY_BRACE);
1738
1739 if (_log.isWarnEnabled()) {
1740 _log.warn(msg.toString());
1741 }
1742
1743 throw new NoSuchLockException(msg.toString());
1744 }
1745
1746 return lock;
1747 }
1748
1749
1757 @Override
1758 public Lock fetchByC_K(String className, String key)
1759 throws SystemException {
1760 return fetchByC_K(className, key, true);
1761 }
1762
1763
1772 @Override
1773 public Lock fetchByC_K(String className, String key,
1774 boolean retrieveFromCache) throws SystemException {
1775 Object[] finderArgs = new Object[] { className, key };
1776
1777 Object result = null;
1778
1779 if (retrieveFromCache) {
1780 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_K,
1781 finderArgs, this);
1782 }
1783
1784 if (result instanceof Lock) {
1785 Lock lock = (Lock)result;
1786
1787 if (!Validator.equals(className, lock.getClassName()) ||
1788 !Validator.equals(key, lock.getKey())) {
1789 result = null;
1790 }
1791 }
1792
1793 if (result == null) {
1794 StringBundler query = new StringBundler(4);
1795
1796 query.append(_SQL_SELECT_LOCK_WHERE);
1797
1798 boolean bindClassName = false;
1799
1800 if (className == null) {
1801 query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
1802 }
1803 else if (className.equals(StringPool.BLANK)) {
1804 query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
1805 }
1806 else {
1807 bindClassName = true;
1808
1809 query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
1810 }
1811
1812 boolean bindKey = false;
1813
1814 if (key == null) {
1815 query.append(_FINDER_COLUMN_C_K_KEY_1);
1816 }
1817 else if (key.equals(StringPool.BLANK)) {
1818 query.append(_FINDER_COLUMN_C_K_KEY_3);
1819 }
1820 else {
1821 bindKey = true;
1822
1823 query.append(_FINDER_COLUMN_C_K_KEY_2);
1824 }
1825
1826 String sql = query.toString();
1827
1828 Session session = null;
1829
1830 try {
1831 session = openSession();
1832
1833 Query q = session.createQuery(sql);
1834
1835 QueryPos qPos = QueryPos.getInstance(q);
1836
1837 if (bindClassName) {
1838 qPos.add(className);
1839 }
1840
1841 if (bindKey) {
1842 qPos.add(key);
1843 }
1844
1845 List<Lock> list = q.list();
1846
1847 if (list.isEmpty()) {
1848 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1849 finderArgs, list);
1850 }
1851 else {
1852 Lock lock = list.get(0);
1853
1854 result = lock;
1855
1856 cacheResult(lock);
1857
1858 if ((lock.getClassName() == null) ||
1859 !lock.getClassName().equals(className) ||
1860 (lock.getKey() == null) ||
1861 !lock.getKey().equals(key)) {
1862 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1863 finderArgs, lock);
1864 }
1865 }
1866 }
1867 catch (Exception e) {
1868 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
1869 finderArgs);
1870
1871 throw processException(e);
1872 }
1873 finally {
1874 closeSession(session);
1875 }
1876 }
1877
1878 if (result instanceof List<?>) {
1879 return null;
1880 }
1881 else {
1882 return (Lock)result;
1883 }
1884 }
1885
1886
1894 @Override
1895 public Lock removeByC_K(String className, String key)
1896 throws NoSuchLockException, SystemException {
1897 Lock lock = findByC_K(className, key);
1898
1899 return remove(lock);
1900 }
1901
1902
1910 @Override
1911 public int countByC_K(String className, String key)
1912 throws SystemException {
1913 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_K;
1914
1915 Object[] finderArgs = new Object[] { className, key };
1916
1917 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1918 this);
1919
1920 if (count == null) {
1921 StringBundler query = new StringBundler(3);
1922
1923 query.append(_SQL_COUNT_LOCK_WHERE);
1924
1925 boolean bindClassName = false;
1926
1927 if (className == null) {
1928 query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
1929 }
1930 else if (className.equals(StringPool.BLANK)) {
1931 query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
1932 }
1933 else {
1934 bindClassName = true;
1935
1936 query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
1937 }
1938
1939 boolean bindKey = false;
1940
1941 if (key == null) {
1942 query.append(_FINDER_COLUMN_C_K_KEY_1);
1943 }
1944 else if (key.equals(StringPool.BLANK)) {
1945 query.append(_FINDER_COLUMN_C_K_KEY_3);
1946 }
1947 else {
1948 bindKey = true;
1949
1950 query.append(_FINDER_COLUMN_C_K_KEY_2);
1951 }
1952
1953 String sql = query.toString();
1954
1955 Session session = null;
1956
1957 try {
1958 session = openSession();
1959
1960 Query q = session.createQuery(sql);
1961
1962 QueryPos qPos = QueryPos.getInstance(q);
1963
1964 if (bindClassName) {
1965 qPos.add(className);
1966 }
1967
1968 if (bindKey) {
1969 qPos.add(key);
1970 }
1971
1972 count = (Long)q.uniqueResult();
1973
1974 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1975 }
1976 catch (Exception e) {
1977 FinderCacheUtil.removeResult(finderPath, finderArgs);
1978
1979 throw processException(e);
1980 }
1981 finally {
1982 closeSession(session);
1983 }
1984 }
1985
1986 return count.intValue();
1987 }
1988
1989 private static final String _FINDER_COLUMN_C_K_CLASSNAME_1 = "lock.className IS NULL AND ";
1990 private static final String _FINDER_COLUMN_C_K_CLASSNAME_2 = "lock.className = ? AND ";
1991 private static final String _FINDER_COLUMN_C_K_CLASSNAME_3 = "(lock.className IS NULL OR lock.className = '') AND ";
1992 private static final String _FINDER_COLUMN_C_K_KEY_1 = "lock.key IS NULL";
1993 private static final String _FINDER_COLUMN_C_K_KEY_2 = "lock.key = ?";
1994 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(lock.key IS NULL OR lock.key = '')";
1995
1996 public LockPersistenceImpl() {
1997 setModelClass(Lock.class);
1998 }
1999
2000
2005 @Override
2006 public void cacheResult(Lock lock) {
2007 EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2008 LockImpl.class, lock.getPrimaryKey(), lock);
2009
2010 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
2011 new Object[] { lock.getClassName(), lock.getKey() }, lock);
2012
2013 lock.resetOriginalValues();
2014 }
2015
2016
2021 @Override
2022 public void cacheResult(List<Lock> locks) {
2023 for (Lock lock : locks) {
2024 if (EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2025 LockImpl.class, lock.getPrimaryKey()) == null) {
2026 cacheResult(lock);
2027 }
2028 else {
2029 lock.resetOriginalValues();
2030 }
2031 }
2032 }
2033
2034
2041 @Override
2042 public void clearCache() {
2043 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2044 CacheRegistryUtil.clear(LockImpl.class.getName());
2045 }
2046
2047 EntityCacheUtil.clearCache(LockImpl.class.getName());
2048
2049 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2050 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2051 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2052 }
2053
2054
2061 @Override
2062 public void clearCache(Lock lock) {
2063 EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2064 LockImpl.class, lock.getPrimaryKey());
2065
2066 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2067 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2068
2069 clearUniqueFindersCache(lock);
2070 }
2071
2072 @Override
2073 public void clearCache(List<Lock> locks) {
2074 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2075 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2076
2077 for (Lock lock : locks) {
2078 EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2079 LockImpl.class, lock.getPrimaryKey());
2080
2081 clearUniqueFindersCache(lock);
2082 }
2083 }
2084
2085 protected void cacheUniqueFindersCache(Lock lock) {
2086 if (lock.isNew()) {
2087 Object[] args = new Object[] { lock.getClassName(), lock.getKey() };
2088
2089 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, args,
2090 Long.valueOf(1));
2091 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K, args, lock);
2092 }
2093 else {
2094 LockModelImpl lockModelImpl = (LockModelImpl)lock;
2095
2096 if ((lockModelImpl.getColumnBitmask() &
2097 FINDER_PATH_FETCH_BY_C_K.getColumnBitmask()) != 0) {
2098 Object[] args = new Object[] { lock.getClassName(), lock.getKey() };
2099
2100 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, args,
2101 Long.valueOf(1));
2102 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K, args, lock);
2103 }
2104 }
2105 }
2106
2107 protected void clearUniqueFindersCache(Lock lock) {
2108 LockModelImpl lockModelImpl = (LockModelImpl)lock;
2109
2110 Object[] args = new Object[] { lock.getClassName(), lock.getKey() };
2111
2112 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2113 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K, args);
2114
2115 if ((lockModelImpl.getColumnBitmask() &
2116 FINDER_PATH_FETCH_BY_C_K.getColumnBitmask()) != 0) {
2117 args = new Object[] {
2118 lockModelImpl.getOriginalClassName(),
2119 lockModelImpl.getOriginalKey()
2120 };
2121
2122 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2123 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K, args);
2124 }
2125 }
2126
2127
2133 @Override
2134 public Lock create(long lockId) {
2135 Lock lock = new LockImpl();
2136
2137 lock.setNew(true);
2138 lock.setPrimaryKey(lockId);
2139
2140 String uuid = PortalUUIDUtil.generate();
2141
2142 lock.setUuid(uuid);
2143
2144 return lock;
2145 }
2146
2147
2155 @Override
2156 public Lock remove(long lockId) throws NoSuchLockException, SystemException {
2157 return remove((Serializable)lockId);
2158 }
2159
2160
2168 @Override
2169 public Lock remove(Serializable primaryKey)
2170 throws NoSuchLockException, SystemException {
2171 Session session = null;
2172
2173 try {
2174 session = openSession();
2175
2176 Lock lock = (Lock)session.get(LockImpl.class, primaryKey);
2177
2178 if (lock == null) {
2179 if (_log.isWarnEnabled()) {
2180 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2181 }
2182
2183 throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2184 primaryKey);
2185 }
2186
2187 return remove(lock);
2188 }
2189 catch (NoSuchLockException nsee) {
2190 throw nsee;
2191 }
2192 catch (Exception e) {
2193 throw processException(e);
2194 }
2195 finally {
2196 closeSession(session);
2197 }
2198 }
2199
2200 @Override
2201 protected Lock removeImpl(Lock lock) throws SystemException {
2202 lock = toUnwrappedModel(lock);
2203
2204 Session session = null;
2205
2206 try {
2207 session = openSession();
2208
2209 if (!session.contains(lock)) {
2210 lock = (Lock)session.get(LockImpl.class, lock.getPrimaryKeyObj());
2211 }
2212
2213 if (lock != null) {
2214 session.delete(lock);
2215 }
2216 }
2217 catch (Exception e) {
2218 throw processException(e);
2219 }
2220 finally {
2221 closeSession(session);
2222 }
2223
2224 if (lock != null) {
2225 clearCache(lock);
2226 }
2227
2228 return lock;
2229 }
2230
2231 @Override
2232 public Lock updateImpl(com.liferay.portal.model.Lock lock)
2233 throws SystemException {
2234 lock = toUnwrappedModel(lock);
2235
2236 boolean isNew = lock.isNew();
2237
2238 LockModelImpl lockModelImpl = (LockModelImpl)lock;
2239
2240 if (Validator.isNull(lock.getUuid())) {
2241 String uuid = PortalUUIDUtil.generate();
2242
2243 lock.setUuid(uuid);
2244 }
2245
2246 Session session = null;
2247
2248 try {
2249 session = openSession();
2250
2251 if (lock.isNew()) {
2252 session.save(lock);
2253
2254 lock.setNew(false);
2255 }
2256 else {
2257 session.merge(lock);
2258 }
2259 }
2260 catch (Exception e) {
2261 throw processException(e);
2262 }
2263 finally {
2264 closeSession(session);
2265 }
2266
2267 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2268
2269 if (isNew || !LockModelImpl.COLUMN_BITMASK_ENABLED) {
2270 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2271 }
2272
2273 else {
2274 if ((lockModelImpl.getColumnBitmask() &
2275 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2276 Object[] args = new Object[] { lockModelImpl.getOriginalUuid() };
2277
2278 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2279 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2280 args);
2281
2282 args = new Object[] { lockModelImpl.getUuid() };
2283
2284 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2285 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2286 args);
2287 }
2288
2289 if ((lockModelImpl.getColumnBitmask() &
2290 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2291 Object[] args = new Object[] {
2292 lockModelImpl.getOriginalUuid(),
2293 lockModelImpl.getOriginalCompanyId()
2294 };
2295
2296 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2297 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2298 args);
2299
2300 args = new Object[] {
2301 lockModelImpl.getUuid(), lockModelImpl.getCompanyId()
2302 };
2303
2304 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2305 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2306 args);
2307 }
2308 }
2309
2310 EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2311 LockImpl.class, lock.getPrimaryKey(), lock);
2312
2313 clearUniqueFindersCache(lock);
2314 cacheUniqueFindersCache(lock);
2315
2316 return lock;
2317 }
2318
2319 protected Lock toUnwrappedModel(Lock lock) {
2320 if (lock instanceof LockImpl) {
2321 return lock;
2322 }
2323
2324 LockImpl lockImpl = new LockImpl();
2325
2326 lockImpl.setNew(lock.isNew());
2327 lockImpl.setPrimaryKey(lock.getPrimaryKey());
2328
2329 lockImpl.setUuid(lock.getUuid());
2330 lockImpl.setLockId(lock.getLockId());
2331 lockImpl.setCompanyId(lock.getCompanyId());
2332 lockImpl.setUserId(lock.getUserId());
2333 lockImpl.setUserName(lock.getUserName());
2334 lockImpl.setCreateDate(lock.getCreateDate());
2335 lockImpl.setClassName(lock.getClassName());
2336 lockImpl.setKey(lock.getKey());
2337 lockImpl.setOwner(lock.getOwner());
2338 lockImpl.setInheritable(lock.isInheritable());
2339 lockImpl.setExpirationDate(lock.getExpirationDate());
2340
2341 return lockImpl;
2342 }
2343
2344
2352 @Override
2353 public Lock findByPrimaryKey(Serializable primaryKey)
2354 throws NoSuchLockException, SystemException {
2355 Lock lock = fetchByPrimaryKey(primaryKey);
2356
2357 if (lock == null) {
2358 if (_log.isWarnEnabled()) {
2359 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2360 }
2361
2362 throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2363 primaryKey);
2364 }
2365
2366 return lock;
2367 }
2368
2369
2377 @Override
2378 public Lock findByPrimaryKey(long lockId)
2379 throws NoSuchLockException, SystemException {
2380 return findByPrimaryKey((Serializable)lockId);
2381 }
2382
2383
2390 @Override
2391 public Lock fetchByPrimaryKey(Serializable primaryKey)
2392 throws SystemException {
2393 Lock lock = (Lock)EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2394 LockImpl.class, primaryKey);
2395
2396 if (lock == _nullLock) {
2397 return null;
2398 }
2399
2400 if (lock == null) {
2401 Session session = null;
2402
2403 try {
2404 session = openSession();
2405
2406 lock = (Lock)session.get(LockImpl.class, primaryKey);
2407
2408 if (lock != null) {
2409 cacheResult(lock);
2410 }
2411 else {
2412 EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2413 LockImpl.class, primaryKey, _nullLock);
2414 }
2415 }
2416 catch (Exception e) {
2417 EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2418 LockImpl.class, primaryKey);
2419
2420 throw processException(e);
2421 }
2422 finally {
2423 closeSession(session);
2424 }
2425 }
2426
2427 return lock;
2428 }
2429
2430
2437 @Override
2438 public Lock fetchByPrimaryKey(long lockId) throws SystemException {
2439 return fetchByPrimaryKey((Serializable)lockId);
2440 }
2441
2442
2448 @Override
2449 public List<Lock> findAll() throws SystemException {
2450 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2451 }
2452
2453
2465 @Override
2466 public List<Lock> findAll(int start, int end) throws SystemException {
2467 return findAll(start, end, null);
2468 }
2469
2470
2483 @Override
2484 public List<Lock> findAll(int start, int end,
2485 OrderByComparator orderByComparator) throws SystemException {
2486 boolean pagination = true;
2487 FinderPath finderPath = null;
2488 Object[] finderArgs = null;
2489
2490 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2491 (orderByComparator == null)) {
2492 pagination = false;
2493 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2494 finderArgs = FINDER_ARGS_EMPTY;
2495 }
2496 else {
2497 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2498 finderArgs = new Object[] { start, end, orderByComparator };
2499 }
2500
2501 List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
2502 finderArgs, this);
2503
2504 if (list == null) {
2505 StringBundler query = null;
2506 String sql = null;
2507
2508 if (orderByComparator != null) {
2509 query = new StringBundler(2 +
2510 (orderByComparator.getOrderByFields().length * 3));
2511
2512 query.append(_SQL_SELECT_LOCK);
2513
2514 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2515 orderByComparator);
2516
2517 sql = query.toString();
2518 }
2519 else {
2520 sql = _SQL_SELECT_LOCK;
2521
2522 if (pagination) {
2523 sql = sql.concat(LockModelImpl.ORDER_BY_JPQL);
2524 }
2525 }
2526
2527 Session session = null;
2528
2529 try {
2530 session = openSession();
2531
2532 Query q = session.createQuery(sql);
2533
2534 if (!pagination) {
2535 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
2536 end, false);
2537
2538 Collections.sort(list);
2539
2540 list = new UnmodifiableList<Lock>(list);
2541 }
2542 else {
2543 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
2544 end);
2545 }
2546
2547 cacheResult(list);
2548
2549 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2550 }
2551 catch (Exception e) {
2552 FinderCacheUtil.removeResult(finderPath, finderArgs);
2553
2554 throw processException(e);
2555 }
2556 finally {
2557 closeSession(session);
2558 }
2559 }
2560
2561 return list;
2562 }
2563
2564
2569 @Override
2570 public void removeAll() throws SystemException {
2571 for (Lock lock : findAll()) {
2572 remove(lock);
2573 }
2574 }
2575
2576
2582 @Override
2583 public int countAll() throws SystemException {
2584 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2585 FINDER_ARGS_EMPTY, this);
2586
2587 if (count == null) {
2588 Session session = null;
2589
2590 try {
2591 session = openSession();
2592
2593 Query q = session.createQuery(_SQL_COUNT_LOCK);
2594
2595 count = (Long)q.uniqueResult();
2596
2597 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2598 FINDER_ARGS_EMPTY, count);
2599 }
2600 catch (Exception e) {
2601 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2602 FINDER_ARGS_EMPTY);
2603
2604 throw processException(e);
2605 }
2606 finally {
2607 closeSession(session);
2608 }
2609 }
2610
2611 return count.intValue();
2612 }
2613
2614 @Override
2615 protected Set<String> getBadColumnNames() {
2616 return _badColumnNames;
2617 }
2618
2619
2622 public void afterPropertiesSet() {
2623 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2624 com.liferay.portal.util.PropsUtil.get(
2625 "value.object.listener.com.liferay.portal.model.Lock")));
2626
2627 if (listenerClassNames.length > 0) {
2628 try {
2629 List<ModelListener<Lock>> listenersList = new ArrayList<ModelListener<Lock>>();
2630
2631 for (String listenerClassName : listenerClassNames) {
2632 listenersList.add((ModelListener<Lock>)InstanceFactory.newInstance(
2633 getClassLoader(), listenerClassName));
2634 }
2635
2636 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2637 }
2638 catch (Exception e) {
2639 _log.error(e);
2640 }
2641 }
2642 }
2643
2644 public void destroy() {
2645 EntityCacheUtil.removeCache(LockImpl.class.getName());
2646 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2647 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2648 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2649 }
2650
2651 private static final String _SQL_SELECT_LOCK = "SELECT lock FROM Lock lock";
2652 private static final String _SQL_SELECT_LOCK_WHERE = "SELECT lock FROM Lock lock WHERE ";
2653 private static final String _SQL_COUNT_LOCK = "SELECT COUNT(lock) FROM Lock lock";
2654 private static final String _SQL_COUNT_LOCK_WHERE = "SELECT COUNT(lock) FROM Lock lock WHERE ";
2655 private static final String _ORDER_BY_ENTITY_ALIAS = "lock.";
2656 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Lock exists with the primary key ";
2657 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Lock exists with the key {";
2658 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2659 private static Log _log = LogFactoryUtil.getLog(LockPersistenceImpl.class);
2660 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2661 "uuid", "key"
2662 });
2663 private static Lock _nullLock = new LockImpl() {
2664 @Override
2665 public Object clone() {
2666 return this;
2667 }
2668
2669 @Override
2670 public CacheModel<Lock> toCacheModel() {
2671 return _nullLockCacheModel;
2672 }
2673 };
2674
2675 private static CacheModel<Lock> _nullLockCacheModel = new CacheModel<Lock>() {
2676 @Override
2677 public Lock toEntityModel() {
2678 return _nullLock;
2679 }
2680 };
2681 }