1
14
15 package com.liferay.portal.service.persistence;
16
17 import com.liferay.portal.NoSuchLayoutSetPrototypeException;
18 import com.liferay.portal.NoSuchModelException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.exception.SystemException;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.model.LayoutSetPrototype;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.model.impl.LayoutSetPrototypeImpl;
39 import com.liferay.portal.model.impl.LayoutSetPrototypeModelImpl;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import java.io.Serializable;
43
44 import java.util.ArrayList;
45 import java.util.Collections;
46 import java.util.List;
47
48
61 public class LayoutSetPrototypePersistenceImpl extends BasePersistenceImpl<LayoutSetPrototype>
62 implements LayoutSetPrototypePersistence {
63 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetPrototypeImpl.class.getName();
64 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
65 ".List";
66 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
67 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
68 FINDER_CLASS_NAME_LIST, "findByCompanyId",
69 new String[] { Long.class.getName() });
70 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
71 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
72 FINDER_CLASS_NAME_LIST, "findByCompanyId",
73 new String[] {
74 Long.class.getName(),
75
76 "java.lang.Integer", "java.lang.Integer",
77 "com.liferay.portal.kernel.util.OrderByComparator"
78 });
79 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
80 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
81 FINDER_CLASS_NAME_LIST, "countByCompanyId",
82 new String[] { Long.class.getName() });
83 public static final FinderPath FINDER_PATH_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
84 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
85 FINDER_CLASS_NAME_LIST, "findByC_A",
86 new String[] { Long.class.getName(), Boolean.class.getName() });
87 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
88 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
89 FINDER_CLASS_NAME_LIST, "findByC_A",
90 new String[] {
91 Long.class.getName(), Boolean.class.getName(),
92
93 "java.lang.Integer", "java.lang.Integer",
94 "com.liferay.portal.kernel.util.OrderByComparator"
95 });
96 public static final FinderPath FINDER_PATH_COUNT_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
97 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
98 FINDER_CLASS_NAME_LIST, "countByC_A",
99 new String[] { Long.class.getName(), Boolean.class.getName() });
100 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
101 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
102 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
103 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
104 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
105 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
106
107 public void cacheResult(LayoutSetPrototype layoutSetPrototype) {
108 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
109 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
110 layoutSetPrototype);
111 }
112
113 public void cacheResult(List<LayoutSetPrototype> layoutSetPrototypes) {
114 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
115 if (EntityCacheUtil.getResult(
116 LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
117 LayoutSetPrototypeImpl.class,
118 layoutSetPrototype.getPrimaryKey(), this) == null) {
119 cacheResult(layoutSetPrototype);
120 }
121 }
122 }
123
124 public void clearCache() {
125 CacheRegistry.clear(LayoutSetPrototypeImpl.class.getName());
126 EntityCacheUtil.clearCache(LayoutSetPrototypeImpl.class.getName());
127 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
128 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
129 }
130
131 public LayoutSetPrototype create(long layoutSetPrototypeId) {
132 LayoutSetPrototype layoutSetPrototype = new LayoutSetPrototypeImpl();
133
134 layoutSetPrototype.setNew(true);
135 layoutSetPrototype.setPrimaryKey(layoutSetPrototypeId);
136
137 return layoutSetPrototype;
138 }
139
140 public LayoutSetPrototype remove(Serializable primaryKey)
141 throws NoSuchModelException, SystemException {
142 return remove(((Long)primaryKey).longValue());
143 }
144
145 public LayoutSetPrototype remove(long layoutSetPrototypeId)
146 throws NoSuchLayoutSetPrototypeException, SystemException {
147 Session session = null;
148
149 try {
150 session = openSession();
151
152 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
153 new Long(layoutSetPrototypeId));
154
155 if (layoutSetPrototype == null) {
156 if (_log.isWarnEnabled()) {
157 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
158 layoutSetPrototypeId);
159 }
160
161 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
162 layoutSetPrototypeId);
163 }
164
165 return remove(layoutSetPrototype);
166 }
167 catch (NoSuchLayoutSetPrototypeException nsee) {
168 throw nsee;
169 }
170 catch (Exception e) {
171 throw processException(e);
172 }
173 finally {
174 closeSession(session);
175 }
176 }
177
178 public LayoutSetPrototype remove(LayoutSetPrototype layoutSetPrototype)
179 throws SystemException {
180 for (ModelListener<LayoutSetPrototype> listener : listeners) {
181 listener.onBeforeRemove(layoutSetPrototype);
182 }
183
184 layoutSetPrototype = removeImpl(layoutSetPrototype);
185
186 for (ModelListener<LayoutSetPrototype> listener : listeners) {
187 listener.onAfterRemove(layoutSetPrototype);
188 }
189
190 return layoutSetPrototype;
191 }
192
193 protected LayoutSetPrototype removeImpl(
194 LayoutSetPrototype layoutSetPrototype) throws SystemException {
195 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
196
197 Session session = null;
198
199 try {
200 session = openSession();
201
202 if (layoutSetPrototype.isCachedModel() ||
203 BatchSessionUtil.isEnabled()) {
204 Object staleObject = session.get(LayoutSetPrototypeImpl.class,
205 layoutSetPrototype.getPrimaryKeyObj());
206
207 if (staleObject != null) {
208 session.evict(staleObject);
209 }
210 }
211
212 session.delete(layoutSetPrototype);
213
214 session.flush();
215 }
216 catch (Exception e) {
217 throw processException(e);
218 }
219 finally {
220 closeSession(session);
221 }
222
223 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
224
225 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
226 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
227
228 return layoutSetPrototype;
229 }
230
231 public LayoutSetPrototype updateImpl(
232 com.liferay.portal.model.LayoutSetPrototype layoutSetPrototype,
233 boolean merge) throws SystemException {
234 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
235
236 Session session = null;
237
238 try {
239 session = openSession();
240
241 BatchSessionUtil.update(session, layoutSetPrototype, merge);
242
243 layoutSetPrototype.setNew(false);
244 }
245 catch (Exception e) {
246 throw processException(e);
247 }
248 finally {
249 closeSession(session);
250 }
251
252 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
253
254 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
255 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
256 layoutSetPrototype);
257
258 return layoutSetPrototype;
259 }
260
261 protected LayoutSetPrototype toUnwrappedModel(
262 LayoutSetPrototype layoutSetPrototype) {
263 if (layoutSetPrototype instanceof LayoutSetPrototypeImpl) {
264 return layoutSetPrototype;
265 }
266
267 LayoutSetPrototypeImpl layoutSetPrototypeImpl = new LayoutSetPrototypeImpl();
268
269 layoutSetPrototypeImpl.setNew(layoutSetPrototype.isNew());
270 layoutSetPrototypeImpl.setPrimaryKey(layoutSetPrototype.getPrimaryKey());
271
272 layoutSetPrototypeImpl.setLayoutSetPrototypeId(layoutSetPrototype.getLayoutSetPrototypeId());
273 layoutSetPrototypeImpl.setCompanyId(layoutSetPrototype.getCompanyId());
274 layoutSetPrototypeImpl.setName(layoutSetPrototype.getName());
275 layoutSetPrototypeImpl.setDescription(layoutSetPrototype.getDescription());
276 layoutSetPrototypeImpl.setSettings(layoutSetPrototype.getSettings());
277 layoutSetPrototypeImpl.setActive(layoutSetPrototype.isActive());
278
279 return layoutSetPrototypeImpl;
280 }
281
282 public LayoutSetPrototype findByPrimaryKey(Serializable primaryKey)
283 throws NoSuchModelException, SystemException {
284 return findByPrimaryKey(((Long)primaryKey).longValue());
285 }
286
287 public LayoutSetPrototype findByPrimaryKey(long layoutSetPrototypeId)
288 throws NoSuchLayoutSetPrototypeException, SystemException {
289 LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(layoutSetPrototypeId);
290
291 if (layoutSetPrototype == null) {
292 if (_log.isWarnEnabled()) {
293 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
294 layoutSetPrototypeId);
295 }
296
297 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
298 layoutSetPrototypeId);
299 }
300
301 return layoutSetPrototype;
302 }
303
304 public LayoutSetPrototype fetchByPrimaryKey(Serializable primaryKey)
305 throws SystemException {
306 return fetchByPrimaryKey(((Long)primaryKey).longValue());
307 }
308
309 public LayoutSetPrototype fetchByPrimaryKey(long layoutSetPrototypeId)
310 throws SystemException {
311 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)EntityCacheUtil.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
312 LayoutSetPrototypeImpl.class, layoutSetPrototypeId, this);
313
314 if (layoutSetPrototype == null) {
315 Session session = null;
316
317 try {
318 session = openSession();
319
320 layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
321 new Long(layoutSetPrototypeId));
322 }
323 catch (Exception e) {
324 throw processException(e);
325 }
326 finally {
327 if (layoutSetPrototype != null) {
328 cacheResult(layoutSetPrototype);
329 }
330
331 closeSession(session);
332 }
333 }
334
335 return layoutSetPrototype;
336 }
337
338 public List<LayoutSetPrototype> findByCompanyId(long companyId)
339 throws SystemException {
340 Object[] finderArgs = new Object[] { new Long(companyId) };
341
342 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
343 finderArgs, this);
344
345 if (list == null) {
346 Session session = null;
347
348 try {
349 session = openSession();
350
351 StringBundler query = new StringBundler(2);
352
353 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
354
355 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
356
357 String sql = query.toString();
358
359 Query q = session.createQuery(sql);
360
361 QueryPos qPos = QueryPos.getInstance(q);
362
363 qPos.add(companyId);
364
365 list = q.list();
366 }
367 catch (Exception e) {
368 throw processException(e);
369 }
370 finally {
371 if (list == null) {
372 list = new ArrayList<LayoutSetPrototype>();
373 }
374
375 cacheResult(list);
376
377 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
378 finderArgs, list);
379
380 closeSession(session);
381 }
382 }
383
384 return list;
385 }
386
387 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
388 int end) throws SystemException {
389 return findByCompanyId(companyId, start, end, null);
390 }
391
392 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
393 int end, OrderByComparator orderByComparator) throws SystemException {
394 Object[] finderArgs = new Object[] {
395 new Long(companyId),
396
397 String.valueOf(start), String.valueOf(end),
398 String.valueOf(orderByComparator)
399 };
400
401 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
402 finderArgs, this);
403
404 if (list == null) {
405 Session session = null;
406
407 try {
408 session = openSession();
409
410 StringBundler query = null;
411
412 if (orderByComparator != null) {
413 query = new StringBundler(3 +
414 (orderByComparator.getOrderByFields().length * 3));
415 }
416 else {
417 query = new StringBundler(2);
418 }
419
420 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
421
422 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
423
424 if (orderByComparator != null) {
425 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
426 orderByComparator);
427 }
428
429 String sql = query.toString();
430
431 Query q = session.createQuery(sql);
432
433 QueryPos qPos = QueryPos.getInstance(q);
434
435 qPos.add(companyId);
436
437 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
438 getDialect(), start, end);
439 }
440 catch (Exception e) {
441 throw processException(e);
442 }
443 finally {
444 if (list == null) {
445 list = new ArrayList<LayoutSetPrototype>();
446 }
447
448 cacheResult(list);
449
450 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
451 finderArgs, list);
452
453 closeSession(session);
454 }
455 }
456
457 return list;
458 }
459
460 public LayoutSetPrototype findByCompanyId_First(long companyId,
461 OrderByComparator orderByComparator)
462 throws NoSuchLayoutSetPrototypeException, SystemException {
463 List<LayoutSetPrototype> list = findByCompanyId(companyId, 0, 1,
464 orderByComparator);
465
466 if (list.isEmpty()) {
467 StringBundler msg = new StringBundler(4);
468
469 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
470
471 msg.append("companyId=");
472 msg.append(companyId);
473
474 msg.append(StringPool.CLOSE_CURLY_BRACE);
475
476 throw new NoSuchLayoutSetPrototypeException(msg.toString());
477 }
478 else {
479 return list.get(0);
480 }
481 }
482
483 public LayoutSetPrototype findByCompanyId_Last(long companyId,
484 OrderByComparator orderByComparator)
485 throws NoSuchLayoutSetPrototypeException, SystemException {
486 int count = countByCompanyId(companyId);
487
488 List<LayoutSetPrototype> list = findByCompanyId(companyId, count - 1,
489 count, orderByComparator);
490
491 if (list.isEmpty()) {
492 StringBundler msg = new StringBundler(4);
493
494 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
495
496 msg.append("companyId=");
497 msg.append(companyId);
498
499 msg.append(StringPool.CLOSE_CURLY_BRACE);
500
501 throw new NoSuchLayoutSetPrototypeException(msg.toString());
502 }
503 else {
504 return list.get(0);
505 }
506 }
507
508 public LayoutSetPrototype[] findByCompanyId_PrevAndNext(
509 long layoutSetPrototypeId, long companyId,
510 OrderByComparator orderByComparator)
511 throws NoSuchLayoutSetPrototypeException, SystemException {
512 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
513
514 int count = countByCompanyId(companyId);
515
516 Session session = null;
517
518 try {
519 session = openSession();
520
521 StringBundler query = null;
522
523 if (orderByComparator != null) {
524 query = new StringBundler(3 +
525 (orderByComparator.getOrderByFields().length * 3));
526 }
527 else {
528 query = new StringBundler(2);
529 }
530
531 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
532
533 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
534
535 if (orderByComparator != null) {
536 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
537 orderByComparator);
538 }
539
540 String sql = query.toString();
541
542 Query q = session.createQuery(sql);
543
544 QueryPos qPos = QueryPos.getInstance(q);
545
546 qPos.add(companyId);
547
548 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
549 orderByComparator, layoutSetPrototype);
550
551 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
552
553 array[0] = (LayoutSetPrototype)objArray[0];
554 array[1] = (LayoutSetPrototype)objArray[1];
555 array[2] = (LayoutSetPrototype)objArray[2];
556
557 return array;
558 }
559 catch (Exception e) {
560 throw processException(e);
561 }
562 finally {
563 closeSession(session);
564 }
565 }
566
567 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active)
568 throws SystemException {
569 Object[] finderArgs = new Object[] {
570 new Long(companyId), Boolean.valueOf(active)
571 };
572
573 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_A,
574 finderArgs, this);
575
576 if (list == null) {
577 Session session = null;
578
579 try {
580 session = openSession();
581
582 StringBundler query = new StringBundler(3);
583
584 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
585
586 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
587
588 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
589
590 String sql = query.toString();
591
592 Query q = session.createQuery(sql);
593
594 QueryPos qPos = QueryPos.getInstance(q);
595
596 qPos.add(companyId);
597
598 qPos.add(active);
599
600 list = q.list();
601 }
602 catch (Exception e) {
603 throw processException(e);
604 }
605 finally {
606 if (list == null) {
607 list = new ArrayList<LayoutSetPrototype>();
608 }
609
610 cacheResult(list);
611
612 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_A, finderArgs,
613 list);
614
615 closeSession(session);
616 }
617 }
618
619 return list;
620 }
621
622 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
623 int start, int end) throws SystemException {
624 return findByC_A(companyId, active, start, end, null);
625 }
626
627 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
628 int start, int end, OrderByComparator orderByComparator)
629 throws SystemException {
630 Object[] finderArgs = new Object[] {
631 new Long(companyId), Boolean.valueOf(active),
632
633 String.valueOf(start), String.valueOf(end),
634 String.valueOf(orderByComparator)
635 };
636
637 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_A,
638 finderArgs, this);
639
640 if (list == null) {
641 Session session = null;
642
643 try {
644 session = openSession();
645
646 StringBundler query = null;
647
648 if (orderByComparator != null) {
649 query = new StringBundler(4 +
650 (orderByComparator.getOrderByFields().length * 3));
651 }
652 else {
653 query = new StringBundler(3);
654 }
655
656 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
657
658 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
659
660 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
661
662 if (orderByComparator != null) {
663 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
664 orderByComparator);
665 }
666
667 String sql = query.toString();
668
669 Query q = session.createQuery(sql);
670
671 QueryPos qPos = QueryPos.getInstance(q);
672
673 qPos.add(companyId);
674
675 qPos.add(active);
676
677 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
678 getDialect(), start, end);
679 }
680 catch (Exception e) {
681 throw processException(e);
682 }
683 finally {
684 if (list == null) {
685 list = new ArrayList<LayoutSetPrototype>();
686 }
687
688 cacheResult(list);
689
690 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_A,
691 finderArgs, list);
692
693 closeSession(session);
694 }
695 }
696
697 return list;
698 }
699
700 public LayoutSetPrototype findByC_A_First(long companyId, boolean active,
701 OrderByComparator orderByComparator)
702 throws NoSuchLayoutSetPrototypeException, SystemException {
703 List<LayoutSetPrototype> list = findByC_A(companyId, active, 0, 1,
704 orderByComparator);
705
706 if (list.isEmpty()) {
707 StringBundler msg = new StringBundler(6);
708
709 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
710
711 msg.append("companyId=");
712 msg.append(companyId);
713
714 msg.append(", active=");
715 msg.append(active);
716
717 msg.append(StringPool.CLOSE_CURLY_BRACE);
718
719 throw new NoSuchLayoutSetPrototypeException(msg.toString());
720 }
721 else {
722 return list.get(0);
723 }
724 }
725
726 public LayoutSetPrototype findByC_A_Last(long companyId, boolean active,
727 OrderByComparator orderByComparator)
728 throws NoSuchLayoutSetPrototypeException, SystemException {
729 int count = countByC_A(companyId, active);
730
731 List<LayoutSetPrototype> list = findByC_A(companyId, active, count - 1,
732 count, orderByComparator);
733
734 if (list.isEmpty()) {
735 StringBundler msg = new StringBundler(6);
736
737 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
738
739 msg.append("companyId=");
740 msg.append(companyId);
741
742 msg.append(", active=");
743 msg.append(active);
744
745 msg.append(StringPool.CLOSE_CURLY_BRACE);
746
747 throw new NoSuchLayoutSetPrototypeException(msg.toString());
748 }
749 else {
750 return list.get(0);
751 }
752 }
753
754 public LayoutSetPrototype[] findByC_A_PrevAndNext(
755 long layoutSetPrototypeId, long companyId, boolean active,
756 OrderByComparator orderByComparator)
757 throws NoSuchLayoutSetPrototypeException, SystemException {
758 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
759
760 int count = countByC_A(companyId, active);
761
762 Session session = null;
763
764 try {
765 session = openSession();
766
767 StringBundler query = null;
768
769 if (orderByComparator != null) {
770 query = new StringBundler(4 +
771 (orderByComparator.getOrderByFields().length * 3));
772 }
773 else {
774 query = new StringBundler(3);
775 }
776
777 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
778
779 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
780
781 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
782
783 if (orderByComparator != null) {
784 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
785 orderByComparator);
786 }
787
788 String sql = query.toString();
789
790 Query q = session.createQuery(sql);
791
792 QueryPos qPos = QueryPos.getInstance(q);
793
794 qPos.add(companyId);
795
796 qPos.add(active);
797
798 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
799 orderByComparator, layoutSetPrototype);
800
801 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
802
803 array[0] = (LayoutSetPrototype)objArray[0];
804 array[1] = (LayoutSetPrototype)objArray[1];
805 array[2] = (LayoutSetPrototype)objArray[2];
806
807 return array;
808 }
809 catch (Exception e) {
810 throw processException(e);
811 }
812 finally {
813 closeSession(session);
814 }
815 }
816
817 public List<LayoutSetPrototype> findAll() throws SystemException {
818 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
819 }
820
821 public List<LayoutSetPrototype> findAll(int start, int end)
822 throws SystemException {
823 return findAll(start, end, null);
824 }
825
826 public List<LayoutSetPrototype> findAll(int start, int end,
827 OrderByComparator orderByComparator) throws SystemException {
828 Object[] finderArgs = new Object[] {
829 String.valueOf(start), String.valueOf(end),
830 String.valueOf(orderByComparator)
831 };
832
833 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
834 finderArgs, this);
835
836 if (list == null) {
837 Session session = null;
838
839 try {
840 session = openSession();
841
842 StringBundler query = null;
843 String sql = null;
844
845 if (orderByComparator != null) {
846 query = new StringBundler(2 +
847 (orderByComparator.getOrderByFields().length * 3));
848
849 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE);
850
851 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
852 orderByComparator);
853
854 sql = query.toString();
855 }
856
857 sql = _SQL_SELECT_LAYOUTSETPROTOTYPE;
858
859 Query q = session.createQuery(sql);
860
861 if (orderByComparator == null) {
862 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
863 getDialect(), start, end, false);
864
865 Collections.sort(list);
866 }
867 else {
868 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
869 getDialect(), start, end);
870 }
871 }
872 catch (Exception e) {
873 throw processException(e);
874 }
875 finally {
876 if (list == null) {
877 list = new ArrayList<LayoutSetPrototype>();
878 }
879
880 cacheResult(list);
881
882 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
883
884 closeSession(session);
885 }
886 }
887
888 return list;
889 }
890
891 public void removeByCompanyId(long companyId) throws SystemException {
892 for (LayoutSetPrototype layoutSetPrototype : findByCompanyId(companyId)) {
893 remove(layoutSetPrototype);
894 }
895 }
896
897 public void removeByC_A(long companyId, boolean active)
898 throws SystemException {
899 for (LayoutSetPrototype layoutSetPrototype : findByC_A(companyId, active)) {
900 remove(layoutSetPrototype);
901 }
902 }
903
904 public void removeAll() throws SystemException {
905 for (LayoutSetPrototype layoutSetPrototype : findAll()) {
906 remove(layoutSetPrototype);
907 }
908 }
909
910 public int countByCompanyId(long companyId) throws SystemException {
911 Object[] finderArgs = new Object[] { new Long(companyId) };
912
913 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
914 finderArgs, this);
915
916 if (count == null) {
917 Session session = null;
918
919 try {
920 session = openSession();
921
922 StringBundler query = new StringBundler(2);
923
924 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
925
926 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
927
928 String sql = query.toString();
929
930 Query q = session.createQuery(sql);
931
932 QueryPos qPos = QueryPos.getInstance(q);
933
934 qPos.add(companyId);
935
936 count = (Long)q.uniqueResult();
937 }
938 catch (Exception e) {
939 throw processException(e);
940 }
941 finally {
942 if (count == null) {
943 count = Long.valueOf(0);
944 }
945
946 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
947 finderArgs, count);
948
949 closeSession(session);
950 }
951 }
952
953 return count.intValue();
954 }
955
956 public int countByC_A(long companyId, boolean active)
957 throws SystemException {
958 Object[] finderArgs = new Object[] {
959 new Long(companyId), Boolean.valueOf(active)
960 };
961
962 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_A,
963 finderArgs, this);
964
965 if (count == null) {
966 Session session = null;
967
968 try {
969 session = openSession();
970
971 StringBundler query = new StringBundler(3);
972
973 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
974
975 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
976
977 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
978
979 String sql = query.toString();
980
981 Query q = session.createQuery(sql);
982
983 QueryPos qPos = QueryPos.getInstance(q);
984
985 qPos.add(companyId);
986
987 qPos.add(active);
988
989 count = (Long)q.uniqueResult();
990 }
991 catch (Exception e) {
992 throw processException(e);
993 }
994 finally {
995 if (count == null) {
996 count = Long.valueOf(0);
997 }
998
999 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_A, finderArgs,
1000 count);
1001
1002 closeSession(session);
1003 }
1004 }
1005
1006 return count.intValue();
1007 }
1008
1009 public int countAll() throws SystemException {
1010 Object[] finderArgs = new Object[0];
1011
1012 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1013 finderArgs, this);
1014
1015 if (count == null) {
1016 Session session = null;
1017
1018 try {
1019 session = openSession();
1020
1021 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETPROTOTYPE);
1022
1023 count = (Long)q.uniqueResult();
1024 }
1025 catch (Exception e) {
1026 throw processException(e);
1027 }
1028 finally {
1029 if (count == null) {
1030 count = Long.valueOf(0);
1031 }
1032
1033 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1034 count);
1035
1036 closeSession(session);
1037 }
1038 }
1039
1040 return count.intValue();
1041 }
1042
1043 public void afterPropertiesSet() {
1044 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1045 com.liferay.portal.util.PropsUtil.get(
1046 "value.object.listener.com.liferay.portal.model.LayoutSetPrototype")));
1047
1048 if (listenerClassNames.length > 0) {
1049 try {
1050 List<ModelListener<LayoutSetPrototype>> listenersList = new ArrayList<ModelListener<LayoutSetPrototype>>();
1051
1052 for (String listenerClassName : listenerClassNames) {
1053 listenersList.add((ModelListener<LayoutSetPrototype>)Class.forName(
1054 listenerClassName).newInstance());
1055 }
1056
1057 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1058 }
1059 catch (Exception e) {
1060 _log.error(e);
1061 }
1062 }
1063 }
1064
1065 @BeanReference(type = AccountPersistence.class)
1066 protected AccountPersistence accountPersistence;
1067 @BeanReference(type = AddressPersistence.class)
1068 protected AddressPersistence addressPersistence;
1069 @BeanReference(type = BrowserTrackerPersistence.class)
1070 protected BrowserTrackerPersistence browserTrackerPersistence;
1071 @BeanReference(type = ClassNamePersistence.class)
1072 protected ClassNamePersistence classNamePersistence;
1073 @BeanReference(type = CompanyPersistence.class)
1074 protected CompanyPersistence companyPersistence;
1075 @BeanReference(type = ContactPersistence.class)
1076 protected ContactPersistence contactPersistence;
1077 @BeanReference(type = CountryPersistence.class)
1078 protected CountryPersistence countryPersistence;
1079 @BeanReference(type = EmailAddressPersistence.class)
1080 protected EmailAddressPersistence emailAddressPersistence;
1081 @BeanReference(type = GroupPersistence.class)
1082 protected GroupPersistence groupPersistence;
1083 @BeanReference(type = ImagePersistence.class)
1084 protected ImagePersistence imagePersistence;
1085 @BeanReference(type = LayoutPersistence.class)
1086 protected LayoutPersistence layoutPersistence;
1087 @BeanReference(type = LayoutPrototypePersistence.class)
1088 protected LayoutPrototypePersistence layoutPrototypePersistence;
1089 @BeanReference(type = LayoutSetPersistence.class)
1090 protected LayoutSetPersistence layoutSetPersistence;
1091 @BeanReference(type = LayoutSetPrototypePersistence.class)
1092 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1093 @BeanReference(type = ListTypePersistence.class)
1094 protected ListTypePersistence listTypePersistence;
1095 @BeanReference(type = LockPersistence.class)
1096 protected LockPersistence lockPersistence;
1097 @BeanReference(type = MembershipRequestPersistence.class)
1098 protected MembershipRequestPersistence membershipRequestPersistence;
1099 @BeanReference(type = OrganizationPersistence.class)
1100 protected OrganizationPersistence organizationPersistence;
1101 @BeanReference(type = OrgGroupPermissionPersistence.class)
1102 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1103 @BeanReference(type = OrgGroupRolePersistence.class)
1104 protected OrgGroupRolePersistence orgGroupRolePersistence;
1105 @BeanReference(type = OrgLaborPersistence.class)
1106 protected OrgLaborPersistence orgLaborPersistence;
1107 @BeanReference(type = PasswordPolicyPersistence.class)
1108 protected PasswordPolicyPersistence passwordPolicyPersistence;
1109 @BeanReference(type = PasswordPolicyRelPersistence.class)
1110 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1111 @BeanReference(type = PasswordTrackerPersistence.class)
1112 protected PasswordTrackerPersistence passwordTrackerPersistence;
1113 @BeanReference(type = PermissionPersistence.class)
1114 protected PermissionPersistence permissionPersistence;
1115 @BeanReference(type = PhonePersistence.class)
1116 protected PhonePersistence phonePersistence;
1117 @BeanReference(type = PluginSettingPersistence.class)
1118 protected PluginSettingPersistence pluginSettingPersistence;
1119 @BeanReference(type = PortletPersistence.class)
1120 protected PortletPersistence portletPersistence;
1121 @BeanReference(type = PortletItemPersistence.class)
1122 protected PortletItemPersistence portletItemPersistence;
1123 @BeanReference(type = PortletPreferencesPersistence.class)
1124 protected PortletPreferencesPersistence portletPreferencesPersistence;
1125 @BeanReference(type = RegionPersistence.class)
1126 protected RegionPersistence regionPersistence;
1127 @BeanReference(type = ReleasePersistence.class)
1128 protected ReleasePersistence releasePersistence;
1129 @BeanReference(type = ResourcePersistence.class)
1130 protected ResourcePersistence resourcePersistence;
1131 @BeanReference(type = ResourceActionPersistence.class)
1132 protected ResourceActionPersistence resourceActionPersistence;
1133 @BeanReference(type = ResourceCodePersistence.class)
1134 protected ResourceCodePersistence resourceCodePersistence;
1135 @BeanReference(type = ResourcePermissionPersistence.class)
1136 protected ResourcePermissionPersistence resourcePermissionPersistence;
1137 @BeanReference(type = RolePersistence.class)
1138 protected RolePersistence rolePersistence;
1139 @BeanReference(type = ServiceComponentPersistence.class)
1140 protected ServiceComponentPersistence serviceComponentPersistence;
1141 @BeanReference(type = ShardPersistence.class)
1142 protected ShardPersistence shardPersistence;
1143 @BeanReference(type = SubscriptionPersistence.class)
1144 protected SubscriptionPersistence subscriptionPersistence;
1145 @BeanReference(type = TeamPersistence.class)
1146 protected TeamPersistence teamPersistence;
1147 @BeanReference(type = UserPersistence.class)
1148 protected UserPersistence userPersistence;
1149 @BeanReference(type = UserGroupPersistence.class)
1150 protected UserGroupPersistence userGroupPersistence;
1151 @BeanReference(type = UserGroupGroupRolePersistence.class)
1152 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1153 @BeanReference(type = UserGroupRolePersistence.class)
1154 protected UserGroupRolePersistence userGroupRolePersistence;
1155 @BeanReference(type = UserIdMapperPersistence.class)
1156 protected UserIdMapperPersistence userIdMapperPersistence;
1157 @BeanReference(type = UserTrackerPersistence.class)
1158 protected UserTrackerPersistence userTrackerPersistence;
1159 @BeanReference(type = UserTrackerPathPersistence.class)
1160 protected UserTrackerPathPersistence userTrackerPathPersistence;
1161 @BeanReference(type = WebDAVPropsPersistence.class)
1162 protected WebDAVPropsPersistence webDAVPropsPersistence;
1163 @BeanReference(type = WebsitePersistence.class)
1164 protected WebsitePersistence websitePersistence;
1165 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1166 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1167 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1168 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1169 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype";
1170 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE ";
1171 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype";
1172 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype WHERE ";
1173 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
1174 private static final String _FINDER_COLUMN_C_A_COMPANYID_2 = "layoutSetPrototype.companyId = ? AND ";
1175 private static final String _FINDER_COLUMN_C_A_ACTIVE_2 = "layoutSetPrototype.active = ?";
1176 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetPrototype.";
1177 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetPrototype exists with the primary key ";
1178 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetPrototype exists with the key {";
1179 private static Log _log = LogFactoryUtil.getLog(LayoutSetPrototypePersistenceImpl.class);
1180}