001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchShardException;
019 import com.liferay.portal.kernel.annotation.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
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.Validator;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.Shard;
040 import com.liferay.portal.model.impl.ShardImpl;
041 import com.liferay.portal.model.impl.ShardModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
066 public class ShardPersistenceImpl extends BasePersistenceImpl<Shard>
067 implements ShardPersistence {
068 public static final String FINDER_CLASS_NAME_ENTITY = ShardImpl.class.getName();
069 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
070 ".List";
071 public static final FinderPath FINDER_PATH_FETCH_BY_NAME = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
072 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
073 "fetchByName", new String[] { String.class.getName() });
074 public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
075 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
076 "countByName", new String[] { String.class.getName() });
077 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
078 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
079 "fetchByC_C",
080 new String[] { Long.class.getName(), Long.class.getName() });
081 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
082 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
083 "countByC_C",
084 new String[] { Long.class.getName(), Long.class.getName() });
085 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
086 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
087 "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
089 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
090 "countAll", new String[0]);
091
092
097 public void cacheResult(Shard shard) {
098 EntityCacheUtil.putResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
099 ShardImpl.class, shard.getPrimaryKey(), shard);
100
101 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
102 new Object[] { shard.getName() }, shard);
103
104 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
105 new Object[] {
106 new Long(shard.getClassNameId()), new Long(shard.getClassPK())
107 }, shard);
108 }
109
110
115 public void cacheResult(List<Shard> shards) {
116 for (Shard shard : shards) {
117 if (EntityCacheUtil.getResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
118 ShardImpl.class, shard.getPrimaryKey(), this) == null) {
119 cacheResult(shard);
120 }
121 }
122 }
123
124
131 public void clearCache() {
132 CacheRegistryUtil.clear(ShardImpl.class.getName());
133 EntityCacheUtil.clearCache(ShardImpl.class.getName());
134 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
135 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
136 }
137
138
145 public void clearCache(Shard shard) {
146 EntityCacheUtil.removeResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
147 ShardImpl.class, shard.getPrimaryKey());
148
149 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
150 new Object[] { shard.getName() });
151
152 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
153 new Object[] {
154 new Long(shard.getClassNameId()), new Long(shard.getClassPK())
155 });
156 }
157
158
164 public Shard create(long shardId) {
165 Shard shard = new ShardImpl();
166
167 shard.setNew(true);
168 shard.setPrimaryKey(shardId);
169
170 return shard;
171 }
172
173
181 public Shard remove(Serializable primaryKey)
182 throws NoSuchModelException, SystemException {
183 return remove(((Long)primaryKey).longValue());
184 }
185
186
194 public Shard remove(long shardId)
195 throws NoSuchShardException, SystemException {
196 Session session = null;
197
198 try {
199 session = openSession();
200
201 Shard shard = (Shard)session.get(ShardImpl.class, new Long(shardId));
202
203 if (shard == null) {
204 if (_log.isWarnEnabled()) {
205 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + shardId);
206 }
207
208 throw new NoSuchShardException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
209 shardId);
210 }
211
212 return remove(shard);
213 }
214 catch (NoSuchShardException nsee) {
215 throw nsee;
216 }
217 catch (Exception e) {
218 throw processException(e);
219 }
220 finally {
221 closeSession(session);
222 }
223 }
224
225 protected Shard removeImpl(Shard shard) throws SystemException {
226 shard = toUnwrappedModel(shard);
227
228 Session session = null;
229
230 try {
231 session = openSession();
232
233 if (shard.isCachedModel() || BatchSessionUtil.isEnabled()) {
234 Object staleObject = session.get(ShardImpl.class,
235 shard.getPrimaryKeyObj());
236
237 if (staleObject != null) {
238 session.evict(staleObject);
239 }
240 }
241
242 session.delete(shard);
243
244 session.flush();
245 }
246 catch (Exception e) {
247 throw processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252
253 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
254
255 ShardModelImpl shardModelImpl = (ShardModelImpl)shard;
256
257 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
258 new Object[] { shardModelImpl.getOriginalName() });
259
260 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
261 new Object[] {
262 new Long(shardModelImpl.getOriginalClassNameId()),
263 new Long(shardModelImpl.getOriginalClassPK())
264 });
265
266 EntityCacheUtil.removeResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
267 ShardImpl.class, shard.getPrimaryKey());
268
269 return shard;
270 }
271
272 public Shard updateImpl(com.liferay.portal.model.Shard shard, boolean merge)
273 throws SystemException {
274 shard = toUnwrappedModel(shard);
275
276 boolean isNew = shard.isNew();
277
278 ShardModelImpl shardModelImpl = (ShardModelImpl)shard;
279
280 Session session = null;
281
282 try {
283 session = openSession();
284
285 BatchSessionUtil.update(session, shard, merge);
286
287 shard.setNew(false);
288 }
289 catch (Exception e) {
290 throw processException(e);
291 }
292 finally {
293 closeSession(session);
294 }
295
296 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
297
298 EntityCacheUtil.putResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
299 ShardImpl.class, shard.getPrimaryKey(), shard);
300
301 if (!isNew &&
302 (!Validator.equals(shard.getName(),
303 shardModelImpl.getOriginalName()))) {
304 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
305 new Object[] { shardModelImpl.getOriginalName() });
306 }
307
308 if (isNew ||
309 (!Validator.equals(shard.getName(),
310 shardModelImpl.getOriginalName()))) {
311 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
312 new Object[] { shard.getName() }, shard);
313 }
314
315 if (!isNew &&
316 ((shard.getClassNameId() != shardModelImpl.getOriginalClassNameId()) ||
317 (shard.getClassPK() != shardModelImpl.getOriginalClassPK()))) {
318 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
319 new Object[] {
320 new Long(shardModelImpl.getOriginalClassNameId()),
321 new Long(shardModelImpl.getOriginalClassPK())
322 });
323 }
324
325 if (isNew ||
326 ((shard.getClassNameId() != shardModelImpl.getOriginalClassNameId()) ||
327 (shard.getClassPK() != shardModelImpl.getOriginalClassPK()))) {
328 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
329 new Object[] {
330 new Long(shard.getClassNameId()),
331 new Long(shard.getClassPK())
332 }, shard);
333 }
334
335 return shard;
336 }
337
338 protected Shard toUnwrappedModel(Shard shard) {
339 if (shard instanceof ShardImpl) {
340 return shard;
341 }
342
343 ShardImpl shardImpl = new ShardImpl();
344
345 shardImpl.setNew(shard.isNew());
346 shardImpl.setPrimaryKey(shard.getPrimaryKey());
347
348 shardImpl.setShardId(shard.getShardId());
349 shardImpl.setClassNameId(shard.getClassNameId());
350 shardImpl.setClassPK(shard.getClassPK());
351 shardImpl.setName(shard.getName());
352
353 return shardImpl;
354 }
355
356
364 public Shard findByPrimaryKey(Serializable primaryKey)
365 throws NoSuchModelException, SystemException {
366 return findByPrimaryKey(((Long)primaryKey).longValue());
367 }
368
369
377 public Shard findByPrimaryKey(long shardId)
378 throws NoSuchShardException, SystemException {
379 Shard shard = fetchByPrimaryKey(shardId);
380
381 if (shard == null) {
382 if (_log.isWarnEnabled()) {
383 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + shardId);
384 }
385
386 throw new NoSuchShardException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
387 shardId);
388 }
389
390 return shard;
391 }
392
393
400 public Shard fetchByPrimaryKey(Serializable primaryKey)
401 throws SystemException {
402 return fetchByPrimaryKey(((Long)primaryKey).longValue());
403 }
404
405
412 public Shard fetchByPrimaryKey(long shardId) throws SystemException {
413 Shard shard = (Shard)EntityCacheUtil.getResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
414 ShardImpl.class, shardId, this);
415
416 if (shard == null) {
417 Session session = null;
418
419 try {
420 session = openSession();
421
422 shard = (Shard)session.get(ShardImpl.class, new Long(shardId));
423 }
424 catch (Exception e) {
425 throw processException(e);
426 }
427 finally {
428 if (shard != null) {
429 cacheResult(shard);
430 }
431
432 closeSession(session);
433 }
434 }
435
436 return shard;
437 }
438
439
447 public Shard findByName(String name)
448 throws NoSuchShardException, SystemException {
449 Shard shard = fetchByName(name);
450
451 if (shard == null) {
452 StringBundler msg = new StringBundler(4);
453
454 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
455
456 msg.append("name=");
457 msg.append(name);
458
459 msg.append(StringPool.CLOSE_CURLY_BRACE);
460
461 if (_log.isWarnEnabled()) {
462 _log.warn(msg.toString());
463 }
464
465 throw new NoSuchShardException(msg.toString());
466 }
467
468 return shard;
469 }
470
471
478 public Shard fetchByName(String name) throws SystemException {
479 return fetchByName(name, true);
480 }
481
482
489 public Shard fetchByName(String name, boolean retrieveFromCache)
490 throws SystemException {
491 Object[] finderArgs = new Object[] { name };
492
493 Object result = null;
494
495 if (retrieveFromCache) {
496 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_NAME,
497 finderArgs, this);
498 }
499
500 if (result == null) {
501 Session session = null;
502
503 try {
504 session = openSession();
505
506 StringBundler query = new StringBundler(2);
507
508 query.append(_SQL_SELECT_SHARD_WHERE);
509
510 if (name == null) {
511 query.append(_FINDER_COLUMN_NAME_NAME_1);
512 }
513 else {
514 if (name.equals(StringPool.BLANK)) {
515 query.append(_FINDER_COLUMN_NAME_NAME_3);
516 }
517 else {
518 query.append(_FINDER_COLUMN_NAME_NAME_2);
519 }
520 }
521
522 String sql = query.toString();
523
524 Query q = session.createQuery(sql);
525
526 QueryPos qPos = QueryPos.getInstance(q);
527
528 if (name != null) {
529 qPos.add(name);
530 }
531
532 List<Shard> list = q.list();
533
534 result = list;
535
536 Shard shard = null;
537
538 if (list.isEmpty()) {
539 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
540 finderArgs, list);
541 }
542 else {
543 shard = list.get(0);
544
545 cacheResult(shard);
546
547 if ((shard.getName() == null) ||
548 !shard.getName().equals(name)) {
549 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
550 finderArgs, shard);
551 }
552 }
553
554 return shard;
555 }
556 catch (Exception e) {
557 throw processException(e);
558 }
559 finally {
560 if (result == null) {
561 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
562 finderArgs, new ArrayList<Shard>());
563 }
564
565 closeSession(session);
566 }
567 }
568 else {
569 if (result instanceof List<?>) {
570 return null;
571 }
572 else {
573 return (Shard)result;
574 }
575 }
576 }
577
578
587 public Shard findByC_C(long classNameId, long classPK)
588 throws NoSuchShardException, SystemException {
589 Shard shard = fetchByC_C(classNameId, classPK);
590
591 if (shard == null) {
592 StringBundler msg = new StringBundler(6);
593
594 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
595
596 msg.append("classNameId=");
597 msg.append(classNameId);
598
599 msg.append(", classPK=");
600 msg.append(classPK);
601
602 msg.append(StringPool.CLOSE_CURLY_BRACE);
603
604 if (_log.isWarnEnabled()) {
605 _log.warn(msg.toString());
606 }
607
608 throw new NoSuchShardException(msg.toString());
609 }
610
611 return shard;
612 }
613
614
622 public Shard fetchByC_C(long classNameId, long classPK)
623 throws SystemException {
624 return fetchByC_C(classNameId, classPK, true);
625 }
626
627
635 public Shard fetchByC_C(long classNameId, long classPK,
636 boolean retrieveFromCache) throws SystemException {
637 Object[] finderArgs = new Object[] { classNameId, classPK };
638
639 Object result = null;
640
641 if (retrieveFromCache) {
642 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
643 finderArgs, this);
644 }
645
646 if (result == null) {
647 Session session = null;
648
649 try {
650 session = openSession();
651
652 StringBundler query = new StringBundler(3);
653
654 query.append(_SQL_SELECT_SHARD_WHERE);
655
656 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
657
658 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
659
660 String sql = query.toString();
661
662 Query q = session.createQuery(sql);
663
664 QueryPos qPos = QueryPos.getInstance(q);
665
666 qPos.add(classNameId);
667
668 qPos.add(classPK);
669
670 List<Shard> list = q.list();
671
672 result = list;
673
674 Shard shard = null;
675
676 if (list.isEmpty()) {
677 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
678 finderArgs, list);
679 }
680 else {
681 shard = list.get(0);
682
683 cacheResult(shard);
684
685 if ((shard.getClassNameId() != classNameId) ||
686 (shard.getClassPK() != classPK)) {
687 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
688 finderArgs, shard);
689 }
690 }
691
692 return shard;
693 }
694 catch (Exception e) {
695 throw processException(e);
696 }
697 finally {
698 if (result == null) {
699 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
700 finderArgs, new ArrayList<Shard>());
701 }
702
703 closeSession(session);
704 }
705 }
706 else {
707 if (result instanceof List<?>) {
708 return null;
709 }
710 else {
711 return (Shard)result;
712 }
713 }
714 }
715
716
722 public List<Shard> findAll() throws SystemException {
723 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
724 }
725
726
738 public List<Shard> findAll(int start, int end) throws SystemException {
739 return findAll(start, end, null);
740 }
741
742
755 public List<Shard> findAll(int start, int end,
756 OrderByComparator orderByComparator) throws SystemException {
757 Object[] finderArgs = new Object[] {
758 String.valueOf(start), String.valueOf(end),
759 String.valueOf(orderByComparator)
760 };
761
762 List<Shard> list = (List<Shard>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
763 finderArgs, this);
764
765 if (list == null) {
766 Session session = null;
767
768 try {
769 session = openSession();
770
771 StringBundler query = null;
772 String sql = null;
773
774 if (orderByComparator != null) {
775 query = new StringBundler(2 +
776 (orderByComparator.getOrderByFields().length * 3));
777
778 query.append(_SQL_SELECT_SHARD);
779
780 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
781 orderByComparator);
782
783 sql = query.toString();
784 }
785 else {
786 sql = _SQL_SELECT_SHARD;
787 }
788
789 Query q = session.createQuery(sql);
790
791 if (orderByComparator == null) {
792 list = (List<Shard>)QueryUtil.list(q, getDialect(), start,
793 end, false);
794
795 Collections.sort(list);
796 }
797 else {
798 list = (List<Shard>)QueryUtil.list(q, getDialect(), start,
799 end);
800 }
801 }
802 catch (Exception e) {
803 throw processException(e);
804 }
805 finally {
806 if (list == null) {
807 list = new ArrayList<Shard>();
808 }
809
810 cacheResult(list);
811
812 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
813
814 closeSession(session);
815 }
816 }
817
818 return list;
819 }
820
821
827 public void removeByName(String name)
828 throws NoSuchShardException, SystemException {
829 Shard shard = findByName(name);
830
831 remove(shard);
832 }
833
834
841 public void removeByC_C(long classNameId, long classPK)
842 throws NoSuchShardException, SystemException {
843 Shard shard = findByC_C(classNameId, classPK);
844
845 remove(shard);
846 }
847
848
853 public void removeAll() throws SystemException {
854 for (Shard shard : findAll()) {
855 remove(shard);
856 }
857 }
858
859
866 public int countByName(String name) throws SystemException {
867 Object[] finderArgs = new Object[] { name };
868
869 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
870 finderArgs, this);
871
872 if (count == null) {
873 Session session = null;
874
875 try {
876 session = openSession();
877
878 StringBundler query = new StringBundler(2);
879
880 query.append(_SQL_COUNT_SHARD_WHERE);
881
882 if (name == null) {
883 query.append(_FINDER_COLUMN_NAME_NAME_1);
884 }
885 else {
886 if (name.equals(StringPool.BLANK)) {
887 query.append(_FINDER_COLUMN_NAME_NAME_3);
888 }
889 else {
890 query.append(_FINDER_COLUMN_NAME_NAME_2);
891 }
892 }
893
894 String sql = query.toString();
895
896 Query q = session.createQuery(sql);
897
898 QueryPos qPos = QueryPos.getInstance(q);
899
900 if (name != null) {
901 qPos.add(name);
902 }
903
904 count = (Long)q.uniqueResult();
905 }
906 catch (Exception e) {
907 throw processException(e);
908 }
909 finally {
910 if (count == null) {
911 count = Long.valueOf(0);
912 }
913
914 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
915 finderArgs, count);
916
917 closeSession(session);
918 }
919 }
920
921 return count.intValue();
922 }
923
924
932 public int countByC_C(long classNameId, long classPK)
933 throws SystemException {
934 Object[] finderArgs = new Object[] { classNameId, classPK };
935
936 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
937 finderArgs, this);
938
939 if (count == null) {
940 Session session = null;
941
942 try {
943 session = openSession();
944
945 StringBundler query = new StringBundler(3);
946
947 query.append(_SQL_COUNT_SHARD_WHERE);
948
949 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
950
951 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
952
953 String sql = query.toString();
954
955 Query q = session.createQuery(sql);
956
957 QueryPos qPos = QueryPos.getInstance(q);
958
959 qPos.add(classNameId);
960
961 qPos.add(classPK);
962
963 count = (Long)q.uniqueResult();
964 }
965 catch (Exception e) {
966 throw processException(e);
967 }
968 finally {
969 if (count == null) {
970 count = Long.valueOf(0);
971 }
972
973 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
974 count);
975
976 closeSession(session);
977 }
978 }
979
980 return count.intValue();
981 }
982
983
989 public int countAll() throws SystemException {
990 Object[] finderArgs = new Object[0];
991
992 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
993 finderArgs, this);
994
995 if (count == null) {
996 Session session = null;
997
998 try {
999 session = openSession();
1000
1001 Query q = session.createQuery(_SQL_COUNT_SHARD);
1002
1003 count = (Long)q.uniqueResult();
1004 }
1005 catch (Exception e) {
1006 throw processException(e);
1007 }
1008 finally {
1009 if (count == null) {
1010 count = Long.valueOf(0);
1011 }
1012
1013 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1014 count);
1015
1016 closeSession(session);
1017 }
1018 }
1019
1020 return count.intValue();
1021 }
1022
1023
1026 public void afterPropertiesSet() {
1027 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1028 com.liferay.portal.util.PropsUtil.get(
1029 "value.object.listener.com.liferay.portal.model.Shard")));
1030
1031 if (listenerClassNames.length > 0) {
1032 try {
1033 List<ModelListener<Shard>> listenersList = new ArrayList<ModelListener<Shard>>();
1034
1035 for (String listenerClassName : listenerClassNames) {
1036 listenersList.add((ModelListener<Shard>)InstanceFactory.newInstance(
1037 listenerClassName));
1038 }
1039
1040 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1041 }
1042 catch (Exception e) {
1043 _log.error(e);
1044 }
1045 }
1046 }
1047
1048 @BeanReference(type = AccountPersistence.class)
1049 protected AccountPersistence accountPersistence;
1050 @BeanReference(type = AddressPersistence.class)
1051 protected AddressPersistence addressPersistence;
1052 @BeanReference(type = BrowserTrackerPersistence.class)
1053 protected BrowserTrackerPersistence browserTrackerPersistence;
1054 @BeanReference(type = ClassNamePersistence.class)
1055 protected ClassNamePersistence classNamePersistence;
1056 @BeanReference(type = ClusterGroupPersistence.class)
1057 protected ClusterGroupPersistence clusterGroupPersistence;
1058 @BeanReference(type = CompanyPersistence.class)
1059 protected CompanyPersistence companyPersistence;
1060 @BeanReference(type = ContactPersistence.class)
1061 protected ContactPersistence contactPersistence;
1062 @BeanReference(type = CountryPersistence.class)
1063 protected CountryPersistence countryPersistence;
1064 @BeanReference(type = EmailAddressPersistence.class)
1065 protected EmailAddressPersistence emailAddressPersistence;
1066 @BeanReference(type = GroupPersistence.class)
1067 protected GroupPersistence groupPersistence;
1068 @BeanReference(type = ImagePersistence.class)
1069 protected ImagePersistence imagePersistence;
1070 @BeanReference(type = LayoutPersistence.class)
1071 protected LayoutPersistence layoutPersistence;
1072 @BeanReference(type = LayoutPrototypePersistence.class)
1073 protected LayoutPrototypePersistence layoutPrototypePersistence;
1074 @BeanReference(type = LayoutSetPersistence.class)
1075 protected LayoutSetPersistence layoutSetPersistence;
1076 @BeanReference(type = LayoutSetPrototypePersistence.class)
1077 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1078 @BeanReference(type = ListTypePersistence.class)
1079 protected ListTypePersistence listTypePersistence;
1080 @BeanReference(type = LockPersistence.class)
1081 protected LockPersistence lockPersistence;
1082 @BeanReference(type = MembershipRequestPersistence.class)
1083 protected MembershipRequestPersistence membershipRequestPersistence;
1084 @BeanReference(type = OrganizationPersistence.class)
1085 protected OrganizationPersistence organizationPersistence;
1086 @BeanReference(type = OrgGroupPermissionPersistence.class)
1087 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1088 @BeanReference(type = OrgGroupRolePersistence.class)
1089 protected OrgGroupRolePersistence orgGroupRolePersistence;
1090 @BeanReference(type = OrgLaborPersistence.class)
1091 protected OrgLaborPersistence orgLaborPersistence;
1092 @BeanReference(type = PasswordPolicyPersistence.class)
1093 protected PasswordPolicyPersistence passwordPolicyPersistence;
1094 @BeanReference(type = PasswordPolicyRelPersistence.class)
1095 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1096 @BeanReference(type = PasswordTrackerPersistence.class)
1097 protected PasswordTrackerPersistence passwordTrackerPersistence;
1098 @BeanReference(type = PermissionPersistence.class)
1099 protected PermissionPersistence permissionPersistence;
1100 @BeanReference(type = PhonePersistence.class)
1101 protected PhonePersistence phonePersistence;
1102 @BeanReference(type = PluginSettingPersistence.class)
1103 protected PluginSettingPersistence pluginSettingPersistence;
1104 @BeanReference(type = PortletPersistence.class)
1105 protected PortletPersistence portletPersistence;
1106 @BeanReference(type = PortletItemPersistence.class)
1107 protected PortletItemPersistence portletItemPersistence;
1108 @BeanReference(type = PortletPreferencesPersistence.class)
1109 protected PortletPreferencesPersistence portletPreferencesPersistence;
1110 @BeanReference(type = RegionPersistence.class)
1111 protected RegionPersistence regionPersistence;
1112 @BeanReference(type = ReleasePersistence.class)
1113 protected ReleasePersistence releasePersistence;
1114 @BeanReference(type = ResourcePersistence.class)
1115 protected ResourcePersistence resourcePersistence;
1116 @BeanReference(type = ResourceActionPersistence.class)
1117 protected ResourceActionPersistence resourceActionPersistence;
1118 @BeanReference(type = ResourceCodePersistence.class)
1119 protected ResourceCodePersistence resourceCodePersistence;
1120 @BeanReference(type = ResourcePermissionPersistence.class)
1121 protected ResourcePermissionPersistence resourcePermissionPersistence;
1122 @BeanReference(type = RolePersistence.class)
1123 protected RolePersistence rolePersistence;
1124 @BeanReference(type = ServiceComponentPersistence.class)
1125 protected ServiceComponentPersistence serviceComponentPersistence;
1126 @BeanReference(type = ShardPersistence.class)
1127 protected ShardPersistence shardPersistence;
1128 @BeanReference(type = SubscriptionPersistence.class)
1129 protected SubscriptionPersistence subscriptionPersistence;
1130 @BeanReference(type = TicketPersistence.class)
1131 protected TicketPersistence ticketPersistence;
1132 @BeanReference(type = TeamPersistence.class)
1133 protected TeamPersistence teamPersistence;
1134 @BeanReference(type = UserPersistence.class)
1135 protected UserPersistence userPersistence;
1136 @BeanReference(type = UserGroupPersistence.class)
1137 protected UserGroupPersistence userGroupPersistence;
1138 @BeanReference(type = UserGroupGroupRolePersistence.class)
1139 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1140 @BeanReference(type = UserGroupRolePersistence.class)
1141 protected UserGroupRolePersistence userGroupRolePersistence;
1142 @BeanReference(type = UserIdMapperPersistence.class)
1143 protected UserIdMapperPersistence userIdMapperPersistence;
1144 @BeanReference(type = UserTrackerPersistence.class)
1145 protected UserTrackerPersistence userTrackerPersistence;
1146 @BeanReference(type = UserTrackerPathPersistence.class)
1147 protected UserTrackerPathPersistence userTrackerPathPersistence;
1148 @BeanReference(type = WebDAVPropsPersistence.class)
1149 protected WebDAVPropsPersistence webDAVPropsPersistence;
1150 @BeanReference(type = WebsitePersistence.class)
1151 protected WebsitePersistence websitePersistence;
1152 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1153 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1154 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1155 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1156 private static final String _SQL_SELECT_SHARD = "SELECT shard FROM Shard shard";
1157 private static final String _SQL_SELECT_SHARD_WHERE = "SELECT shard FROM Shard shard WHERE ";
1158 private static final String _SQL_COUNT_SHARD = "SELECT COUNT(shard) FROM Shard shard";
1159 private static final String _SQL_COUNT_SHARD_WHERE = "SELECT COUNT(shard) FROM Shard shard WHERE ";
1160 private static final String _FINDER_COLUMN_NAME_NAME_1 = "shard.name IS NULL";
1161 private static final String _FINDER_COLUMN_NAME_NAME_2 = "shard.name = ?";
1162 private static final String _FINDER_COLUMN_NAME_NAME_3 = "(shard.name IS NULL OR shard.name = ?)";
1163 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "shard.classNameId = ? AND ";
1164 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "shard.classPK = ?";
1165 private static final String _ORDER_BY_ENTITY_ALIAS = "shard.";
1166 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Shard exists with the primary key ";
1167 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Shard exists with the key {";
1168 private static Log _log = LogFactoryUtil.getLog(ShardPersistenceImpl.class);
1169 }