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 (!Validator.equals(expirationDate, lock.getExpirationDate())) {
1262 list = null;
1263
1264 break;
1265 }
1266 }
1267 }
1268
1269 if (list == null) {
1270 StringBundler query = null;
1271
1272 if (orderByComparator != null) {
1273 query = new StringBundler(3 +
1274 (orderByComparator.getOrderByFields().length * 3));
1275 }
1276 else {
1277 query = new StringBundler(3);
1278 }
1279
1280 query.append(_SQL_SELECT_LOCK_WHERE);
1281
1282 boolean bindExpirationDate = false;
1283
1284 if (expirationDate == null) {
1285 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1286 }
1287 else {
1288 bindExpirationDate = true;
1289
1290 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1291 }
1292
1293 if (orderByComparator != null) {
1294 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1295 orderByComparator);
1296 }
1297 else
1298 if (pagination) {
1299 query.append(LockModelImpl.ORDER_BY_JPQL);
1300 }
1301
1302 String sql = query.toString();
1303
1304 Session session = null;
1305
1306 try {
1307 session = openSession();
1308
1309 Query q = session.createQuery(sql);
1310
1311 QueryPos qPos = QueryPos.getInstance(q);
1312
1313 if (bindExpirationDate) {
1314 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1315 }
1316
1317 if (!pagination) {
1318 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1319 end, false);
1320
1321 Collections.sort(list);
1322
1323 list = new UnmodifiableList<Lock>(list);
1324 }
1325 else {
1326 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
1327 end);
1328 }
1329
1330 cacheResult(list);
1331
1332 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1333 }
1334 catch (Exception e) {
1335 FinderCacheUtil.removeResult(finderPath, finderArgs);
1336
1337 throw processException(e);
1338 }
1339 finally {
1340 closeSession(session);
1341 }
1342 }
1343
1344 return list;
1345 }
1346
1347
1356 @Override
1357 public Lock findByLtExpirationDate_First(Date expirationDate,
1358 OrderByComparator orderByComparator)
1359 throws NoSuchLockException, SystemException {
1360 Lock lock = fetchByLtExpirationDate_First(expirationDate,
1361 orderByComparator);
1362
1363 if (lock != null) {
1364 return lock;
1365 }
1366
1367 StringBundler msg = new StringBundler(4);
1368
1369 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1370
1371 msg.append("expirationDate=");
1372 msg.append(expirationDate);
1373
1374 msg.append(StringPool.CLOSE_CURLY_BRACE);
1375
1376 throw new NoSuchLockException(msg.toString());
1377 }
1378
1379
1387 @Override
1388 public Lock fetchByLtExpirationDate_First(Date expirationDate,
1389 OrderByComparator orderByComparator) throws SystemException {
1390 List<Lock> list = findByLtExpirationDate(expirationDate, 0, 1,
1391 orderByComparator);
1392
1393 if (!list.isEmpty()) {
1394 return list.get(0);
1395 }
1396
1397 return null;
1398 }
1399
1400
1409 @Override
1410 public Lock findByLtExpirationDate_Last(Date expirationDate,
1411 OrderByComparator orderByComparator)
1412 throws NoSuchLockException, SystemException {
1413 Lock lock = fetchByLtExpirationDate_Last(expirationDate,
1414 orderByComparator);
1415
1416 if (lock != null) {
1417 return lock;
1418 }
1419
1420 StringBundler msg = new StringBundler(4);
1421
1422 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1423
1424 msg.append("expirationDate=");
1425 msg.append(expirationDate);
1426
1427 msg.append(StringPool.CLOSE_CURLY_BRACE);
1428
1429 throw new NoSuchLockException(msg.toString());
1430 }
1431
1432
1440 @Override
1441 public Lock fetchByLtExpirationDate_Last(Date expirationDate,
1442 OrderByComparator orderByComparator) throws SystemException {
1443 int count = countByLtExpirationDate(expirationDate);
1444
1445 if (count == 0) {
1446 return null;
1447 }
1448
1449 List<Lock> list = findByLtExpirationDate(expirationDate, count - 1,
1450 count, orderByComparator);
1451
1452 if (!list.isEmpty()) {
1453 return list.get(0);
1454 }
1455
1456 return null;
1457 }
1458
1459
1469 @Override
1470 public Lock[] findByLtExpirationDate_PrevAndNext(long lockId,
1471 Date expirationDate, OrderByComparator orderByComparator)
1472 throws NoSuchLockException, SystemException {
1473 Lock lock = findByPrimaryKey(lockId);
1474
1475 Session session = null;
1476
1477 try {
1478 session = openSession();
1479
1480 Lock[] array = new LockImpl[3];
1481
1482 array[0] = getByLtExpirationDate_PrevAndNext(session, lock,
1483 expirationDate, orderByComparator, true);
1484
1485 array[1] = lock;
1486
1487 array[2] = getByLtExpirationDate_PrevAndNext(session, lock,
1488 expirationDate, orderByComparator, false);
1489
1490 return array;
1491 }
1492 catch (Exception e) {
1493 throw processException(e);
1494 }
1495 finally {
1496 closeSession(session);
1497 }
1498 }
1499
1500 protected Lock getByLtExpirationDate_PrevAndNext(Session session,
1501 Lock lock, Date expirationDate, OrderByComparator orderByComparator,
1502 boolean previous) {
1503 StringBundler query = null;
1504
1505 if (orderByComparator != null) {
1506 query = new StringBundler(6 +
1507 (orderByComparator.getOrderByFields().length * 6));
1508 }
1509 else {
1510 query = new StringBundler(3);
1511 }
1512
1513 query.append(_SQL_SELECT_LOCK_WHERE);
1514
1515 boolean bindExpirationDate = false;
1516
1517 if (expirationDate == null) {
1518 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1519 }
1520 else {
1521 bindExpirationDate = true;
1522
1523 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1524 }
1525
1526 if (orderByComparator != null) {
1527 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1528
1529 if (orderByConditionFields.length > 0) {
1530 query.append(WHERE_AND);
1531 }
1532
1533 for (int i = 0; i < orderByConditionFields.length; i++) {
1534 query.append(_ORDER_BY_ENTITY_ALIAS);
1535 query.append(orderByConditionFields[i]);
1536
1537 if ((i + 1) < orderByConditionFields.length) {
1538 if (orderByComparator.isAscending() ^ previous) {
1539 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1540 }
1541 else {
1542 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1543 }
1544 }
1545 else {
1546 if (orderByComparator.isAscending() ^ previous) {
1547 query.append(WHERE_GREATER_THAN);
1548 }
1549 else {
1550 query.append(WHERE_LESSER_THAN);
1551 }
1552 }
1553 }
1554
1555 query.append(ORDER_BY_CLAUSE);
1556
1557 String[] orderByFields = orderByComparator.getOrderByFields();
1558
1559 for (int i = 0; i < orderByFields.length; i++) {
1560 query.append(_ORDER_BY_ENTITY_ALIAS);
1561 query.append(orderByFields[i]);
1562
1563 if ((i + 1) < orderByFields.length) {
1564 if (orderByComparator.isAscending() ^ previous) {
1565 query.append(ORDER_BY_ASC_HAS_NEXT);
1566 }
1567 else {
1568 query.append(ORDER_BY_DESC_HAS_NEXT);
1569 }
1570 }
1571 else {
1572 if (orderByComparator.isAscending() ^ previous) {
1573 query.append(ORDER_BY_ASC);
1574 }
1575 else {
1576 query.append(ORDER_BY_DESC);
1577 }
1578 }
1579 }
1580 }
1581 else {
1582 query.append(LockModelImpl.ORDER_BY_JPQL);
1583 }
1584
1585 String sql = query.toString();
1586
1587 Query q = session.createQuery(sql);
1588
1589 q.setFirstResult(0);
1590 q.setMaxResults(2);
1591
1592 QueryPos qPos = QueryPos.getInstance(q);
1593
1594 if (bindExpirationDate) {
1595 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1596 }
1597
1598 if (orderByComparator != null) {
1599 Object[] values = orderByComparator.getOrderByConditionValues(lock);
1600
1601 for (Object value : values) {
1602 qPos.add(value);
1603 }
1604 }
1605
1606 List<Lock> list = q.list();
1607
1608 if (list.size() == 2) {
1609 return list.get(1);
1610 }
1611 else {
1612 return null;
1613 }
1614 }
1615
1616
1622 @Override
1623 public void removeByLtExpirationDate(Date expirationDate)
1624 throws SystemException {
1625 for (Lock lock : findByLtExpirationDate(expirationDate,
1626 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1627 remove(lock);
1628 }
1629 }
1630
1631
1638 @Override
1639 public int countByLtExpirationDate(Date expirationDate)
1640 throws SystemException {
1641 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTEXPIRATIONDATE;
1642
1643 Object[] finderArgs = new Object[] { expirationDate };
1644
1645 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1646 this);
1647
1648 if (count == null) {
1649 StringBundler query = new StringBundler(2);
1650
1651 query.append(_SQL_COUNT_LOCK_WHERE);
1652
1653 boolean bindExpirationDate = false;
1654
1655 if (expirationDate == null) {
1656 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1);
1657 }
1658 else {
1659 bindExpirationDate = true;
1660
1661 query.append(_FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2);
1662 }
1663
1664 String sql = query.toString();
1665
1666 Session session = null;
1667
1668 try {
1669 session = openSession();
1670
1671 Query q = session.createQuery(sql);
1672
1673 QueryPos qPos = QueryPos.getInstance(q);
1674
1675 if (bindExpirationDate) {
1676 qPos.add(CalendarUtil.getTimestamp(expirationDate));
1677 }
1678
1679 count = (Long)q.uniqueResult();
1680
1681 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1682 }
1683 catch (Exception e) {
1684 FinderCacheUtil.removeResult(finderPath, finderArgs);
1685
1686 throw processException(e);
1687 }
1688 finally {
1689 closeSession(session);
1690 }
1691 }
1692
1693 return count.intValue();
1694 }
1695
1696 private static final String _FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_1 =
1697 "lock.expirationDate < NULL";
1698 private static final String _FINDER_COLUMN_LTEXPIRATIONDATE_EXPIRATIONDATE_2 =
1699 "lock.expirationDate < ?";
1700 public static final FinderPath FINDER_PATH_FETCH_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
1701 LockModelImpl.FINDER_CACHE_ENABLED, LockImpl.class,
1702 FINDER_CLASS_NAME_ENTITY, "fetchByC_K",
1703 new String[] { String.class.getName(), String.class.getName() },
1704 LockModelImpl.CLASSNAME_COLUMN_BITMASK |
1705 LockModelImpl.KEY_COLUMN_BITMASK);
1706 public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(LockModelImpl.ENTITY_CACHE_ENABLED,
1707 LockModelImpl.FINDER_CACHE_ENABLED, Long.class,
1708 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K",
1709 new String[] { String.class.getName(), String.class.getName() });
1710
1711
1720 @Override
1721 public Lock findByC_K(String className, String key)
1722 throws NoSuchLockException, SystemException {
1723 Lock lock = fetchByC_K(className, key);
1724
1725 if (lock == null) {
1726 StringBundler msg = new StringBundler(6);
1727
1728 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1729
1730 msg.append("className=");
1731 msg.append(className);
1732
1733 msg.append(", key=");
1734 msg.append(key);
1735
1736 msg.append(StringPool.CLOSE_CURLY_BRACE);
1737
1738 if (_log.isWarnEnabled()) {
1739 _log.warn(msg.toString());
1740 }
1741
1742 throw new NoSuchLockException(msg.toString());
1743 }
1744
1745 return lock;
1746 }
1747
1748
1756 @Override
1757 public Lock fetchByC_K(String className, String key)
1758 throws SystemException {
1759 return fetchByC_K(className, key, true);
1760 }
1761
1762
1771 @Override
1772 public Lock fetchByC_K(String className, String key,
1773 boolean retrieveFromCache) throws SystemException {
1774 Object[] finderArgs = new Object[] { className, key };
1775
1776 Object result = null;
1777
1778 if (retrieveFromCache) {
1779 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_K,
1780 finderArgs, this);
1781 }
1782
1783 if (result instanceof Lock) {
1784 Lock lock = (Lock)result;
1785
1786 if (!Validator.equals(className, lock.getClassName()) ||
1787 !Validator.equals(key, lock.getKey())) {
1788 result = null;
1789 }
1790 }
1791
1792 if (result == null) {
1793 StringBundler query = new StringBundler(4);
1794
1795 query.append(_SQL_SELECT_LOCK_WHERE);
1796
1797 boolean bindClassName = false;
1798
1799 if (className == null) {
1800 query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
1801 }
1802 else if (className.equals(StringPool.BLANK)) {
1803 query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
1804 }
1805 else {
1806 bindClassName = true;
1807
1808 query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
1809 }
1810
1811 boolean bindKey = false;
1812
1813 if (key == null) {
1814 query.append(_FINDER_COLUMN_C_K_KEY_1);
1815 }
1816 else if (key.equals(StringPool.BLANK)) {
1817 query.append(_FINDER_COLUMN_C_K_KEY_3);
1818 }
1819 else {
1820 bindKey = true;
1821
1822 query.append(_FINDER_COLUMN_C_K_KEY_2);
1823 }
1824
1825 String sql = query.toString();
1826
1827 Session session = null;
1828
1829 try {
1830 session = openSession();
1831
1832 Query q = session.createQuery(sql);
1833
1834 QueryPos qPos = QueryPos.getInstance(q);
1835
1836 if (bindClassName) {
1837 qPos.add(className);
1838 }
1839
1840 if (bindKey) {
1841 qPos.add(key);
1842 }
1843
1844 List<Lock> list = q.list();
1845
1846 if (list.isEmpty()) {
1847 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1848 finderArgs, list);
1849 }
1850 else {
1851 Lock lock = list.get(0);
1852
1853 result = lock;
1854
1855 cacheResult(lock);
1856
1857 if ((lock.getClassName() == null) ||
1858 !lock.getClassName().equals(className) ||
1859 (lock.getKey() == null) ||
1860 !lock.getKey().equals(key)) {
1861 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
1862 finderArgs, lock);
1863 }
1864 }
1865 }
1866 catch (Exception e) {
1867 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K,
1868 finderArgs);
1869
1870 throw processException(e);
1871 }
1872 finally {
1873 closeSession(session);
1874 }
1875 }
1876
1877 if (result instanceof List<?>) {
1878 return null;
1879 }
1880 else {
1881 return (Lock)result;
1882 }
1883 }
1884
1885
1893 @Override
1894 public Lock removeByC_K(String className, String key)
1895 throws NoSuchLockException, SystemException {
1896 Lock lock = findByC_K(className, key);
1897
1898 return remove(lock);
1899 }
1900
1901
1909 @Override
1910 public int countByC_K(String className, String key)
1911 throws SystemException {
1912 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_K;
1913
1914 Object[] finderArgs = new Object[] { className, key };
1915
1916 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1917 this);
1918
1919 if (count == null) {
1920 StringBundler query = new StringBundler(3);
1921
1922 query.append(_SQL_COUNT_LOCK_WHERE);
1923
1924 boolean bindClassName = false;
1925
1926 if (className == null) {
1927 query.append(_FINDER_COLUMN_C_K_CLASSNAME_1);
1928 }
1929 else if (className.equals(StringPool.BLANK)) {
1930 query.append(_FINDER_COLUMN_C_K_CLASSNAME_3);
1931 }
1932 else {
1933 bindClassName = true;
1934
1935 query.append(_FINDER_COLUMN_C_K_CLASSNAME_2);
1936 }
1937
1938 boolean bindKey = false;
1939
1940 if (key == null) {
1941 query.append(_FINDER_COLUMN_C_K_KEY_1);
1942 }
1943 else if (key.equals(StringPool.BLANK)) {
1944 query.append(_FINDER_COLUMN_C_K_KEY_3);
1945 }
1946 else {
1947 bindKey = true;
1948
1949 query.append(_FINDER_COLUMN_C_K_KEY_2);
1950 }
1951
1952 String sql = query.toString();
1953
1954 Session session = null;
1955
1956 try {
1957 session = openSession();
1958
1959 Query q = session.createQuery(sql);
1960
1961 QueryPos qPos = QueryPos.getInstance(q);
1962
1963 if (bindClassName) {
1964 qPos.add(className);
1965 }
1966
1967 if (bindKey) {
1968 qPos.add(key);
1969 }
1970
1971 count = (Long)q.uniqueResult();
1972
1973 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1974 }
1975 catch (Exception e) {
1976 FinderCacheUtil.removeResult(finderPath, finderArgs);
1977
1978 throw processException(e);
1979 }
1980 finally {
1981 closeSession(session);
1982 }
1983 }
1984
1985 return count.intValue();
1986 }
1987
1988 private static final String _FINDER_COLUMN_C_K_CLASSNAME_1 = "lock.className IS NULL AND ";
1989 private static final String _FINDER_COLUMN_C_K_CLASSNAME_2 = "lock.className = ? AND ";
1990 private static final String _FINDER_COLUMN_C_K_CLASSNAME_3 = "(lock.className IS NULL OR lock.className = '') AND ";
1991 private static final String _FINDER_COLUMN_C_K_KEY_1 = "lock.key IS NULL";
1992 private static final String _FINDER_COLUMN_C_K_KEY_2 = "lock.key = ?";
1993 private static final String _FINDER_COLUMN_C_K_KEY_3 = "(lock.key IS NULL OR lock.key = '')";
1994
1995
2000 @Override
2001 public void cacheResult(Lock lock) {
2002 EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2003 LockImpl.class, lock.getPrimaryKey(), lock);
2004
2005 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K,
2006 new Object[] { lock.getClassName(), lock.getKey() }, lock);
2007
2008 lock.resetOriginalValues();
2009 }
2010
2011
2016 @Override
2017 public void cacheResult(List<Lock> locks) {
2018 for (Lock lock : locks) {
2019 if (EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2020 LockImpl.class, lock.getPrimaryKey()) == null) {
2021 cacheResult(lock);
2022 }
2023 else {
2024 lock.resetOriginalValues();
2025 }
2026 }
2027 }
2028
2029
2036 @Override
2037 public void clearCache() {
2038 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2039 CacheRegistryUtil.clear(LockImpl.class.getName());
2040 }
2041
2042 EntityCacheUtil.clearCache(LockImpl.class.getName());
2043
2044 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2045 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2046 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2047 }
2048
2049
2056 @Override
2057 public void clearCache(Lock lock) {
2058 EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2059 LockImpl.class, lock.getPrimaryKey());
2060
2061 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2062 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2063
2064 clearUniqueFindersCache(lock);
2065 }
2066
2067 @Override
2068 public void clearCache(List<Lock> locks) {
2069 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2070 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2071
2072 for (Lock lock : locks) {
2073 EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2074 LockImpl.class, lock.getPrimaryKey());
2075
2076 clearUniqueFindersCache(lock);
2077 }
2078 }
2079
2080 protected void cacheUniqueFindersCache(Lock lock) {
2081 if (lock.isNew()) {
2082 Object[] args = new Object[] { lock.getClassName(), lock.getKey() };
2083
2084 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, args,
2085 Long.valueOf(1));
2086 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K, args, lock);
2087 }
2088 else {
2089 LockModelImpl lockModelImpl = (LockModelImpl)lock;
2090
2091 if ((lockModelImpl.getColumnBitmask() &
2092 FINDER_PATH_FETCH_BY_C_K.getColumnBitmask()) != 0) {
2093 Object[] args = new Object[] { lock.getClassName(), lock.getKey() };
2094
2095 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, args,
2096 Long.valueOf(1));
2097 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_K, args, lock);
2098 }
2099 }
2100 }
2101
2102 protected void clearUniqueFindersCache(Lock lock) {
2103 LockModelImpl lockModelImpl = (LockModelImpl)lock;
2104
2105 Object[] args = new Object[] { lock.getClassName(), lock.getKey() };
2106
2107 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2108 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K, args);
2109
2110 if ((lockModelImpl.getColumnBitmask() &
2111 FINDER_PATH_FETCH_BY_C_K.getColumnBitmask()) != 0) {
2112 args = new Object[] {
2113 lockModelImpl.getOriginalClassName(),
2114 lockModelImpl.getOriginalKey()
2115 };
2116
2117 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
2118 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_K, args);
2119 }
2120 }
2121
2122
2128 @Override
2129 public Lock create(long lockId) {
2130 Lock lock = new LockImpl();
2131
2132 lock.setNew(true);
2133 lock.setPrimaryKey(lockId);
2134
2135 String uuid = PortalUUIDUtil.generate();
2136
2137 lock.setUuid(uuid);
2138
2139 return lock;
2140 }
2141
2142
2150 @Override
2151 public Lock remove(long lockId) throws NoSuchLockException, SystemException {
2152 return remove((Serializable)lockId);
2153 }
2154
2155
2163 @Override
2164 public Lock remove(Serializable primaryKey)
2165 throws NoSuchLockException, SystemException {
2166 Session session = null;
2167
2168 try {
2169 session = openSession();
2170
2171 Lock lock = (Lock)session.get(LockImpl.class, primaryKey);
2172
2173 if (lock == null) {
2174 if (_log.isWarnEnabled()) {
2175 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2176 }
2177
2178 throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2179 primaryKey);
2180 }
2181
2182 return remove(lock);
2183 }
2184 catch (NoSuchLockException nsee) {
2185 throw nsee;
2186 }
2187 catch (Exception e) {
2188 throw processException(e);
2189 }
2190 finally {
2191 closeSession(session);
2192 }
2193 }
2194
2195 @Override
2196 protected Lock removeImpl(Lock lock) throws SystemException {
2197 lock = toUnwrappedModel(lock);
2198
2199 Session session = null;
2200
2201 try {
2202 session = openSession();
2203
2204 if (!session.contains(lock)) {
2205 lock = (Lock)session.get(LockImpl.class, lock.getPrimaryKeyObj());
2206 }
2207
2208 if (lock != null) {
2209 session.delete(lock);
2210 }
2211 }
2212 catch (Exception e) {
2213 throw processException(e);
2214 }
2215 finally {
2216 closeSession(session);
2217 }
2218
2219 if (lock != null) {
2220 clearCache(lock);
2221 }
2222
2223 return lock;
2224 }
2225
2226 @Override
2227 public Lock updateImpl(com.liferay.portal.model.Lock lock)
2228 throws SystemException {
2229 lock = toUnwrappedModel(lock);
2230
2231 boolean isNew = lock.isNew();
2232
2233 LockModelImpl lockModelImpl = (LockModelImpl)lock;
2234
2235 if (Validator.isNull(lock.getUuid())) {
2236 String uuid = PortalUUIDUtil.generate();
2237
2238 lock.setUuid(uuid);
2239 }
2240
2241 Session session = null;
2242
2243 try {
2244 session = openSession();
2245
2246 if (lock.isNew()) {
2247 session.save(lock);
2248
2249 lock.setNew(false);
2250 }
2251 else {
2252 session.merge(lock);
2253 }
2254 }
2255 catch (Exception e) {
2256 throw processException(e);
2257 }
2258 finally {
2259 closeSession(session);
2260 }
2261
2262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2263
2264 if (isNew || !LockModelImpl.COLUMN_BITMASK_ENABLED) {
2265 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2266 }
2267
2268 else {
2269 if ((lockModelImpl.getColumnBitmask() &
2270 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2271 Object[] args = new Object[] { lockModelImpl.getOriginalUuid() };
2272
2273 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2274 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2275 args);
2276
2277 args = new Object[] { lockModelImpl.getUuid() };
2278
2279 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2280 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2281 args);
2282 }
2283
2284 if ((lockModelImpl.getColumnBitmask() &
2285 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2286 Object[] args = new Object[] {
2287 lockModelImpl.getOriginalUuid(),
2288 lockModelImpl.getOriginalCompanyId()
2289 };
2290
2291 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2292 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2293 args);
2294
2295 args = new Object[] {
2296 lockModelImpl.getUuid(), lockModelImpl.getCompanyId()
2297 };
2298
2299 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2300 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2301 args);
2302 }
2303 }
2304
2305 EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2306 LockImpl.class, lock.getPrimaryKey(), lock);
2307
2308 clearUniqueFindersCache(lock);
2309 cacheUniqueFindersCache(lock);
2310
2311 return lock;
2312 }
2313
2314 protected Lock toUnwrappedModel(Lock lock) {
2315 if (lock instanceof LockImpl) {
2316 return lock;
2317 }
2318
2319 LockImpl lockImpl = new LockImpl();
2320
2321 lockImpl.setNew(lock.isNew());
2322 lockImpl.setPrimaryKey(lock.getPrimaryKey());
2323
2324 lockImpl.setUuid(lock.getUuid());
2325 lockImpl.setLockId(lock.getLockId());
2326 lockImpl.setCompanyId(lock.getCompanyId());
2327 lockImpl.setUserId(lock.getUserId());
2328 lockImpl.setUserName(lock.getUserName());
2329 lockImpl.setCreateDate(lock.getCreateDate());
2330 lockImpl.setClassName(lock.getClassName());
2331 lockImpl.setKey(lock.getKey());
2332 lockImpl.setOwner(lock.getOwner());
2333 lockImpl.setInheritable(lock.isInheritable());
2334 lockImpl.setExpirationDate(lock.getExpirationDate());
2335
2336 return lockImpl;
2337 }
2338
2339
2347 @Override
2348 public Lock findByPrimaryKey(Serializable primaryKey)
2349 throws NoSuchLockException, SystemException {
2350 Lock lock = fetchByPrimaryKey(primaryKey);
2351
2352 if (lock == null) {
2353 if (_log.isWarnEnabled()) {
2354 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2355 }
2356
2357 throw new NoSuchLockException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2358 primaryKey);
2359 }
2360
2361 return lock;
2362 }
2363
2364
2372 @Override
2373 public Lock findByPrimaryKey(long lockId)
2374 throws NoSuchLockException, SystemException {
2375 return findByPrimaryKey((Serializable)lockId);
2376 }
2377
2378
2385 @Override
2386 public Lock fetchByPrimaryKey(Serializable primaryKey)
2387 throws SystemException {
2388 Lock lock = (Lock)EntityCacheUtil.getResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2389 LockImpl.class, primaryKey);
2390
2391 if (lock == _nullLock) {
2392 return null;
2393 }
2394
2395 if (lock == null) {
2396 Session session = null;
2397
2398 try {
2399 session = openSession();
2400
2401 lock = (Lock)session.get(LockImpl.class, primaryKey);
2402
2403 if (lock != null) {
2404 cacheResult(lock);
2405 }
2406 else {
2407 EntityCacheUtil.putResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2408 LockImpl.class, primaryKey, _nullLock);
2409 }
2410 }
2411 catch (Exception e) {
2412 EntityCacheUtil.removeResult(LockModelImpl.ENTITY_CACHE_ENABLED,
2413 LockImpl.class, primaryKey);
2414
2415 throw processException(e);
2416 }
2417 finally {
2418 closeSession(session);
2419 }
2420 }
2421
2422 return lock;
2423 }
2424
2425
2432 @Override
2433 public Lock fetchByPrimaryKey(long lockId) throws SystemException {
2434 return fetchByPrimaryKey((Serializable)lockId);
2435 }
2436
2437
2443 @Override
2444 public List<Lock> findAll() throws SystemException {
2445 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2446 }
2447
2448
2460 @Override
2461 public List<Lock> findAll(int start, int end) throws SystemException {
2462 return findAll(start, end, null);
2463 }
2464
2465
2478 @Override
2479 public List<Lock> findAll(int start, int end,
2480 OrderByComparator orderByComparator) throws SystemException {
2481 boolean pagination = true;
2482 FinderPath finderPath = null;
2483 Object[] finderArgs = null;
2484
2485 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2486 (orderByComparator == null)) {
2487 pagination = false;
2488 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2489 finderArgs = FINDER_ARGS_EMPTY;
2490 }
2491 else {
2492 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2493 finderArgs = new Object[] { start, end, orderByComparator };
2494 }
2495
2496 List<Lock> list = (List<Lock>)FinderCacheUtil.getResult(finderPath,
2497 finderArgs, this);
2498
2499 if (list == null) {
2500 StringBundler query = null;
2501 String sql = null;
2502
2503 if (orderByComparator != null) {
2504 query = new StringBundler(2 +
2505 (orderByComparator.getOrderByFields().length * 3));
2506
2507 query.append(_SQL_SELECT_LOCK);
2508
2509 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2510 orderByComparator);
2511
2512 sql = query.toString();
2513 }
2514 else {
2515 sql = _SQL_SELECT_LOCK;
2516
2517 if (pagination) {
2518 sql = sql.concat(LockModelImpl.ORDER_BY_JPQL);
2519 }
2520 }
2521
2522 Session session = null;
2523
2524 try {
2525 session = openSession();
2526
2527 Query q = session.createQuery(sql);
2528
2529 if (!pagination) {
2530 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
2531 end, false);
2532
2533 Collections.sort(list);
2534
2535 list = new UnmodifiableList<Lock>(list);
2536 }
2537 else {
2538 list = (List<Lock>)QueryUtil.list(q, getDialect(), start,
2539 end);
2540 }
2541
2542 cacheResult(list);
2543
2544 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2545 }
2546 catch (Exception e) {
2547 FinderCacheUtil.removeResult(finderPath, finderArgs);
2548
2549 throw processException(e);
2550 }
2551 finally {
2552 closeSession(session);
2553 }
2554 }
2555
2556 return list;
2557 }
2558
2559
2564 @Override
2565 public void removeAll() throws SystemException {
2566 for (Lock lock : findAll()) {
2567 remove(lock);
2568 }
2569 }
2570
2571
2577 @Override
2578 public int countAll() throws SystemException {
2579 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2580 FINDER_ARGS_EMPTY, this);
2581
2582 if (count == null) {
2583 Session session = null;
2584
2585 try {
2586 session = openSession();
2587
2588 Query q = session.createQuery(_SQL_COUNT_LOCK);
2589
2590 count = (Long)q.uniqueResult();
2591
2592 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2593 FINDER_ARGS_EMPTY, count);
2594 }
2595 catch (Exception e) {
2596 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2597 FINDER_ARGS_EMPTY);
2598
2599 throw processException(e);
2600 }
2601 finally {
2602 closeSession(session);
2603 }
2604 }
2605
2606 return count.intValue();
2607 }
2608
2609 @Override
2610 protected Set<String> getBadColumnNames() {
2611 return _badColumnNames;
2612 }
2613
2614
2617 public void afterPropertiesSet() {
2618 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2619 com.liferay.portal.util.PropsUtil.get(
2620 "value.object.listener.com.liferay.portal.model.Lock")));
2621
2622 if (listenerClassNames.length > 0) {
2623 try {
2624 List<ModelListener<Lock>> listenersList = new ArrayList<ModelListener<Lock>>();
2625
2626 for (String listenerClassName : listenerClassNames) {
2627 listenersList.add((ModelListener<Lock>)InstanceFactory.newInstance(
2628 getClassLoader(), listenerClassName));
2629 }
2630
2631 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2632 }
2633 catch (Exception e) {
2634 _log.error(e);
2635 }
2636 }
2637 }
2638
2639 public void destroy() {
2640 EntityCacheUtil.removeCache(LockImpl.class.getName());
2641 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2642 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2643 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2644 }
2645
2646 private static final String _SQL_SELECT_LOCK = "SELECT lock FROM Lock lock";
2647 private static final String _SQL_SELECT_LOCK_WHERE = "SELECT lock FROM Lock lock WHERE ";
2648 private static final String _SQL_COUNT_LOCK = "SELECT COUNT(lock) FROM Lock lock";
2649 private static final String _SQL_COUNT_LOCK_WHERE = "SELECT COUNT(lock) FROM Lock lock WHERE ";
2650 private static final String _ORDER_BY_ENTITY_ALIAS = "lock.";
2651 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Lock exists with the primary key ";
2652 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Lock exists with the key {";
2653 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2654 private static Log _log = LogFactoryUtil.getLog(LockPersistenceImpl.class);
2655 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2656 "uuid", "key"
2657 });
2658 private static Lock _nullLock = new LockImpl() {
2659 @Override
2660 public Object clone() {
2661 return this;
2662 }
2663
2664 @Override
2665 public CacheModel<Lock> toCacheModel() {
2666 return _nullLockCacheModel;
2667 }
2668 };
2669
2670 private static CacheModel<Lock> _nullLockCacheModel = new CacheModel<Lock>() {
2671 @Override
2672 public Lock toEntityModel() {
2673 return _nullLock;
2674 }
2675 };
2676 }