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