001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.NoSuchServiceComponentException;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.Validator;
035 import com.liferay.portal.model.CacheModel;
036 import com.liferay.portal.model.MVCCModel;
037 import com.liferay.portal.model.ServiceComponent;
038 import com.liferay.portal.model.impl.ServiceComponentImpl;
039 import com.liferay.portal.model.impl.ServiceComponentModelImpl;
040 import com.liferay.portal.service.persistence.ServiceComponentPersistence;
041
042 import java.io.Serializable;
043
044 import java.util.Collections;
045 import java.util.HashMap;
046 import java.util.HashSet;
047 import java.util.Iterator;
048 import java.util.List;
049 import java.util.Map;
050 import java.util.Set;
051
052
064 @ProviderType
065 public class ServiceComponentPersistenceImpl extends BasePersistenceImpl<ServiceComponent>
066 implements ServiceComponentPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = ServiceComponentImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
078 ServiceComponentModelImpl.FINDER_CACHE_ENABLED,
079 ServiceComponentImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
080 "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
082 ServiceComponentModelImpl.FINDER_CACHE_ENABLED,
083 ServiceComponentImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
086 ServiceComponentModelImpl.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_BUILDNAMESPACE =
089 new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
090 ServiceComponentModelImpl.FINDER_CACHE_ENABLED,
091 ServiceComponentImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092 "findByBuildNamespace",
093 new String[] {
094 String.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BUILDNAMESPACE =
100 new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
101 ServiceComponentModelImpl.FINDER_CACHE_ENABLED,
102 ServiceComponentImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByBuildNamespace",
104 new String[] { String.class.getName() },
105 ServiceComponentModelImpl.BUILDNAMESPACE_COLUMN_BITMASK |
106 ServiceComponentModelImpl.BUILDNUMBER_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_BUILDNAMESPACE = new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
108 ServiceComponentModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByBuildNamespace",
110 new String[] { String.class.getName() });
111
112
118 @Override
119 public List<ServiceComponent> findByBuildNamespace(String buildNamespace) {
120 return findByBuildNamespace(buildNamespace, QueryUtil.ALL_POS,
121 QueryUtil.ALL_POS, null);
122 }
123
124
136 @Override
137 public List<ServiceComponent> findByBuildNamespace(String buildNamespace,
138 int start, int end) {
139 return findByBuildNamespace(buildNamespace, start, end, null);
140 }
141
142
155 @Override
156 public List<ServiceComponent> findByBuildNamespace(String buildNamespace,
157 int start, int end,
158 OrderByComparator<ServiceComponent> orderByComparator) {
159 boolean pagination = true;
160 FinderPath finderPath = null;
161 Object[] finderArgs = null;
162
163 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164 (orderByComparator == null)) {
165 pagination = false;
166 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BUILDNAMESPACE;
167 finderArgs = new Object[] { buildNamespace };
168 }
169 else {
170 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_BUILDNAMESPACE;
171 finderArgs = new Object[] {
172 buildNamespace,
173
174 start, end, orderByComparator
175 };
176 }
177
178 List<ServiceComponent> list = (List<ServiceComponent>)FinderCacheUtil.getResult(finderPath,
179 finderArgs, this);
180
181 if ((list != null) && !list.isEmpty()) {
182 for (ServiceComponent serviceComponent : list) {
183 if (!Validator.equals(buildNamespace,
184 serviceComponent.getBuildNamespace())) {
185 list = null;
186
187 break;
188 }
189 }
190 }
191
192 if (list == null) {
193 StringBundler query = null;
194
195 if (orderByComparator != null) {
196 query = new StringBundler(3 +
197 (orderByComparator.getOrderByFields().length * 3));
198 }
199 else {
200 query = new StringBundler(3);
201 }
202
203 query.append(_SQL_SELECT_SERVICECOMPONENT_WHERE);
204
205 boolean bindBuildNamespace = false;
206
207 if (buildNamespace == null) {
208 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_1);
209 }
210 else if (buildNamespace.equals(StringPool.BLANK)) {
211 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_3);
212 }
213 else {
214 bindBuildNamespace = true;
215
216 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_2);
217 }
218
219 if (orderByComparator != null) {
220 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
221 orderByComparator);
222 }
223 else
224 if (pagination) {
225 query.append(ServiceComponentModelImpl.ORDER_BY_JPQL);
226 }
227
228 String sql = query.toString();
229
230 Session session = null;
231
232 try {
233 session = openSession();
234
235 Query q = session.createQuery(sql);
236
237 QueryPos qPos = QueryPos.getInstance(q);
238
239 if (bindBuildNamespace) {
240 qPos.add(buildNamespace);
241 }
242
243 if (!pagination) {
244 list = (List<ServiceComponent>)QueryUtil.list(q,
245 getDialect(), start, end, false);
246
247 Collections.sort(list);
248
249 list = Collections.unmodifiableList(list);
250 }
251 else {
252 list = (List<ServiceComponent>)QueryUtil.list(q,
253 getDialect(), start, end);
254 }
255
256 cacheResult(list);
257
258 FinderCacheUtil.putResult(finderPath, finderArgs, list);
259 }
260 catch (Exception e) {
261 FinderCacheUtil.removeResult(finderPath, finderArgs);
262
263 throw processException(e);
264 }
265 finally {
266 closeSession(session);
267 }
268 }
269
270 return list;
271 }
272
273
281 @Override
282 public ServiceComponent findByBuildNamespace_First(String buildNamespace,
283 OrderByComparator<ServiceComponent> orderByComparator)
284 throws NoSuchServiceComponentException {
285 ServiceComponent serviceComponent = fetchByBuildNamespace_First(buildNamespace,
286 orderByComparator);
287
288 if (serviceComponent != null) {
289 return serviceComponent;
290 }
291
292 StringBundler msg = new StringBundler(4);
293
294 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
295
296 msg.append("buildNamespace=");
297 msg.append(buildNamespace);
298
299 msg.append(StringPool.CLOSE_CURLY_BRACE);
300
301 throw new NoSuchServiceComponentException(msg.toString());
302 }
303
304
311 @Override
312 public ServiceComponent fetchByBuildNamespace_First(String buildNamespace,
313 OrderByComparator<ServiceComponent> orderByComparator) {
314 List<ServiceComponent> list = findByBuildNamespace(buildNamespace, 0,
315 1, orderByComparator);
316
317 if (!list.isEmpty()) {
318 return list.get(0);
319 }
320
321 return null;
322 }
323
324
332 @Override
333 public ServiceComponent findByBuildNamespace_Last(String buildNamespace,
334 OrderByComparator<ServiceComponent> orderByComparator)
335 throws NoSuchServiceComponentException {
336 ServiceComponent serviceComponent = fetchByBuildNamespace_Last(buildNamespace,
337 orderByComparator);
338
339 if (serviceComponent != null) {
340 return serviceComponent;
341 }
342
343 StringBundler msg = new StringBundler(4);
344
345 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
346
347 msg.append("buildNamespace=");
348 msg.append(buildNamespace);
349
350 msg.append(StringPool.CLOSE_CURLY_BRACE);
351
352 throw new NoSuchServiceComponentException(msg.toString());
353 }
354
355
362 @Override
363 public ServiceComponent fetchByBuildNamespace_Last(String buildNamespace,
364 OrderByComparator<ServiceComponent> orderByComparator) {
365 int count = countByBuildNamespace(buildNamespace);
366
367 if (count == 0) {
368 return null;
369 }
370
371 List<ServiceComponent> list = findByBuildNamespace(buildNamespace,
372 count - 1, count, orderByComparator);
373
374 if (!list.isEmpty()) {
375 return list.get(0);
376 }
377
378 return null;
379 }
380
381
390 @Override
391 public ServiceComponent[] findByBuildNamespace_PrevAndNext(
392 long serviceComponentId, String buildNamespace,
393 OrderByComparator<ServiceComponent> orderByComparator)
394 throws NoSuchServiceComponentException {
395 ServiceComponent serviceComponent = findByPrimaryKey(serviceComponentId);
396
397 Session session = null;
398
399 try {
400 session = openSession();
401
402 ServiceComponent[] array = new ServiceComponentImpl[3];
403
404 array[0] = getByBuildNamespace_PrevAndNext(session,
405 serviceComponent, buildNamespace, orderByComparator, true);
406
407 array[1] = serviceComponent;
408
409 array[2] = getByBuildNamespace_PrevAndNext(session,
410 serviceComponent, buildNamespace, orderByComparator, false);
411
412 return array;
413 }
414 catch (Exception e) {
415 throw processException(e);
416 }
417 finally {
418 closeSession(session);
419 }
420 }
421
422 protected ServiceComponent getByBuildNamespace_PrevAndNext(
423 Session session, ServiceComponent serviceComponent,
424 String buildNamespace,
425 OrderByComparator<ServiceComponent> orderByComparator, boolean previous) {
426 StringBundler query = null;
427
428 if (orderByComparator != null) {
429 query = new StringBundler(6 +
430 (orderByComparator.getOrderByFields().length * 6));
431 }
432 else {
433 query = new StringBundler(3);
434 }
435
436 query.append(_SQL_SELECT_SERVICECOMPONENT_WHERE);
437
438 boolean bindBuildNamespace = false;
439
440 if (buildNamespace == null) {
441 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_1);
442 }
443 else if (buildNamespace.equals(StringPool.BLANK)) {
444 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_3);
445 }
446 else {
447 bindBuildNamespace = true;
448
449 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_2);
450 }
451
452 if (orderByComparator != null) {
453 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
454
455 if (orderByConditionFields.length > 0) {
456 query.append(WHERE_AND);
457 }
458
459 for (int i = 0; i < orderByConditionFields.length; i++) {
460 query.append(_ORDER_BY_ENTITY_ALIAS);
461 query.append(orderByConditionFields[i]);
462
463 if ((i + 1) < orderByConditionFields.length) {
464 if (orderByComparator.isAscending() ^ previous) {
465 query.append(WHERE_GREATER_THAN_HAS_NEXT);
466 }
467 else {
468 query.append(WHERE_LESSER_THAN_HAS_NEXT);
469 }
470 }
471 else {
472 if (orderByComparator.isAscending() ^ previous) {
473 query.append(WHERE_GREATER_THAN);
474 }
475 else {
476 query.append(WHERE_LESSER_THAN);
477 }
478 }
479 }
480
481 query.append(ORDER_BY_CLAUSE);
482
483 String[] orderByFields = orderByComparator.getOrderByFields();
484
485 for (int i = 0; i < orderByFields.length; i++) {
486 query.append(_ORDER_BY_ENTITY_ALIAS);
487 query.append(orderByFields[i]);
488
489 if ((i + 1) < orderByFields.length) {
490 if (orderByComparator.isAscending() ^ previous) {
491 query.append(ORDER_BY_ASC_HAS_NEXT);
492 }
493 else {
494 query.append(ORDER_BY_DESC_HAS_NEXT);
495 }
496 }
497 else {
498 if (orderByComparator.isAscending() ^ previous) {
499 query.append(ORDER_BY_ASC);
500 }
501 else {
502 query.append(ORDER_BY_DESC);
503 }
504 }
505 }
506 }
507 else {
508 query.append(ServiceComponentModelImpl.ORDER_BY_JPQL);
509 }
510
511 String sql = query.toString();
512
513 Query q = session.createQuery(sql);
514
515 q.setFirstResult(0);
516 q.setMaxResults(2);
517
518 QueryPos qPos = QueryPos.getInstance(q);
519
520 if (bindBuildNamespace) {
521 qPos.add(buildNamespace);
522 }
523
524 if (orderByComparator != null) {
525 Object[] values = orderByComparator.getOrderByConditionValues(serviceComponent);
526
527 for (Object value : values) {
528 qPos.add(value);
529 }
530 }
531
532 List<ServiceComponent> list = q.list();
533
534 if (list.size() == 2) {
535 return list.get(1);
536 }
537 else {
538 return null;
539 }
540 }
541
542
547 @Override
548 public void removeByBuildNamespace(String buildNamespace) {
549 for (ServiceComponent serviceComponent : findByBuildNamespace(
550 buildNamespace, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
551 remove(serviceComponent);
552 }
553 }
554
555
561 @Override
562 public int countByBuildNamespace(String buildNamespace) {
563 FinderPath finderPath = FINDER_PATH_COUNT_BY_BUILDNAMESPACE;
564
565 Object[] finderArgs = new Object[] { buildNamespace };
566
567 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
568 this);
569
570 if (count == null) {
571 StringBundler query = new StringBundler(2);
572
573 query.append(_SQL_COUNT_SERVICECOMPONENT_WHERE);
574
575 boolean bindBuildNamespace = false;
576
577 if (buildNamespace == null) {
578 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_1);
579 }
580 else if (buildNamespace.equals(StringPool.BLANK)) {
581 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_3);
582 }
583 else {
584 bindBuildNamespace = true;
585
586 query.append(_FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_2);
587 }
588
589 String sql = query.toString();
590
591 Session session = null;
592
593 try {
594 session = openSession();
595
596 Query q = session.createQuery(sql);
597
598 QueryPos qPos = QueryPos.getInstance(q);
599
600 if (bindBuildNamespace) {
601 qPos.add(buildNamespace);
602 }
603
604 count = (Long)q.uniqueResult();
605
606 FinderCacheUtil.putResult(finderPath, finderArgs, count);
607 }
608 catch (Exception e) {
609 FinderCacheUtil.removeResult(finderPath, finderArgs);
610
611 throw processException(e);
612 }
613 finally {
614 closeSession(session);
615 }
616 }
617
618 return count.intValue();
619 }
620
621 private static final String _FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_1 = "serviceComponent.buildNamespace IS NULL";
622 private static final String _FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_2 = "serviceComponent.buildNamespace = ?";
623 private static final String _FINDER_COLUMN_BUILDNAMESPACE_BUILDNAMESPACE_3 = "(serviceComponent.buildNamespace IS NULL OR serviceComponent.buildNamespace = '')";
624 public static final FinderPath FINDER_PATH_FETCH_BY_BNS_BNU = new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
625 ServiceComponentModelImpl.FINDER_CACHE_ENABLED,
626 ServiceComponentImpl.class, FINDER_CLASS_NAME_ENTITY,
627 "fetchByBNS_BNU",
628 new String[] { String.class.getName(), Long.class.getName() },
629 ServiceComponentModelImpl.BUILDNAMESPACE_COLUMN_BITMASK |
630 ServiceComponentModelImpl.BUILDNUMBER_COLUMN_BITMASK);
631 public static final FinderPath FINDER_PATH_COUNT_BY_BNS_BNU = new FinderPath(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
632 ServiceComponentModelImpl.FINDER_CACHE_ENABLED, Long.class,
633 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByBNS_BNU",
634 new String[] { String.class.getName(), Long.class.getName() });
635
636
644 @Override
645 public ServiceComponent findByBNS_BNU(String buildNamespace,
646 long buildNumber) throws NoSuchServiceComponentException {
647 ServiceComponent serviceComponent = fetchByBNS_BNU(buildNamespace,
648 buildNumber);
649
650 if (serviceComponent == null) {
651 StringBundler msg = new StringBundler(6);
652
653 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
654
655 msg.append("buildNamespace=");
656 msg.append(buildNamespace);
657
658 msg.append(", buildNumber=");
659 msg.append(buildNumber);
660
661 msg.append(StringPool.CLOSE_CURLY_BRACE);
662
663 if (_log.isWarnEnabled()) {
664 _log.warn(msg.toString());
665 }
666
667 throw new NoSuchServiceComponentException(msg.toString());
668 }
669
670 return serviceComponent;
671 }
672
673
680 @Override
681 public ServiceComponent fetchByBNS_BNU(String buildNamespace,
682 long buildNumber) {
683 return fetchByBNS_BNU(buildNamespace, buildNumber, true);
684 }
685
686
694 @Override
695 public ServiceComponent fetchByBNS_BNU(String buildNamespace,
696 long buildNumber, boolean retrieveFromCache) {
697 Object[] finderArgs = new Object[] { buildNamespace, buildNumber };
698
699 Object result = null;
700
701 if (retrieveFromCache) {
702 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_BNS_BNU,
703 finderArgs, this);
704 }
705
706 if (result instanceof ServiceComponent) {
707 ServiceComponent serviceComponent = (ServiceComponent)result;
708
709 if (!Validator.equals(buildNamespace,
710 serviceComponent.getBuildNamespace()) ||
711 (buildNumber != serviceComponent.getBuildNumber())) {
712 result = null;
713 }
714 }
715
716 if (result == null) {
717 StringBundler query = new StringBundler(4);
718
719 query.append(_SQL_SELECT_SERVICECOMPONENT_WHERE);
720
721 boolean bindBuildNamespace = false;
722
723 if (buildNamespace == null) {
724 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_1);
725 }
726 else if (buildNamespace.equals(StringPool.BLANK)) {
727 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_3);
728 }
729 else {
730 bindBuildNamespace = true;
731
732 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_2);
733 }
734
735 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNUMBER_2);
736
737 String sql = query.toString();
738
739 Session session = null;
740
741 try {
742 session = openSession();
743
744 Query q = session.createQuery(sql);
745
746 QueryPos qPos = QueryPos.getInstance(q);
747
748 if (bindBuildNamespace) {
749 qPos.add(buildNamespace);
750 }
751
752 qPos.add(buildNumber);
753
754 List<ServiceComponent> list = q.list();
755
756 if (list.isEmpty()) {
757 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_BNS_BNU,
758 finderArgs, list);
759 }
760 else {
761 ServiceComponent serviceComponent = list.get(0);
762
763 result = serviceComponent;
764
765 cacheResult(serviceComponent);
766
767 if ((serviceComponent.getBuildNamespace() == null) ||
768 !serviceComponent.getBuildNamespace()
769 .equals(buildNamespace) ||
770 (serviceComponent.getBuildNumber() != buildNumber)) {
771 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_BNS_BNU,
772 finderArgs, serviceComponent);
773 }
774 }
775 }
776 catch (Exception e) {
777 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_BNS_BNU,
778 finderArgs);
779
780 throw processException(e);
781 }
782 finally {
783 closeSession(session);
784 }
785 }
786
787 if (result instanceof List<?>) {
788 return null;
789 }
790 else {
791 return (ServiceComponent)result;
792 }
793 }
794
795
802 @Override
803 public ServiceComponent removeByBNS_BNU(String buildNamespace,
804 long buildNumber) throws NoSuchServiceComponentException {
805 ServiceComponent serviceComponent = findByBNS_BNU(buildNamespace,
806 buildNumber);
807
808 return remove(serviceComponent);
809 }
810
811
818 @Override
819 public int countByBNS_BNU(String buildNamespace, long buildNumber) {
820 FinderPath finderPath = FINDER_PATH_COUNT_BY_BNS_BNU;
821
822 Object[] finderArgs = new Object[] { buildNamespace, buildNumber };
823
824 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
825 this);
826
827 if (count == null) {
828 StringBundler query = new StringBundler(3);
829
830 query.append(_SQL_COUNT_SERVICECOMPONENT_WHERE);
831
832 boolean bindBuildNamespace = false;
833
834 if (buildNamespace == null) {
835 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_1);
836 }
837 else if (buildNamespace.equals(StringPool.BLANK)) {
838 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_3);
839 }
840 else {
841 bindBuildNamespace = true;
842
843 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_2);
844 }
845
846 query.append(_FINDER_COLUMN_BNS_BNU_BUILDNUMBER_2);
847
848 String sql = query.toString();
849
850 Session session = null;
851
852 try {
853 session = openSession();
854
855 Query q = session.createQuery(sql);
856
857 QueryPos qPos = QueryPos.getInstance(q);
858
859 if (bindBuildNamespace) {
860 qPos.add(buildNamespace);
861 }
862
863 qPos.add(buildNumber);
864
865 count = (Long)q.uniqueResult();
866
867 FinderCacheUtil.putResult(finderPath, finderArgs, count);
868 }
869 catch (Exception e) {
870 FinderCacheUtil.removeResult(finderPath, finderArgs);
871
872 throw processException(e);
873 }
874 finally {
875 closeSession(session);
876 }
877 }
878
879 return count.intValue();
880 }
881
882 private static final String _FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_1 = "serviceComponent.buildNamespace IS NULL AND ";
883 private static final String _FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_2 = "serviceComponent.buildNamespace = ? AND ";
884 private static final String _FINDER_COLUMN_BNS_BNU_BUILDNAMESPACE_3 = "(serviceComponent.buildNamespace IS NULL OR serviceComponent.buildNamespace = '') AND ";
885 private static final String _FINDER_COLUMN_BNS_BNU_BUILDNUMBER_2 = "serviceComponent.buildNumber = ?";
886
887 public ServiceComponentPersistenceImpl() {
888 setModelClass(ServiceComponent.class);
889 }
890
891
896 @Override
897 public void cacheResult(ServiceComponent serviceComponent) {
898 EntityCacheUtil.putResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
899 ServiceComponentImpl.class, serviceComponent.getPrimaryKey(),
900 serviceComponent);
901
902 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_BNS_BNU,
903 new Object[] {
904 serviceComponent.getBuildNamespace(),
905 serviceComponent.getBuildNumber()
906 }, serviceComponent);
907
908 serviceComponent.resetOriginalValues();
909 }
910
911
916 @Override
917 public void cacheResult(List<ServiceComponent> serviceComponents) {
918 for (ServiceComponent serviceComponent : serviceComponents) {
919 if (EntityCacheUtil.getResult(
920 ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
921 ServiceComponentImpl.class,
922 serviceComponent.getPrimaryKey()) == null) {
923 cacheResult(serviceComponent);
924 }
925 else {
926 serviceComponent.resetOriginalValues();
927 }
928 }
929 }
930
931
938 @Override
939 public void clearCache() {
940 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
941 CacheRegistryUtil.clear(ServiceComponentImpl.class.getName());
942 }
943
944 EntityCacheUtil.clearCache(ServiceComponentImpl.class);
945
946 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
947 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
948 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
949 }
950
951
958 @Override
959 public void clearCache(ServiceComponent serviceComponent) {
960 EntityCacheUtil.removeResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
961 ServiceComponentImpl.class, serviceComponent.getPrimaryKey());
962
963 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
964 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
965
966 clearUniqueFindersCache(serviceComponent);
967 }
968
969 @Override
970 public void clearCache(List<ServiceComponent> serviceComponents) {
971 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
972 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
973
974 for (ServiceComponent serviceComponent : serviceComponents) {
975 EntityCacheUtil.removeResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
976 ServiceComponentImpl.class, serviceComponent.getPrimaryKey());
977
978 clearUniqueFindersCache(serviceComponent);
979 }
980 }
981
982 protected void cacheUniqueFindersCache(ServiceComponent serviceComponent) {
983 if (serviceComponent.isNew()) {
984 Object[] args = new Object[] {
985 serviceComponent.getBuildNamespace(),
986 serviceComponent.getBuildNumber()
987 };
988
989 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_BNS_BNU, args,
990 Long.valueOf(1));
991 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_BNS_BNU, args,
992 serviceComponent);
993 }
994 else {
995 ServiceComponentModelImpl serviceComponentModelImpl = (ServiceComponentModelImpl)serviceComponent;
996
997 if ((serviceComponentModelImpl.getColumnBitmask() &
998 FINDER_PATH_FETCH_BY_BNS_BNU.getColumnBitmask()) != 0) {
999 Object[] args = new Object[] {
1000 serviceComponent.getBuildNamespace(),
1001 serviceComponent.getBuildNumber()
1002 };
1003
1004 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_BNS_BNU, args,
1005 Long.valueOf(1));
1006 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_BNS_BNU, args,
1007 serviceComponent);
1008 }
1009 }
1010 }
1011
1012 protected void clearUniqueFindersCache(ServiceComponent serviceComponent) {
1013 ServiceComponentModelImpl serviceComponentModelImpl = (ServiceComponentModelImpl)serviceComponent;
1014
1015 Object[] args = new Object[] {
1016 serviceComponent.getBuildNamespace(),
1017 serviceComponent.getBuildNumber()
1018 };
1019
1020 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BNS_BNU, args);
1021 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_BNS_BNU, args);
1022
1023 if ((serviceComponentModelImpl.getColumnBitmask() &
1024 FINDER_PATH_FETCH_BY_BNS_BNU.getColumnBitmask()) != 0) {
1025 args = new Object[] {
1026 serviceComponentModelImpl.getOriginalBuildNamespace(),
1027 serviceComponentModelImpl.getOriginalBuildNumber()
1028 };
1029
1030 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BNS_BNU, args);
1031 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_BNS_BNU, args);
1032 }
1033 }
1034
1035
1041 @Override
1042 public ServiceComponent create(long serviceComponentId) {
1043 ServiceComponent serviceComponent = new ServiceComponentImpl();
1044
1045 serviceComponent.setNew(true);
1046 serviceComponent.setPrimaryKey(serviceComponentId);
1047
1048 return serviceComponent;
1049 }
1050
1051
1058 @Override
1059 public ServiceComponent remove(long serviceComponentId)
1060 throws NoSuchServiceComponentException {
1061 return remove((Serializable)serviceComponentId);
1062 }
1063
1064
1071 @Override
1072 public ServiceComponent remove(Serializable primaryKey)
1073 throws NoSuchServiceComponentException {
1074 Session session = null;
1075
1076 try {
1077 session = openSession();
1078
1079 ServiceComponent serviceComponent = (ServiceComponent)session.get(ServiceComponentImpl.class,
1080 primaryKey);
1081
1082 if (serviceComponent == null) {
1083 if (_log.isWarnEnabled()) {
1084 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1085 }
1086
1087 throw new NoSuchServiceComponentException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1088 primaryKey);
1089 }
1090
1091 return remove(serviceComponent);
1092 }
1093 catch (NoSuchServiceComponentException nsee) {
1094 throw nsee;
1095 }
1096 catch (Exception e) {
1097 throw processException(e);
1098 }
1099 finally {
1100 closeSession(session);
1101 }
1102 }
1103
1104 @Override
1105 protected ServiceComponent removeImpl(ServiceComponent serviceComponent) {
1106 serviceComponent = toUnwrappedModel(serviceComponent);
1107
1108 Session session = null;
1109
1110 try {
1111 session = openSession();
1112
1113 if (!session.contains(serviceComponent)) {
1114 serviceComponent = (ServiceComponent)session.get(ServiceComponentImpl.class,
1115 serviceComponent.getPrimaryKeyObj());
1116 }
1117
1118 if (serviceComponent != null) {
1119 session.delete(serviceComponent);
1120 }
1121 }
1122 catch (Exception e) {
1123 throw processException(e);
1124 }
1125 finally {
1126 closeSession(session);
1127 }
1128
1129 if (serviceComponent != null) {
1130 clearCache(serviceComponent);
1131 }
1132
1133 return serviceComponent;
1134 }
1135
1136 @Override
1137 public ServiceComponent updateImpl(
1138 com.liferay.portal.model.ServiceComponent serviceComponent) {
1139 serviceComponent = toUnwrappedModel(serviceComponent);
1140
1141 boolean isNew = serviceComponent.isNew();
1142
1143 ServiceComponentModelImpl serviceComponentModelImpl = (ServiceComponentModelImpl)serviceComponent;
1144
1145 Session session = null;
1146
1147 try {
1148 session = openSession();
1149
1150 if (serviceComponent.isNew()) {
1151 session.save(serviceComponent);
1152
1153 serviceComponent.setNew(false);
1154 }
1155 else {
1156 session.merge(serviceComponent);
1157 }
1158 }
1159 catch (Exception e) {
1160 throw processException(e);
1161 }
1162 finally {
1163 closeSession(session);
1164 }
1165
1166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1167
1168 if (isNew || !ServiceComponentModelImpl.COLUMN_BITMASK_ENABLED) {
1169 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1170 }
1171
1172 else {
1173 if ((serviceComponentModelImpl.getColumnBitmask() &
1174 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BUILDNAMESPACE.getColumnBitmask()) != 0) {
1175 Object[] args = new Object[] {
1176 serviceComponentModelImpl.getOriginalBuildNamespace()
1177 };
1178
1179 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BUILDNAMESPACE,
1180 args);
1181 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BUILDNAMESPACE,
1182 args);
1183
1184 args = new Object[] {
1185 serviceComponentModelImpl.getBuildNamespace()
1186 };
1187
1188 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_BUILDNAMESPACE,
1189 args);
1190 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_BUILDNAMESPACE,
1191 args);
1192 }
1193 }
1194
1195 EntityCacheUtil.putResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
1196 ServiceComponentImpl.class, serviceComponent.getPrimaryKey(),
1197 serviceComponent, false);
1198
1199 clearUniqueFindersCache(serviceComponent);
1200 cacheUniqueFindersCache(serviceComponent);
1201
1202 serviceComponent.resetOriginalValues();
1203
1204 return serviceComponent;
1205 }
1206
1207 protected ServiceComponent toUnwrappedModel(
1208 ServiceComponent serviceComponent) {
1209 if (serviceComponent instanceof ServiceComponentImpl) {
1210 return serviceComponent;
1211 }
1212
1213 ServiceComponentImpl serviceComponentImpl = new ServiceComponentImpl();
1214
1215 serviceComponentImpl.setNew(serviceComponent.isNew());
1216 serviceComponentImpl.setPrimaryKey(serviceComponent.getPrimaryKey());
1217
1218 serviceComponentImpl.setMvccVersion(serviceComponent.getMvccVersion());
1219 serviceComponentImpl.setServiceComponentId(serviceComponent.getServiceComponentId());
1220 serviceComponentImpl.setBuildNamespace(serviceComponent.getBuildNamespace());
1221 serviceComponentImpl.setBuildNumber(serviceComponent.getBuildNumber());
1222 serviceComponentImpl.setBuildDate(serviceComponent.getBuildDate());
1223 serviceComponentImpl.setData(serviceComponent.getData());
1224
1225 return serviceComponentImpl;
1226 }
1227
1228
1235 @Override
1236 public ServiceComponent findByPrimaryKey(Serializable primaryKey)
1237 throws NoSuchServiceComponentException {
1238 ServiceComponent serviceComponent = fetchByPrimaryKey(primaryKey);
1239
1240 if (serviceComponent == null) {
1241 if (_log.isWarnEnabled()) {
1242 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1243 }
1244
1245 throw new NoSuchServiceComponentException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1246 primaryKey);
1247 }
1248
1249 return serviceComponent;
1250 }
1251
1252
1259 @Override
1260 public ServiceComponent findByPrimaryKey(long serviceComponentId)
1261 throws NoSuchServiceComponentException {
1262 return findByPrimaryKey((Serializable)serviceComponentId);
1263 }
1264
1265
1271 @Override
1272 public ServiceComponent fetchByPrimaryKey(Serializable primaryKey) {
1273 ServiceComponent serviceComponent = (ServiceComponent)EntityCacheUtil.getResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
1274 ServiceComponentImpl.class, primaryKey);
1275
1276 if (serviceComponent == _nullServiceComponent) {
1277 return null;
1278 }
1279
1280 if (serviceComponent == null) {
1281 Session session = null;
1282
1283 try {
1284 session = openSession();
1285
1286 serviceComponent = (ServiceComponent)session.get(ServiceComponentImpl.class,
1287 primaryKey);
1288
1289 if (serviceComponent != null) {
1290 cacheResult(serviceComponent);
1291 }
1292 else {
1293 EntityCacheUtil.putResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
1294 ServiceComponentImpl.class, primaryKey,
1295 _nullServiceComponent);
1296 }
1297 }
1298 catch (Exception e) {
1299 EntityCacheUtil.removeResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
1300 ServiceComponentImpl.class, primaryKey);
1301
1302 throw processException(e);
1303 }
1304 finally {
1305 closeSession(session);
1306 }
1307 }
1308
1309 return serviceComponent;
1310 }
1311
1312
1318 @Override
1319 public ServiceComponent fetchByPrimaryKey(long serviceComponentId) {
1320 return fetchByPrimaryKey((Serializable)serviceComponentId);
1321 }
1322
1323 @Override
1324 public Map<Serializable, ServiceComponent> fetchByPrimaryKeys(
1325 Set<Serializable> primaryKeys) {
1326 if (primaryKeys.isEmpty()) {
1327 return Collections.emptyMap();
1328 }
1329
1330 Map<Serializable, ServiceComponent> map = new HashMap<Serializable, ServiceComponent>();
1331
1332 if (primaryKeys.size() == 1) {
1333 Iterator<Serializable> iterator = primaryKeys.iterator();
1334
1335 Serializable primaryKey = iterator.next();
1336
1337 ServiceComponent serviceComponent = fetchByPrimaryKey(primaryKey);
1338
1339 if (serviceComponent != null) {
1340 map.put(primaryKey, serviceComponent);
1341 }
1342
1343 return map;
1344 }
1345
1346 Set<Serializable> uncachedPrimaryKeys = null;
1347
1348 for (Serializable primaryKey : primaryKeys) {
1349 ServiceComponent serviceComponent = (ServiceComponent)EntityCacheUtil.getResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
1350 ServiceComponentImpl.class, primaryKey);
1351
1352 if (serviceComponent == null) {
1353 if (uncachedPrimaryKeys == null) {
1354 uncachedPrimaryKeys = new HashSet<Serializable>();
1355 }
1356
1357 uncachedPrimaryKeys.add(primaryKey);
1358 }
1359 else {
1360 map.put(primaryKey, serviceComponent);
1361 }
1362 }
1363
1364 if (uncachedPrimaryKeys == null) {
1365 return map;
1366 }
1367
1368 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1369 1);
1370
1371 query.append(_SQL_SELECT_SERVICECOMPONENT_WHERE_PKS_IN);
1372
1373 for (Serializable primaryKey : uncachedPrimaryKeys) {
1374 query.append(String.valueOf(primaryKey));
1375
1376 query.append(StringPool.COMMA);
1377 }
1378
1379 query.setIndex(query.index() - 1);
1380
1381 query.append(StringPool.CLOSE_PARENTHESIS);
1382
1383 String sql = query.toString();
1384
1385 Session session = null;
1386
1387 try {
1388 session = openSession();
1389
1390 Query q = session.createQuery(sql);
1391
1392 for (ServiceComponent serviceComponent : (List<ServiceComponent>)q.list()) {
1393 map.put(serviceComponent.getPrimaryKeyObj(), serviceComponent);
1394
1395 cacheResult(serviceComponent);
1396
1397 uncachedPrimaryKeys.remove(serviceComponent.getPrimaryKeyObj());
1398 }
1399
1400 for (Serializable primaryKey : uncachedPrimaryKeys) {
1401 EntityCacheUtil.putResult(ServiceComponentModelImpl.ENTITY_CACHE_ENABLED,
1402 ServiceComponentImpl.class, primaryKey,
1403 _nullServiceComponent);
1404 }
1405 }
1406 catch (Exception e) {
1407 throw processException(e);
1408 }
1409 finally {
1410 closeSession(session);
1411 }
1412
1413 return map;
1414 }
1415
1416
1421 @Override
1422 public List<ServiceComponent> findAll() {
1423 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1424 }
1425
1426
1437 @Override
1438 public List<ServiceComponent> findAll(int start, int end) {
1439 return findAll(start, end, null);
1440 }
1441
1442
1454 @Override
1455 public List<ServiceComponent> findAll(int start, int end,
1456 OrderByComparator<ServiceComponent> orderByComparator) {
1457 boolean pagination = true;
1458 FinderPath finderPath = null;
1459 Object[] finderArgs = null;
1460
1461 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1462 (orderByComparator == null)) {
1463 pagination = false;
1464 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1465 finderArgs = FINDER_ARGS_EMPTY;
1466 }
1467 else {
1468 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1469 finderArgs = new Object[] { start, end, orderByComparator };
1470 }
1471
1472 List<ServiceComponent> list = (List<ServiceComponent>)FinderCacheUtil.getResult(finderPath,
1473 finderArgs, this);
1474
1475 if (list == null) {
1476 StringBundler query = null;
1477 String sql = null;
1478
1479 if (orderByComparator != null) {
1480 query = new StringBundler(2 +
1481 (orderByComparator.getOrderByFields().length * 3));
1482
1483 query.append(_SQL_SELECT_SERVICECOMPONENT);
1484
1485 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1486 orderByComparator);
1487
1488 sql = query.toString();
1489 }
1490 else {
1491 sql = _SQL_SELECT_SERVICECOMPONENT;
1492
1493 if (pagination) {
1494 sql = sql.concat(ServiceComponentModelImpl.ORDER_BY_JPQL);
1495 }
1496 }
1497
1498 Session session = null;
1499
1500 try {
1501 session = openSession();
1502
1503 Query q = session.createQuery(sql);
1504
1505 if (!pagination) {
1506 list = (List<ServiceComponent>)QueryUtil.list(q,
1507 getDialect(), start, end, false);
1508
1509 Collections.sort(list);
1510
1511 list = Collections.unmodifiableList(list);
1512 }
1513 else {
1514 list = (List<ServiceComponent>)QueryUtil.list(q,
1515 getDialect(), start, end);
1516 }
1517
1518 cacheResult(list);
1519
1520 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1521 }
1522 catch (Exception e) {
1523 FinderCacheUtil.removeResult(finderPath, finderArgs);
1524
1525 throw processException(e);
1526 }
1527 finally {
1528 closeSession(session);
1529 }
1530 }
1531
1532 return list;
1533 }
1534
1535
1539 @Override
1540 public void removeAll() {
1541 for (ServiceComponent serviceComponent : findAll()) {
1542 remove(serviceComponent);
1543 }
1544 }
1545
1546
1551 @Override
1552 public int countAll() {
1553 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1554 FINDER_ARGS_EMPTY, this);
1555
1556 if (count == null) {
1557 Session session = null;
1558
1559 try {
1560 session = openSession();
1561
1562 Query q = session.createQuery(_SQL_COUNT_SERVICECOMPONENT);
1563
1564 count = (Long)q.uniqueResult();
1565
1566 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1567 FINDER_ARGS_EMPTY, count);
1568 }
1569 catch (Exception e) {
1570 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1571 FINDER_ARGS_EMPTY);
1572
1573 throw processException(e);
1574 }
1575 finally {
1576 closeSession(session);
1577 }
1578 }
1579
1580 return count.intValue();
1581 }
1582
1583 @Override
1584 protected Set<String> getBadColumnNames() {
1585 return _badColumnNames;
1586 }
1587
1588
1591 public void afterPropertiesSet() {
1592 }
1593
1594 public void destroy() {
1595 EntityCacheUtil.removeCache(ServiceComponentImpl.class.getName());
1596 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1597 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1598 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1599 }
1600
1601 private static final String _SQL_SELECT_SERVICECOMPONENT = "SELECT serviceComponent FROM ServiceComponent serviceComponent";
1602 private static final String _SQL_SELECT_SERVICECOMPONENT_WHERE_PKS_IN = "SELECT serviceComponent FROM ServiceComponent serviceComponent WHERE serviceComponentId IN (";
1603 private static final String _SQL_SELECT_SERVICECOMPONENT_WHERE = "SELECT serviceComponent FROM ServiceComponent serviceComponent WHERE ";
1604 private static final String _SQL_COUNT_SERVICECOMPONENT = "SELECT COUNT(serviceComponent) FROM ServiceComponent serviceComponent";
1605 private static final String _SQL_COUNT_SERVICECOMPONENT_WHERE = "SELECT COUNT(serviceComponent) FROM ServiceComponent serviceComponent WHERE ";
1606 private static final String _ORDER_BY_ENTITY_ALIAS = "serviceComponent.";
1607 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ServiceComponent exists with the primary key ";
1608 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ServiceComponent exists with the key {";
1609 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1610 private static final Log _log = LogFactoryUtil.getLog(ServiceComponentPersistenceImpl.class);
1611 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1612 "data"
1613 });
1614 private static final ServiceComponent _nullServiceComponent = new ServiceComponentImpl() {
1615 @Override
1616 public Object clone() {
1617 return this;
1618 }
1619
1620 @Override
1621 public CacheModel<ServiceComponent> toCacheModel() {
1622 return _nullServiceComponentCacheModel;
1623 }
1624 };
1625
1626 private static final CacheModel<ServiceComponent> _nullServiceComponentCacheModel =
1627 new NullCacheModel();
1628
1629 private static class NullCacheModel implements CacheModel<ServiceComponent>,
1630 MVCCModel {
1631 @Override
1632 public long getMvccVersion() {
1633 return -1;
1634 }
1635
1636 @Override
1637 public void setMvccVersion(long mvccVersion) {
1638 }
1639
1640 @Override
1641 public ServiceComponent toEntityModel() {
1642 return _nullServiceComponent;
1643 }
1644 }
1645 }