1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchShardException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringPool;
42 import com.liferay.portal.kernel.util.StringUtil;
43 import com.liferay.portal.kernel.util.Validator;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.model.Shard;
46 import com.liferay.portal.model.impl.ShardImpl;
47 import com.liferay.portal.model.impl.ShardModelImpl;
48 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.List;
53
54
67 public class ShardPersistenceImpl extends BasePersistenceImpl
68 implements ShardPersistence {
69 public static final String FINDER_CLASS_NAME_ENTITY = ShardImpl.class.getName();
70 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
71 ".List";
72 public static final FinderPath FINDER_PATH_FETCH_BY_NAME = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
73 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
74 "fetchByName", new String[] { String.class.getName() });
75 public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
76 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
77 "countByName", new String[] { String.class.getName() });
78 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
79 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
80 "fetchByC_C",
81 new String[] { Long.class.getName(), Long.class.getName() });
82 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
83 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84 "countByC_C",
85 new String[] { Long.class.getName(), Long.class.getName() });
86 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
87 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
88 "findAll", new String[0]);
89 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
90 ShardModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91 "countAll", new String[0]);
92
93 public void cacheResult(Shard shard) {
94 EntityCacheUtil.putResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
95 ShardImpl.class, shard.getPrimaryKey(), shard);
96
97 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
98 new Object[] { shard.getName() }, shard);
99
100 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
101 new Object[] {
102 new Long(shard.getClassNameId()), new Long(shard.getClassPK())
103 }, shard);
104 }
105
106 public void cacheResult(List<Shard> shards) {
107 for (Shard shard : shards) {
108 if (EntityCacheUtil.getResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
109 ShardImpl.class, shard.getPrimaryKey(), this) == null) {
110 cacheResult(shard);
111 }
112 }
113 }
114
115 public void clearCache() {
116 CacheRegistry.clear(ShardImpl.class.getName());
117 EntityCacheUtil.clearCache(ShardImpl.class.getName());
118 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
119 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
120 }
121
122 public Shard create(long shardId) {
123 Shard shard = new ShardImpl();
124
125 shard.setNew(true);
126 shard.setPrimaryKey(shardId);
127
128 return shard;
129 }
130
131 public Shard remove(long shardId)
132 throws NoSuchShardException, SystemException {
133 Session session = null;
134
135 try {
136 session = openSession();
137
138 Shard shard = (Shard)session.get(ShardImpl.class, new Long(shardId));
139
140 if (shard == null) {
141 if (_log.isWarnEnabled()) {
142 _log.warn("No Shard exists with the primary key " +
143 shardId);
144 }
145
146 throw new NoSuchShardException(
147 "No Shard exists with the primary key " + shardId);
148 }
149
150 return remove(shard);
151 }
152 catch (NoSuchShardException nsee) {
153 throw nsee;
154 }
155 catch (Exception e) {
156 throw processException(e);
157 }
158 finally {
159 closeSession(session);
160 }
161 }
162
163 public Shard remove(Shard shard) throws SystemException {
164 for (ModelListener<Shard> listener : listeners) {
165 listener.onBeforeRemove(shard);
166 }
167
168 shard = removeImpl(shard);
169
170 for (ModelListener<Shard> listener : listeners) {
171 listener.onAfterRemove(shard);
172 }
173
174 return shard;
175 }
176
177 protected Shard removeImpl(Shard shard) throws SystemException {
178 shard = toUnwrappedModel(shard);
179
180 Session session = null;
181
182 try {
183 session = openSession();
184
185 if (shard.isCachedModel() || BatchSessionUtil.isEnabled()) {
186 Object staleObject = session.get(ShardImpl.class,
187 shard.getPrimaryKeyObj());
188
189 if (staleObject != null) {
190 session.evict(staleObject);
191 }
192 }
193
194 session.delete(shard);
195
196 session.flush();
197 }
198 catch (Exception e) {
199 throw processException(e);
200 }
201 finally {
202 closeSession(session);
203 }
204
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
206
207 ShardModelImpl shardModelImpl = (ShardModelImpl)shard;
208
209 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
210 new Object[] { shardModelImpl.getOriginalName() });
211
212 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
213 new Object[] {
214 new Long(shardModelImpl.getOriginalClassNameId()),
215 new Long(shardModelImpl.getOriginalClassPK())
216 });
217
218 EntityCacheUtil.removeResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
219 ShardImpl.class, shard.getPrimaryKey());
220
221 return shard;
222 }
223
224
227 public Shard update(Shard shard) throws SystemException {
228 if (_log.isWarnEnabled()) {
229 _log.warn(
230 "Using the deprecated update(Shard shard) method. Use update(Shard shard, boolean merge) instead.");
231 }
232
233 return update(shard, false);
234 }
235
236
248 public Shard update(Shard shard, boolean merge) throws SystemException {
249 boolean isNew = shard.isNew();
250
251 for (ModelListener<Shard> listener : listeners) {
252 if (isNew) {
253 listener.onBeforeCreate(shard);
254 }
255 else {
256 listener.onBeforeUpdate(shard);
257 }
258 }
259
260 shard = updateImpl(shard, merge);
261
262 for (ModelListener<Shard> listener : listeners) {
263 if (isNew) {
264 listener.onAfterCreate(shard);
265 }
266 else {
267 listener.onAfterUpdate(shard);
268 }
269 }
270
271 return shard;
272 }
273
274 public Shard updateImpl(com.liferay.portal.model.Shard shard, boolean merge)
275 throws SystemException {
276 shard = toUnwrappedModel(shard);
277
278 boolean isNew = shard.isNew();
279
280 ShardModelImpl shardModelImpl = (ShardModelImpl)shard;
281
282 Session session = null;
283
284 try {
285 session = openSession();
286
287 BatchSessionUtil.update(session, shard, merge);
288
289 shard.setNew(false);
290 }
291 catch (Exception e) {
292 throw processException(e);
293 }
294 finally {
295 closeSession(session);
296 }
297
298 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
299
300 EntityCacheUtil.putResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
301 ShardImpl.class, shard.getPrimaryKey(), shard);
302
303 if (!isNew &&
304 (!Validator.equals(shard.getName(),
305 shardModelImpl.getOriginalName()))) {
306 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
307 new Object[] { shardModelImpl.getOriginalName() });
308 }
309
310 if (isNew ||
311 (!Validator.equals(shard.getName(),
312 shardModelImpl.getOriginalName()))) {
313 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
314 new Object[] { shard.getName() }, shard);
315 }
316
317 if (!isNew &&
318 ((shard.getClassNameId() != shardModelImpl.getOriginalClassNameId()) ||
319 (shard.getClassPK() != shardModelImpl.getOriginalClassPK()))) {
320 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
321 new Object[] {
322 new Long(shardModelImpl.getOriginalClassNameId()),
323 new Long(shardModelImpl.getOriginalClassPK())
324 });
325 }
326
327 if (isNew ||
328 ((shard.getClassNameId() != shardModelImpl.getOriginalClassNameId()) ||
329 (shard.getClassPK() != shardModelImpl.getOriginalClassPK()))) {
330 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
331 new Object[] {
332 new Long(shard.getClassNameId()),
333 new Long(shard.getClassPK())
334 }, shard);
335 }
336
337 return shard;
338 }
339
340 protected Shard toUnwrappedModel(Shard shard) {
341 if (shard instanceof ShardImpl) {
342 return shard;
343 }
344
345 ShardImpl shardImpl = new ShardImpl();
346
347 shardImpl.setNew(shard.isNew());
348 shardImpl.setPrimaryKey(shard.getPrimaryKey());
349
350 shardImpl.setShardId(shard.getShardId());
351 shardImpl.setClassNameId(shard.getClassNameId());
352 shardImpl.setClassPK(shard.getClassPK());
353 shardImpl.setName(shard.getName());
354
355 return shardImpl;
356 }
357
358 public Shard findByPrimaryKey(long shardId)
359 throws NoSuchShardException, SystemException {
360 Shard shard = fetchByPrimaryKey(shardId);
361
362 if (shard == null) {
363 if (_log.isWarnEnabled()) {
364 _log.warn("No Shard exists with the primary key " + shardId);
365 }
366
367 throw new NoSuchShardException(
368 "No Shard exists with the primary key " + shardId);
369 }
370
371 return shard;
372 }
373
374 public Shard fetchByPrimaryKey(long shardId) throws SystemException {
375 Shard shard = (Shard)EntityCacheUtil.getResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
376 ShardImpl.class, shardId, this);
377
378 if (shard == null) {
379 Session session = null;
380
381 try {
382 session = openSession();
383
384 shard = (Shard)session.get(ShardImpl.class, new Long(shardId));
385 }
386 catch (Exception e) {
387 throw processException(e);
388 }
389 finally {
390 if (shard != null) {
391 cacheResult(shard);
392 }
393
394 closeSession(session);
395 }
396 }
397
398 return shard;
399 }
400
401 public Shard findByName(String name)
402 throws NoSuchShardException, SystemException {
403 Shard shard = fetchByName(name);
404
405 if (shard == null) {
406 StringBuilder msg = new StringBuilder();
407
408 msg.append("No Shard exists with the key {");
409
410 msg.append("name=" + name);
411
412 msg.append(StringPool.CLOSE_CURLY_BRACE);
413
414 if (_log.isWarnEnabled()) {
415 _log.warn(msg.toString());
416 }
417
418 throw new NoSuchShardException(msg.toString());
419 }
420
421 return shard;
422 }
423
424 public Shard fetchByName(String name) throws SystemException {
425 return fetchByName(name, true);
426 }
427
428 public Shard fetchByName(String name, boolean retrieveFromCache)
429 throws SystemException {
430 Object[] finderArgs = new Object[] { name };
431
432 Object result = null;
433
434 if (retrieveFromCache) {
435 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_NAME,
436 finderArgs, this);
437 }
438
439 if (result == null) {
440 Session session = null;
441
442 try {
443 session = openSession();
444
445 StringBuilder query = new StringBuilder();
446
447 query.append("SELECT shard FROM Shard shard WHERE ");
448
449 if (name == null) {
450 query.append("shard.name IS NULL");
451 }
452 else {
453 query.append("shard.name = ?");
454 }
455
456 query.append(" ");
457
458 Query q = session.createQuery(query.toString());
459
460 QueryPos qPos = QueryPos.getInstance(q);
461
462 if (name != null) {
463 qPos.add(name);
464 }
465
466 List<Shard> list = q.list();
467
468 result = list;
469
470 Shard shard = null;
471
472 if (list.isEmpty()) {
473 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
474 finderArgs, list);
475 }
476 else {
477 shard = list.get(0);
478
479 cacheResult(shard);
480
481 if ((shard.getName() == null) ||
482 !shard.getName().equals(name)) {
483 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
484 finderArgs, shard);
485 }
486 }
487
488 return shard;
489 }
490 catch (Exception e) {
491 throw processException(e);
492 }
493 finally {
494 if (result == null) {
495 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
496 finderArgs, new ArrayList<Shard>());
497 }
498
499 closeSession(session);
500 }
501 }
502 else {
503 if (result instanceof List<?>) {
504 return null;
505 }
506 else {
507 return (Shard)result;
508 }
509 }
510 }
511
512 public Shard findByC_C(long classNameId, long classPK)
513 throws NoSuchShardException, SystemException {
514 Shard shard = fetchByC_C(classNameId, classPK);
515
516 if (shard == null) {
517 StringBuilder msg = new StringBuilder();
518
519 msg.append("No Shard exists with the key {");
520
521 msg.append("classNameId=" + classNameId);
522
523 msg.append(", ");
524 msg.append("classPK=" + classPK);
525
526 msg.append(StringPool.CLOSE_CURLY_BRACE);
527
528 if (_log.isWarnEnabled()) {
529 _log.warn(msg.toString());
530 }
531
532 throw new NoSuchShardException(msg.toString());
533 }
534
535 return shard;
536 }
537
538 public Shard fetchByC_C(long classNameId, long classPK)
539 throws SystemException {
540 return fetchByC_C(classNameId, classPK, true);
541 }
542
543 public Shard fetchByC_C(long classNameId, long classPK,
544 boolean retrieveFromCache) throws SystemException {
545 Object[] finderArgs = new Object[] {
546 new Long(classNameId), new Long(classPK)
547 };
548
549 Object result = null;
550
551 if (retrieveFromCache) {
552 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
553 finderArgs, this);
554 }
555
556 if (result == null) {
557 Session session = null;
558
559 try {
560 session = openSession();
561
562 StringBuilder query = new StringBuilder();
563
564 query.append("SELECT shard FROM Shard shard WHERE ");
565
566 query.append("shard.classNameId = ?");
567
568 query.append(" AND ");
569
570 query.append("shard.classPK = ?");
571
572 query.append(" ");
573
574 Query q = session.createQuery(query.toString());
575
576 QueryPos qPos = QueryPos.getInstance(q);
577
578 qPos.add(classNameId);
579
580 qPos.add(classPK);
581
582 List<Shard> list = q.list();
583
584 result = list;
585
586 Shard shard = null;
587
588 if (list.isEmpty()) {
589 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
590 finderArgs, list);
591 }
592 else {
593 shard = list.get(0);
594
595 cacheResult(shard);
596
597 if ((shard.getClassNameId() != classNameId) ||
598 (shard.getClassPK() != classPK)) {
599 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
600 finderArgs, shard);
601 }
602 }
603
604 return shard;
605 }
606 catch (Exception e) {
607 throw processException(e);
608 }
609 finally {
610 if (result == null) {
611 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
612 finderArgs, new ArrayList<Shard>());
613 }
614
615 closeSession(session);
616 }
617 }
618 else {
619 if (result instanceof List<?>) {
620 return null;
621 }
622 else {
623 return (Shard)result;
624 }
625 }
626 }
627
628 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
629 throws SystemException {
630 Session session = null;
631
632 try {
633 session = openSession();
634
635 dynamicQuery.compile(session);
636
637 return dynamicQuery.list();
638 }
639 catch (Exception e) {
640 throw processException(e);
641 }
642 finally {
643 closeSession(session);
644 }
645 }
646
647 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
648 int start, int end) throws SystemException {
649 Session session = null;
650
651 try {
652 session = openSession();
653
654 dynamicQuery.setLimit(start, end);
655
656 dynamicQuery.compile(session);
657
658 return dynamicQuery.list();
659 }
660 catch (Exception e) {
661 throw processException(e);
662 }
663 finally {
664 closeSession(session);
665 }
666 }
667
668 public List<Shard> findAll() throws SystemException {
669 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
670 }
671
672 public List<Shard> findAll(int start, int end) throws SystemException {
673 return findAll(start, end, null);
674 }
675
676 public List<Shard> findAll(int start, int end, OrderByComparator obc)
677 throws SystemException {
678 Object[] finderArgs = new Object[] {
679 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
680 };
681
682 List<Shard> list = (List<Shard>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
683 finderArgs, this);
684
685 if (list == null) {
686 Session session = null;
687
688 try {
689 session = openSession();
690
691 StringBuilder query = new StringBuilder();
692
693 query.append("SELECT shard FROM Shard shard ");
694
695 if (obc != null) {
696 query.append("ORDER BY ");
697
698 String[] orderByFields = obc.getOrderByFields();
699
700 for (int i = 0; i < orderByFields.length; i++) {
701 query.append("shard.");
702 query.append(orderByFields[i]);
703
704 if (obc.isAscending()) {
705 query.append(" ASC");
706 }
707 else {
708 query.append(" DESC");
709 }
710
711 if ((i + 1) < orderByFields.length) {
712 query.append(", ");
713 }
714 }
715 }
716
717 Query q = session.createQuery(query.toString());
718
719 if (obc == null) {
720 list = (List<Shard>)QueryUtil.list(q, getDialect(), start,
721 end, false);
722
723 Collections.sort(list);
724 }
725 else {
726 list = (List<Shard>)QueryUtil.list(q, getDialect(), start,
727 end);
728 }
729 }
730 catch (Exception e) {
731 throw processException(e);
732 }
733 finally {
734 if (list == null) {
735 list = new ArrayList<Shard>();
736 }
737
738 cacheResult(list);
739
740 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
741
742 closeSession(session);
743 }
744 }
745
746 return list;
747 }
748
749 public void removeByName(String name)
750 throws NoSuchShardException, SystemException {
751 Shard shard = findByName(name);
752
753 remove(shard);
754 }
755
756 public void removeByC_C(long classNameId, long classPK)
757 throws NoSuchShardException, SystemException {
758 Shard shard = findByC_C(classNameId, classPK);
759
760 remove(shard);
761 }
762
763 public void removeAll() throws SystemException {
764 for (Shard shard : findAll()) {
765 remove(shard);
766 }
767 }
768
769 public int countByName(String name) throws SystemException {
770 Object[] finderArgs = new Object[] { name };
771
772 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
773 finderArgs, this);
774
775 if (count == null) {
776 Session session = null;
777
778 try {
779 session = openSession();
780
781 StringBuilder query = new StringBuilder();
782
783 query.append("SELECT COUNT(shard) ");
784 query.append("FROM Shard shard WHERE ");
785
786 if (name == null) {
787 query.append("shard.name IS NULL");
788 }
789 else {
790 query.append("shard.name = ?");
791 }
792
793 query.append(" ");
794
795 Query q = session.createQuery(query.toString());
796
797 QueryPos qPos = QueryPos.getInstance(q);
798
799 if (name != null) {
800 qPos.add(name);
801 }
802
803 count = (Long)q.uniqueResult();
804 }
805 catch (Exception e) {
806 throw processException(e);
807 }
808 finally {
809 if (count == null) {
810 count = Long.valueOf(0);
811 }
812
813 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
814 finderArgs, count);
815
816 closeSession(session);
817 }
818 }
819
820 return count.intValue();
821 }
822
823 public int countByC_C(long classNameId, long classPK)
824 throws SystemException {
825 Object[] finderArgs = new Object[] {
826 new Long(classNameId), new Long(classPK)
827 };
828
829 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
830 finderArgs, this);
831
832 if (count == null) {
833 Session session = null;
834
835 try {
836 session = openSession();
837
838 StringBuilder query = new StringBuilder();
839
840 query.append("SELECT COUNT(shard) ");
841 query.append("FROM Shard shard WHERE ");
842
843 query.append("shard.classNameId = ?");
844
845 query.append(" AND ");
846
847 query.append("shard.classPK = ?");
848
849 query.append(" ");
850
851 Query q = session.createQuery(query.toString());
852
853 QueryPos qPos = QueryPos.getInstance(q);
854
855 qPos.add(classNameId);
856
857 qPos.add(classPK);
858
859 count = (Long)q.uniqueResult();
860 }
861 catch (Exception e) {
862 throw processException(e);
863 }
864 finally {
865 if (count == null) {
866 count = Long.valueOf(0);
867 }
868
869 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
870 count);
871
872 closeSession(session);
873 }
874 }
875
876 return count.intValue();
877 }
878
879 public int countAll() throws SystemException {
880 Object[] finderArgs = new Object[0];
881
882 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
883 finderArgs, this);
884
885 if (count == null) {
886 Session session = null;
887
888 try {
889 session = openSession();
890
891 Query q = session.createQuery(
892 "SELECT COUNT(shard) FROM Shard shard");
893
894 count = (Long)q.uniqueResult();
895 }
896 catch (Exception e) {
897 throw processException(e);
898 }
899 finally {
900 if (count == null) {
901 count = Long.valueOf(0);
902 }
903
904 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
905 count);
906
907 closeSession(session);
908 }
909 }
910
911 return count.intValue();
912 }
913
914 public void afterPropertiesSet() {
915 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
916 com.liferay.portal.util.PropsUtil.get(
917 "value.object.listener.com.liferay.portal.model.Shard")));
918
919 if (listenerClassNames.length > 0) {
920 try {
921 List<ModelListener<Shard>> listenersList = new ArrayList<ModelListener<Shard>>();
922
923 for (String listenerClassName : listenerClassNames) {
924 listenersList.add((ModelListener<Shard>)Class.forName(
925 listenerClassName).newInstance());
926 }
927
928 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
929 }
930 catch (Exception e) {
931 _log.error(e);
932 }
933 }
934 }
935
936 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
937 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
938 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
939 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
940 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
941 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
942 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
943 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
944 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
945 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
946 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
947 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
948 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
949 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
950 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
951 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
952 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
953 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
954 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
955 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
956 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
957 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
958 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
959 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
960 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
961 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
962 @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence.impl")
963 protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
964 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
965 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
966 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
967 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
968 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
969 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
970 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
971 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
972 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
973 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
974 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
975 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
976 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
977 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
978 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
979 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
980 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
981 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
982 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
983 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
984 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
985 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
986 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
987 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
988 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
989 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
990 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
991 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
992 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
993 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
994 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
995 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
996 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
997 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
998 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
999 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1000 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1001 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1002 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
1003 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1004 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1005 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1006 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1007 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1008 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
1009 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1010 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1011 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1012 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1013 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1014 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1015 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1016 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence.impl")
1017 protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1018 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1019 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1020 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1021 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1022 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1023 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1024 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1025 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1026 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1027 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1028 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1029 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1030 private static Log _log = LogFactoryUtil.getLog(ShardPersistenceImpl.class);
1031}