001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLayoutRevisionException;
018 import com.liferay.portal.NoSuchModelException;
019 import com.liferay.portal.kernel.bean.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.model.CacheModel;
038 import com.liferay.portal.model.LayoutRevision;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.model.impl.LayoutRevisionImpl;
041 import com.liferay.portal.model.impl.LayoutRevisionModelImpl;
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
062 public class LayoutRevisionPersistenceImpl extends BasePersistenceImpl<LayoutRevision>
063 implements LayoutRevisionPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = LayoutRevisionImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETBRANCHID =
075 new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
076 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
077 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
078 "findByLayoutSetBranchId",
079 new String[] {
080 Long.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID =
086 new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
087 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
088 LayoutRevisionImpl.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
090 "findByLayoutSetBranchId", new String[] { Long.class.getName() },
091 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
093 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
095 "countByLayoutSetBranchId", new String[] { Long.class.getName() });
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
097 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
098 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
099 "findByPlid",
100 new String[] {
101 Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
107 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
108 LayoutRevisionImpl.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPlid",
110 new String[] { Long.class.getName() },
111 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_PLID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
113 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPlid",
115 new String[] { Long.class.getName() });
116 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_H = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
117 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
118 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
119 "findByL_H",
120 new String[] {
121 Long.class.getName(), Boolean.class.getName(),
122
123 "java.lang.Integer", "java.lang.Integer",
124 "com.liferay.portal.kernel.util.OrderByComparator"
125 });
126 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
127 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
128 LayoutRevisionImpl.class,
129 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_H",
130 new String[] { Long.class.getName(), Boolean.class.getName() },
131 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
132 LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK);
133 public static final FinderPath FINDER_PATH_COUNT_BY_L_H = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
134 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_H",
136 new String[] { Long.class.getName(), Boolean.class.getName() });
137 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
138 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
139 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
140 "findByL_P",
141 new String[] {
142 Long.class.getName(), Long.class.getName(),
143
144 "java.lang.Integer", "java.lang.Integer",
145 "com.liferay.portal.kernel.util.OrderByComparator"
146 });
147 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
148 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
149 LayoutRevisionImpl.class,
150 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P",
151 new String[] { Long.class.getName(), Long.class.getName() },
152 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
153 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
154 public static final FinderPath FINDER_PATH_COUNT_BY_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
155 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
156 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P",
157 new String[] { Long.class.getName(), Long.class.getName() });
158 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
159 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
160 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
161 "findByL_S",
162 new String[] {
163 Long.class.getName(), Integer.class.getName(),
164
165 "java.lang.Integer", "java.lang.Integer",
166 "com.liferay.portal.kernel.util.OrderByComparator"
167 });
168 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
169 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
170 LayoutRevisionImpl.class,
171 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_S",
172 new String[] { Long.class.getName(), Integer.class.getName() },
173 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
174 LayoutRevisionModelImpl.STATUS_COLUMN_BITMASK);
175 public static final FinderPath FINDER_PATH_COUNT_BY_L_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
176 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
177 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_S",
178 new String[] { Long.class.getName(), Integer.class.getName() });
179 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
180 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
181 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
182 "findByH_P",
183 new String[] {
184 Boolean.class.getName(), Long.class.getName(),
185
186 "java.lang.Integer", "java.lang.Integer",
187 "com.liferay.portal.kernel.util.OrderByComparator"
188 });
189 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
190 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
191 LayoutRevisionImpl.class,
192 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByH_P",
193 new String[] { Boolean.class.getName(), Long.class.getName() },
194 LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK |
195 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
196 public static final FinderPath FINDER_PATH_COUNT_BY_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
197 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
198 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByH_P",
199 new String[] { Boolean.class.getName(), Long.class.getName() });
200 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_NOTS = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
201 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
202 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
203 "findByP_NotS",
204 new String[] {
205 Long.class.getName(), Integer.class.getName(),
206
207 "java.lang.Integer", "java.lang.Integer",
208 "com.liferay.portal.kernel.util.OrderByComparator"
209 });
210 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
211 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
212 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByP_NotS",
213 new String[] { Long.class.getName(), Integer.class.getName() });
214 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
215 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
216 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
217 "findByL_L_P",
218 new String[] {
219 Long.class.getName(), Long.class.getName(), Long.class.getName(),
220
221 "java.lang.Integer", "java.lang.Integer",
222 "com.liferay.portal.kernel.util.OrderByComparator"
223 });
224 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
225 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
226 LayoutRevisionImpl.class,
227 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_L_P",
228 new String[] {
229 Long.class.getName(), Long.class.getName(), Long.class.getName()
230 },
231 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
232 LayoutRevisionModelImpl.LAYOUTBRANCHID_COLUMN_BITMASK |
233 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
234 public static final FinderPath FINDER_PATH_COUNT_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
235 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
236 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_L_P",
237 new String[] {
238 Long.class.getName(), Long.class.getName(), Long.class.getName()
239 });
240 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
241 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
242 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
243 "findByL_P_P",
244 new String[] {
245 Long.class.getName(), Long.class.getName(), Long.class.getName(),
246
247 "java.lang.Integer", "java.lang.Integer",
248 "com.liferay.portal.kernel.util.OrderByComparator"
249 });
250 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
251 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
252 LayoutRevisionImpl.class,
253 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P_P",
254 new String[] {
255 Long.class.getName(), Long.class.getName(), Long.class.getName()
256 },
257 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
258 LayoutRevisionModelImpl.PARENTLAYOUTREVISIONID_COLUMN_BITMASK |
259 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
260 public static final FinderPath FINDER_PATH_COUNT_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
261 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
262 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_P",
263 new String[] {
264 Long.class.getName(), Long.class.getName(), Long.class.getName()
265 });
266 public static final FinderPath FINDER_PATH_FETCH_BY_L_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
267 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
268 LayoutRevisionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByL_H_P",
269 new String[] {
270 Long.class.getName(), Boolean.class.getName(),
271 Long.class.getName()
272 },
273 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
274 LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK |
275 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
276 public static final FinderPath FINDER_PATH_COUNT_BY_L_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
277 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
278 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_H_P",
279 new String[] {
280 Long.class.getName(), Boolean.class.getName(),
281 Long.class.getName()
282 });
283 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
284 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
285 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
286 "findByL_P_S",
287 new String[] {
288 Long.class.getName(), Long.class.getName(),
289 Integer.class.getName(),
290
291 "java.lang.Integer", "java.lang.Integer",
292 "com.liferay.portal.kernel.util.OrderByComparator"
293 });
294 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
295 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
296 LayoutRevisionImpl.class,
297 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P_S",
298 new String[] {
299 Long.class.getName(), Long.class.getName(),
300 Integer.class.getName()
301 },
302 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
303 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
304 LayoutRevisionModelImpl.STATUS_COLUMN_BITMASK);
305 public static final FinderPath FINDER_PATH_COUNT_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
306 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
307 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_S",
308 new String[] {
309 Long.class.getName(), Long.class.getName(),
310 Integer.class.getName()
311 });
312 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
313 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
314 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
315 "findAll", new String[0]);
316 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
317 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
318 LayoutRevisionImpl.class,
319 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
320 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
321 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
322 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
323
324
329 public void cacheResult(LayoutRevision layoutRevision) {
330 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
331 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey(),
332 layoutRevision);
333
334 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
335 new Object[] {
336 Long.valueOf(layoutRevision.getLayoutSetBranchId()),
337 Boolean.valueOf(layoutRevision.getHead()),
338 Long.valueOf(layoutRevision.getPlid())
339 }, layoutRevision);
340
341 layoutRevision.resetOriginalValues();
342 }
343
344
349 public void cacheResult(List<LayoutRevision> layoutRevisions) {
350 for (LayoutRevision layoutRevision : layoutRevisions) {
351 if (EntityCacheUtil.getResult(
352 LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
353 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey()) == null) {
354 cacheResult(layoutRevision);
355 }
356 else {
357 layoutRevision.resetOriginalValues();
358 }
359 }
360 }
361
362
369 @Override
370 public void clearCache() {
371 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
372 CacheRegistryUtil.clear(LayoutRevisionImpl.class.getName());
373 }
374
375 EntityCacheUtil.clearCache(LayoutRevisionImpl.class.getName());
376
377 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
378 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
379 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
380 }
381
382
389 @Override
390 public void clearCache(LayoutRevision layoutRevision) {
391 EntityCacheUtil.removeResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
392 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey());
393
394 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
395 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
396
397 clearUniqueFindersCache(layoutRevision);
398 }
399
400 @Override
401 public void clearCache(List<LayoutRevision> layoutRevisions) {
402 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
403 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
404
405 for (LayoutRevision layoutRevision : layoutRevisions) {
406 EntityCacheUtil.removeResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
407 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey());
408
409 clearUniqueFindersCache(layoutRevision);
410 }
411 }
412
413 protected void clearUniqueFindersCache(LayoutRevision layoutRevision) {
414 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P,
415 new Object[] {
416 Long.valueOf(layoutRevision.getLayoutSetBranchId()),
417 Boolean.valueOf(layoutRevision.getHead()),
418 Long.valueOf(layoutRevision.getPlid())
419 });
420 }
421
422
428 public LayoutRevision create(long layoutRevisionId) {
429 LayoutRevision layoutRevision = new LayoutRevisionImpl();
430
431 layoutRevision.setNew(true);
432 layoutRevision.setPrimaryKey(layoutRevisionId);
433
434 return layoutRevision;
435 }
436
437
445 public LayoutRevision remove(long layoutRevisionId)
446 throws NoSuchLayoutRevisionException, SystemException {
447 return remove(Long.valueOf(layoutRevisionId));
448 }
449
450
458 @Override
459 public LayoutRevision remove(Serializable primaryKey)
460 throws NoSuchLayoutRevisionException, SystemException {
461 Session session = null;
462
463 try {
464 session = openSession();
465
466 LayoutRevision layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
467 primaryKey);
468
469 if (layoutRevision == null) {
470 if (_log.isWarnEnabled()) {
471 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
472 }
473
474 throw new NoSuchLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
475 primaryKey);
476 }
477
478 return remove(layoutRevision);
479 }
480 catch (NoSuchLayoutRevisionException nsee) {
481 throw nsee;
482 }
483 catch (Exception e) {
484 throw processException(e);
485 }
486 finally {
487 closeSession(session);
488 }
489 }
490
491 @Override
492 protected LayoutRevision removeImpl(LayoutRevision layoutRevision)
493 throws SystemException {
494 layoutRevision = toUnwrappedModel(layoutRevision);
495
496 Session session = null;
497
498 try {
499 session = openSession();
500
501 if (layoutRevision.isCachedModel()) {
502 layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
503 layoutRevision.getPrimaryKeyObj());
504 }
505
506 session.delete(layoutRevision);
507 }
508 catch (Exception e) {
509 throw processException(e);
510 }
511 finally {
512 closeSession(session);
513 }
514
515 clearCache(layoutRevision);
516
517 return layoutRevision;
518 }
519
520 @Override
521 public LayoutRevision updateImpl(
522 com.liferay.portal.model.LayoutRevision layoutRevision)
523 throws SystemException {
524 layoutRevision = toUnwrappedModel(layoutRevision);
525
526 boolean isNew = layoutRevision.isNew();
527
528 LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
529
530 Session session = null;
531
532 try {
533 session = openSession();
534
535 if (layoutRevision.isNew()) {
536 session.save(layoutRevision);
537
538 layoutRevision.setNew(false);
539 }
540 else {
541 session.merge(layoutRevision);
542 }
543 }
544 catch (Exception e) {
545 throw processException(e);
546 }
547 finally {
548 closeSession(session);
549 }
550
551 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
552
553 if (isNew || !LayoutRevisionModelImpl.COLUMN_BITMASK_ENABLED) {
554 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
555 }
556
557 else {
558 if ((layoutRevisionModelImpl.getColumnBitmask() &
559 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID.getColumnBitmask()) != 0) {
560 Object[] args = new Object[] {
561 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId())
562 };
563
564 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
565 args);
566 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
567 args);
568
569 args = new Object[] {
570 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId())
571 };
572
573 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
574 args);
575 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
576 args);
577 }
578
579 if ((layoutRevisionModelImpl.getColumnBitmask() &
580 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID.getColumnBitmask()) != 0) {
581 Object[] args = new Object[] {
582 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
583 };
584
585 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
586 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
587 args);
588
589 args = new Object[] {
590 Long.valueOf(layoutRevisionModelImpl.getPlid())
591 };
592
593 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
594 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
595 args);
596 }
597
598 if ((layoutRevisionModelImpl.getColumnBitmask() &
599 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H.getColumnBitmask()) != 0) {
600 Object[] args = new Object[] {
601 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
602 Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead())
603 };
604
605 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
606 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
607 args);
608
609 args = new Object[] {
610 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
611 Boolean.valueOf(layoutRevisionModelImpl.getHead())
612 };
613
614 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
615 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
616 args);
617 }
618
619 if ((layoutRevisionModelImpl.getColumnBitmask() &
620 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
621 Object[] args = new Object[] {
622 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
623 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
624 };
625
626 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
627 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
628 args);
629
630 args = new Object[] {
631 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
632 Long.valueOf(layoutRevisionModelImpl.getPlid())
633 };
634
635 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
636 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
637 args);
638 }
639
640 if ((layoutRevisionModelImpl.getColumnBitmask() &
641 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S.getColumnBitmask()) != 0) {
642 Object[] args = new Object[] {
643 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
644 Integer.valueOf(layoutRevisionModelImpl.getOriginalStatus())
645 };
646
647 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
648 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
649 args);
650
651 args = new Object[] {
652 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
653 Integer.valueOf(layoutRevisionModelImpl.getStatus())
654 };
655
656 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
657 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
658 args);
659 }
660
661 if ((layoutRevisionModelImpl.getColumnBitmask() &
662 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P.getColumnBitmask()) != 0) {
663 Object[] args = new Object[] {
664 Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead()),
665 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
666 };
667
668 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
669 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
670 args);
671
672 args = new Object[] {
673 Boolean.valueOf(layoutRevisionModelImpl.getHead()),
674 Long.valueOf(layoutRevisionModelImpl.getPlid())
675 };
676
677 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
678 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
679 args);
680 }
681
682 if ((layoutRevisionModelImpl.getColumnBitmask() &
683 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P.getColumnBitmask()) != 0) {
684 Object[] args = new Object[] {
685 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
686 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutBranchId()),
687 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
688 };
689
690 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_L_P, args);
691 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P,
692 args);
693
694 args = new Object[] {
695 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
696 Long.valueOf(layoutRevisionModelImpl.getLayoutBranchId()),
697 Long.valueOf(layoutRevisionModelImpl.getPlid())
698 };
699
700 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_L_P, args);
701 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P,
702 args);
703 }
704
705 if ((layoutRevisionModelImpl.getColumnBitmask() &
706 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P.getColumnBitmask()) != 0) {
707 Object[] args = new Object[] {
708 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
709 Long.valueOf(layoutRevisionModelImpl.getOriginalParentLayoutRevisionId()),
710 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
711 };
712
713 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_P, args);
714 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P,
715 args);
716
717 args = new Object[] {
718 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
719 Long.valueOf(layoutRevisionModelImpl.getParentLayoutRevisionId()),
720 Long.valueOf(layoutRevisionModelImpl.getPlid())
721 };
722
723 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_P, args);
724 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P,
725 args);
726 }
727
728 if ((layoutRevisionModelImpl.getColumnBitmask() &
729 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S.getColumnBitmask()) != 0) {
730 Object[] args = new Object[] {
731 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
732 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid()),
733 Integer.valueOf(layoutRevisionModelImpl.getOriginalStatus())
734 };
735
736 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_S, args);
737 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S,
738 args);
739
740 args = new Object[] {
741 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
742 Long.valueOf(layoutRevisionModelImpl.getPlid()),
743 Integer.valueOf(layoutRevisionModelImpl.getStatus())
744 };
745
746 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_S, args);
747 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S,
748 args);
749 }
750 }
751
752 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
753 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey(),
754 layoutRevision);
755
756 if (isNew) {
757 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
758 new Object[] {
759 Long.valueOf(layoutRevision.getLayoutSetBranchId()),
760 Boolean.valueOf(layoutRevision.getHead()),
761 Long.valueOf(layoutRevision.getPlid())
762 }, layoutRevision);
763 }
764 else {
765 if ((layoutRevisionModelImpl.getColumnBitmask() &
766 FINDER_PATH_FETCH_BY_L_H_P.getColumnBitmask()) != 0) {
767 Object[] args = new Object[] {
768 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
769 Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead()),
770 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
771 };
772
773 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H_P, args);
774
775 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P, args);
776
777 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
778 new Object[] {
779 Long.valueOf(layoutRevision.getLayoutSetBranchId()),
780 Boolean.valueOf(layoutRevision.getHead()),
781 Long.valueOf(layoutRevision.getPlid())
782 }, layoutRevision);
783 }
784 }
785
786 return layoutRevision;
787 }
788
789 protected LayoutRevision toUnwrappedModel(LayoutRevision layoutRevision) {
790 if (layoutRevision instanceof LayoutRevisionImpl) {
791 return layoutRevision;
792 }
793
794 LayoutRevisionImpl layoutRevisionImpl = new LayoutRevisionImpl();
795
796 layoutRevisionImpl.setNew(layoutRevision.isNew());
797 layoutRevisionImpl.setPrimaryKey(layoutRevision.getPrimaryKey());
798
799 layoutRevisionImpl.setLayoutRevisionId(layoutRevision.getLayoutRevisionId());
800 layoutRevisionImpl.setGroupId(layoutRevision.getGroupId());
801 layoutRevisionImpl.setCompanyId(layoutRevision.getCompanyId());
802 layoutRevisionImpl.setUserId(layoutRevision.getUserId());
803 layoutRevisionImpl.setUserName(layoutRevision.getUserName());
804 layoutRevisionImpl.setCreateDate(layoutRevision.getCreateDate());
805 layoutRevisionImpl.setModifiedDate(layoutRevision.getModifiedDate());
806 layoutRevisionImpl.setLayoutSetBranchId(layoutRevision.getLayoutSetBranchId());
807 layoutRevisionImpl.setLayoutBranchId(layoutRevision.getLayoutBranchId());
808 layoutRevisionImpl.setParentLayoutRevisionId(layoutRevision.getParentLayoutRevisionId());
809 layoutRevisionImpl.setHead(layoutRevision.isHead());
810 layoutRevisionImpl.setMajor(layoutRevision.isMajor());
811 layoutRevisionImpl.setPlid(layoutRevision.getPlid());
812 layoutRevisionImpl.setPrivateLayout(layoutRevision.isPrivateLayout());
813 layoutRevisionImpl.setName(layoutRevision.getName());
814 layoutRevisionImpl.setTitle(layoutRevision.getTitle());
815 layoutRevisionImpl.setDescription(layoutRevision.getDescription());
816 layoutRevisionImpl.setKeywords(layoutRevision.getKeywords());
817 layoutRevisionImpl.setRobots(layoutRevision.getRobots());
818 layoutRevisionImpl.setTypeSettings(layoutRevision.getTypeSettings());
819 layoutRevisionImpl.setIconImage(layoutRevision.isIconImage());
820 layoutRevisionImpl.setIconImageId(layoutRevision.getIconImageId());
821 layoutRevisionImpl.setThemeId(layoutRevision.getThemeId());
822 layoutRevisionImpl.setColorSchemeId(layoutRevision.getColorSchemeId());
823 layoutRevisionImpl.setWapThemeId(layoutRevision.getWapThemeId());
824 layoutRevisionImpl.setWapColorSchemeId(layoutRevision.getWapColorSchemeId());
825 layoutRevisionImpl.setCss(layoutRevision.getCss());
826 layoutRevisionImpl.setStatus(layoutRevision.getStatus());
827 layoutRevisionImpl.setStatusByUserId(layoutRevision.getStatusByUserId());
828 layoutRevisionImpl.setStatusByUserName(layoutRevision.getStatusByUserName());
829 layoutRevisionImpl.setStatusDate(layoutRevision.getStatusDate());
830
831 return layoutRevisionImpl;
832 }
833
834
842 @Override
843 public LayoutRevision findByPrimaryKey(Serializable primaryKey)
844 throws NoSuchModelException, SystemException {
845 return findByPrimaryKey(((Long)primaryKey).longValue());
846 }
847
848
856 public LayoutRevision findByPrimaryKey(long layoutRevisionId)
857 throws NoSuchLayoutRevisionException, SystemException {
858 LayoutRevision layoutRevision = fetchByPrimaryKey(layoutRevisionId);
859
860 if (layoutRevision == null) {
861 if (_log.isWarnEnabled()) {
862 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutRevisionId);
863 }
864
865 throw new NoSuchLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
866 layoutRevisionId);
867 }
868
869 return layoutRevision;
870 }
871
872
879 @Override
880 public LayoutRevision fetchByPrimaryKey(Serializable primaryKey)
881 throws SystemException {
882 return fetchByPrimaryKey(((Long)primaryKey).longValue());
883 }
884
885
892 public LayoutRevision fetchByPrimaryKey(long layoutRevisionId)
893 throws SystemException {
894 LayoutRevision layoutRevision = (LayoutRevision)EntityCacheUtil.getResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
895 LayoutRevisionImpl.class, layoutRevisionId);
896
897 if (layoutRevision == _nullLayoutRevision) {
898 return null;
899 }
900
901 if (layoutRevision == null) {
902 Session session = null;
903
904 boolean hasException = false;
905
906 try {
907 session = openSession();
908
909 layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
910 Long.valueOf(layoutRevisionId));
911 }
912 catch (Exception e) {
913 hasException = true;
914
915 throw processException(e);
916 }
917 finally {
918 if (layoutRevision != null) {
919 cacheResult(layoutRevision);
920 }
921 else if (!hasException) {
922 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
923 LayoutRevisionImpl.class, layoutRevisionId,
924 _nullLayoutRevision);
925 }
926
927 closeSession(session);
928 }
929 }
930
931 return layoutRevision;
932 }
933
934
941 public List<LayoutRevision> findByLayoutSetBranchId(long layoutSetBranchId)
942 throws SystemException {
943 return findByLayoutSetBranchId(layoutSetBranchId, QueryUtil.ALL_POS,
944 QueryUtil.ALL_POS, null);
945 }
946
947
960 public List<LayoutRevision> findByLayoutSetBranchId(
961 long layoutSetBranchId, int start, int end) throws SystemException {
962 return findByLayoutSetBranchId(layoutSetBranchId, start, end, null);
963 }
964
965
979 public List<LayoutRevision> findByLayoutSetBranchId(
980 long layoutSetBranchId, int start, int end,
981 OrderByComparator orderByComparator) throws SystemException {
982 FinderPath finderPath = null;
983 Object[] finderArgs = null;
984
985 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
986 (orderByComparator == null)) {
987 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
988 finderArgs = new Object[] { layoutSetBranchId };
989 }
990 else {
991 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
992 finderArgs = new Object[] {
993 layoutSetBranchId,
994
995 start, end, orderByComparator
996 };
997 }
998
999 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1000 finderArgs, this);
1001
1002 if ((list != null) && !list.isEmpty()) {
1003 for (LayoutRevision layoutRevision : list) {
1004 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId())) {
1005 list = null;
1006
1007 break;
1008 }
1009 }
1010 }
1011
1012 if (list == null) {
1013 StringBundler query = null;
1014
1015 if (orderByComparator != null) {
1016 query = new StringBundler(3 +
1017 (orderByComparator.getOrderByFields().length * 3));
1018 }
1019 else {
1020 query = new StringBundler(3);
1021 }
1022
1023 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1024
1025 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
1026
1027 if (orderByComparator != null) {
1028 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1029 orderByComparator);
1030 }
1031
1032 else {
1033 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1034 }
1035
1036 String sql = query.toString();
1037
1038 Session session = null;
1039
1040 try {
1041 session = openSession();
1042
1043 Query q = session.createQuery(sql);
1044
1045 QueryPos qPos = QueryPos.getInstance(q);
1046
1047 qPos.add(layoutSetBranchId);
1048
1049 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1050 start, end);
1051 }
1052 catch (Exception e) {
1053 throw processException(e);
1054 }
1055 finally {
1056 if (list == null) {
1057 FinderCacheUtil.removeResult(finderPath, finderArgs);
1058 }
1059 else {
1060 cacheResult(list);
1061
1062 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1063 }
1064
1065 closeSession(session);
1066 }
1067 }
1068
1069 return list;
1070 }
1071
1072
1081 public LayoutRevision findByLayoutSetBranchId_First(
1082 long layoutSetBranchId, OrderByComparator orderByComparator)
1083 throws NoSuchLayoutRevisionException, SystemException {
1084 LayoutRevision layoutRevision = fetchByLayoutSetBranchId_First(layoutSetBranchId,
1085 orderByComparator);
1086
1087 if (layoutRevision != null) {
1088 return layoutRevision;
1089 }
1090
1091 StringBundler msg = new StringBundler(4);
1092
1093 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1094
1095 msg.append("layoutSetBranchId=");
1096 msg.append(layoutSetBranchId);
1097
1098 msg.append(StringPool.CLOSE_CURLY_BRACE);
1099
1100 throw new NoSuchLayoutRevisionException(msg.toString());
1101 }
1102
1103
1111 public LayoutRevision fetchByLayoutSetBranchId_First(
1112 long layoutSetBranchId, OrderByComparator orderByComparator)
1113 throws SystemException {
1114 List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
1115 0, 1, orderByComparator);
1116
1117 if (!list.isEmpty()) {
1118 return list.get(0);
1119 }
1120
1121 return null;
1122 }
1123
1124
1133 public LayoutRevision findByLayoutSetBranchId_Last(long layoutSetBranchId,
1134 OrderByComparator orderByComparator)
1135 throws NoSuchLayoutRevisionException, SystemException {
1136 LayoutRevision layoutRevision = fetchByLayoutSetBranchId_Last(layoutSetBranchId,
1137 orderByComparator);
1138
1139 if (layoutRevision != null) {
1140 return layoutRevision;
1141 }
1142
1143 StringBundler msg = new StringBundler(4);
1144
1145 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146
1147 msg.append("layoutSetBranchId=");
1148 msg.append(layoutSetBranchId);
1149
1150 msg.append(StringPool.CLOSE_CURLY_BRACE);
1151
1152 throw new NoSuchLayoutRevisionException(msg.toString());
1153 }
1154
1155
1163 public LayoutRevision fetchByLayoutSetBranchId_Last(
1164 long layoutSetBranchId, OrderByComparator orderByComparator)
1165 throws SystemException {
1166 int count = countByLayoutSetBranchId(layoutSetBranchId);
1167
1168 List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
1169 count - 1, count, orderByComparator);
1170
1171 if (!list.isEmpty()) {
1172 return list.get(0);
1173 }
1174
1175 return null;
1176 }
1177
1178
1188 public LayoutRevision[] findByLayoutSetBranchId_PrevAndNext(
1189 long layoutRevisionId, long layoutSetBranchId,
1190 OrderByComparator orderByComparator)
1191 throws NoSuchLayoutRevisionException, SystemException {
1192 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1193
1194 Session session = null;
1195
1196 try {
1197 session = openSession();
1198
1199 LayoutRevision[] array = new LayoutRevisionImpl[3];
1200
1201 array[0] = getByLayoutSetBranchId_PrevAndNext(session,
1202 layoutRevision, layoutSetBranchId, orderByComparator, true);
1203
1204 array[1] = layoutRevision;
1205
1206 array[2] = getByLayoutSetBranchId_PrevAndNext(session,
1207 layoutRevision, layoutSetBranchId, orderByComparator, false);
1208
1209 return array;
1210 }
1211 catch (Exception e) {
1212 throw processException(e);
1213 }
1214 finally {
1215 closeSession(session);
1216 }
1217 }
1218
1219 protected LayoutRevision getByLayoutSetBranchId_PrevAndNext(
1220 Session session, LayoutRevision layoutRevision, long layoutSetBranchId,
1221 OrderByComparator orderByComparator, boolean previous) {
1222 StringBundler query = null;
1223
1224 if (orderByComparator != null) {
1225 query = new StringBundler(6 +
1226 (orderByComparator.getOrderByFields().length * 6));
1227 }
1228 else {
1229 query = new StringBundler(3);
1230 }
1231
1232 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1233
1234 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
1235
1236 if (orderByComparator != null) {
1237 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1238
1239 if (orderByConditionFields.length > 0) {
1240 query.append(WHERE_AND);
1241 }
1242
1243 for (int i = 0; i < orderByConditionFields.length; i++) {
1244 query.append(_ORDER_BY_ENTITY_ALIAS);
1245 query.append(orderByConditionFields[i]);
1246
1247 if ((i + 1) < orderByConditionFields.length) {
1248 if (orderByComparator.isAscending() ^ previous) {
1249 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1250 }
1251 else {
1252 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1253 }
1254 }
1255 else {
1256 if (orderByComparator.isAscending() ^ previous) {
1257 query.append(WHERE_GREATER_THAN);
1258 }
1259 else {
1260 query.append(WHERE_LESSER_THAN);
1261 }
1262 }
1263 }
1264
1265 query.append(ORDER_BY_CLAUSE);
1266
1267 String[] orderByFields = orderByComparator.getOrderByFields();
1268
1269 for (int i = 0; i < orderByFields.length; i++) {
1270 query.append(_ORDER_BY_ENTITY_ALIAS);
1271 query.append(orderByFields[i]);
1272
1273 if ((i + 1) < orderByFields.length) {
1274 if (orderByComparator.isAscending() ^ previous) {
1275 query.append(ORDER_BY_ASC_HAS_NEXT);
1276 }
1277 else {
1278 query.append(ORDER_BY_DESC_HAS_NEXT);
1279 }
1280 }
1281 else {
1282 if (orderByComparator.isAscending() ^ previous) {
1283 query.append(ORDER_BY_ASC);
1284 }
1285 else {
1286 query.append(ORDER_BY_DESC);
1287 }
1288 }
1289 }
1290 }
1291
1292 else {
1293 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1294 }
1295
1296 String sql = query.toString();
1297
1298 Query q = session.createQuery(sql);
1299
1300 q.setFirstResult(0);
1301 q.setMaxResults(2);
1302
1303 QueryPos qPos = QueryPos.getInstance(q);
1304
1305 qPos.add(layoutSetBranchId);
1306
1307 if (orderByComparator != null) {
1308 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1309
1310 for (Object value : values) {
1311 qPos.add(value);
1312 }
1313 }
1314
1315 List<LayoutRevision> list = q.list();
1316
1317 if (list.size() == 2) {
1318 return list.get(1);
1319 }
1320 else {
1321 return null;
1322 }
1323 }
1324
1325
1332 public List<LayoutRevision> findByPlid(long plid) throws SystemException {
1333 return findByPlid(plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1334 }
1335
1336
1349 public List<LayoutRevision> findByPlid(long plid, int start, int end)
1350 throws SystemException {
1351 return findByPlid(plid, start, end, null);
1352 }
1353
1354
1368 public List<LayoutRevision> findByPlid(long plid, int start, int end,
1369 OrderByComparator orderByComparator) throws SystemException {
1370 FinderPath finderPath = null;
1371 Object[] finderArgs = null;
1372
1373 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1374 (orderByComparator == null)) {
1375 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID;
1376 finderArgs = new Object[] { plid };
1377 }
1378 else {
1379 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID;
1380 finderArgs = new Object[] { plid, start, end, orderByComparator };
1381 }
1382
1383 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1384 finderArgs, this);
1385
1386 if ((list != null) && !list.isEmpty()) {
1387 for (LayoutRevision layoutRevision : list) {
1388 if ((plid != layoutRevision.getPlid())) {
1389 list = null;
1390
1391 break;
1392 }
1393 }
1394 }
1395
1396 if (list == null) {
1397 StringBundler query = null;
1398
1399 if (orderByComparator != null) {
1400 query = new StringBundler(3 +
1401 (orderByComparator.getOrderByFields().length * 3));
1402 }
1403 else {
1404 query = new StringBundler(3);
1405 }
1406
1407 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1408
1409 query.append(_FINDER_COLUMN_PLID_PLID_2);
1410
1411 if (orderByComparator != null) {
1412 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1413 orderByComparator);
1414 }
1415
1416 else {
1417 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1418 }
1419
1420 String sql = query.toString();
1421
1422 Session session = null;
1423
1424 try {
1425 session = openSession();
1426
1427 Query q = session.createQuery(sql);
1428
1429 QueryPos qPos = QueryPos.getInstance(q);
1430
1431 qPos.add(plid);
1432
1433 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1434 start, end);
1435 }
1436 catch (Exception e) {
1437 throw processException(e);
1438 }
1439 finally {
1440 if (list == null) {
1441 FinderCacheUtil.removeResult(finderPath, finderArgs);
1442 }
1443 else {
1444 cacheResult(list);
1445
1446 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1447 }
1448
1449 closeSession(session);
1450 }
1451 }
1452
1453 return list;
1454 }
1455
1456
1465 public LayoutRevision findByPlid_First(long plid,
1466 OrderByComparator orderByComparator)
1467 throws NoSuchLayoutRevisionException, SystemException {
1468 LayoutRevision layoutRevision = fetchByPlid_First(plid,
1469 orderByComparator);
1470
1471 if (layoutRevision != null) {
1472 return layoutRevision;
1473 }
1474
1475 StringBundler msg = new StringBundler(4);
1476
1477 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1478
1479 msg.append("plid=");
1480 msg.append(plid);
1481
1482 msg.append(StringPool.CLOSE_CURLY_BRACE);
1483
1484 throw new NoSuchLayoutRevisionException(msg.toString());
1485 }
1486
1487
1495 public LayoutRevision fetchByPlid_First(long plid,
1496 OrderByComparator orderByComparator) throws SystemException {
1497 List<LayoutRevision> list = findByPlid(plid, 0, 1, orderByComparator);
1498
1499 if (!list.isEmpty()) {
1500 return list.get(0);
1501 }
1502
1503 return null;
1504 }
1505
1506
1515 public LayoutRevision findByPlid_Last(long plid,
1516 OrderByComparator orderByComparator)
1517 throws NoSuchLayoutRevisionException, SystemException {
1518 LayoutRevision layoutRevision = fetchByPlid_Last(plid, orderByComparator);
1519
1520 if (layoutRevision != null) {
1521 return layoutRevision;
1522 }
1523
1524 StringBundler msg = new StringBundler(4);
1525
1526 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1527
1528 msg.append("plid=");
1529 msg.append(plid);
1530
1531 msg.append(StringPool.CLOSE_CURLY_BRACE);
1532
1533 throw new NoSuchLayoutRevisionException(msg.toString());
1534 }
1535
1536
1544 public LayoutRevision fetchByPlid_Last(long plid,
1545 OrderByComparator orderByComparator) throws SystemException {
1546 int count = countByPlid(plid);
1547
1548 List<LayoutRevision> list = findByPlid(plid, count - 1, count,
1549 orderByComparator);
1550
1551 if (!list.isEmpty()) {
1552 return list.get(0);
1553 }
1554
1555 return null;
1556 }
1557
1558
1568 public LayoutRevision[] findByPlid_PrevAndNext(long layoutRevisionId,
1569 long plid, OrderByComparator orderByComparator)
1570 throws NoSuchLayoutRevisionException, SystemException {
1571 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1572
1573 Session session = null;
1574
1575 try {
1576 session = openSession();
1577
1578 LayoutRevision[] array = new LayoutRevisionImpl[3];
1579
1580 array[0] = getByPlid_PrevAndNext(session, layoutRevision, plid,
1581 orderByComparator, true);
1582
1583 array[1] = layoutRevision;
1584
1585 array[2] = getByPlid_PrevAndNext(session, layoutRevision, plid,
1586 orderByComparator, false);
1587
1588 return array;
1589 }
1590 catch (Exception e) {
1591 throw processException(e);
1592 }
1593 finally {
1594 closeSession(session);
1595 }
1596 }
1597
1598 protected LayoutRevision getByPlid_PrevAndNext(Session session,
1599 LayoutRevision layoutRevision, long plid,
1600 OrderByComparator orderByComparator, boolean previous) {
1601 StringBundler query = null;
1602
1603 if (orderByComparator != null) {
1604 query = new StringBundler(6 +
1605 (orderByComparator.getOrderByFields().length * 6));
1606 }
1607 else {
1608 query = new StringBundler(3);
1609 }
1610
1611 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1612
1613 query.append(_FINDER_COLUMN_PLID_PLID_2);
1614
1615 if (orderByComparator != null) {
1616 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1617
1618 if (orderByConditionFields.length > 0) {
1619 query.append(WHERE_AND);
1620 }
1621
1622 for (int i = 0; i < orderByConditionFields.length; i++) {
1623 query.append(_ORDER_BY_ENTITY_ALIAS);
1624 query.append(orderByConditionFields[i]);
1625
1626 if ((i + 1) < orderByConditionFields.length) {
1627 if (orderByComparator.isAscending() ^ previous) {
1628 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1629 }
1630 else {
1631 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1632 }
1633 }
1634 else {
1635 if (orderByComparator.isAscending() ^ previous) {
1636 query.append(WHERE_GREATER_THAN);
1637 }
1638 else {
1639 query.append(WHERE_LESSER_THAN);
1640 }
1641 }
1642 }
1643
1644 query.append(ORDER_BY_CLAUSE);
1645
1646 String[] orderByFields = orderByComparator.getOrderByFields();
1647
1648 for (int i = 0; i < orderByFields.length; i++) {
1649 query.append(_ORDER_BY_ENTITY_ALIAS);
1650 query.append(orderByFields[i]);
1651
1652 if ((i + 1) < orderByFields.length) {
1653 if (orderByComparator.isAscending() ^ previous) {
1654 query.append(ORDER_BY_ASC_HAS_NEXT);
1655 }
1656 else {
1657 query.append(ORDER_BY_DESC_HAS_NEXT);
1658 }
1659 }
1660 else {
1661 if (orderByComparator.isAscending() ^ previous) {
1662 query.append(ORDER_BY_ASC);
1663 }
1664 else {
1665 query.append(ORDER_BY_DESC);
1666 }
1667 }
1668 }
1669 }
1670
1671 else {
1672 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1673 }
1674
1675 String sql = query.toString();
1676
1677 Query q = session.createQuery(sql);
1678
1679 q.setFirstResult(0);
1680 q.setMaxResults(2);
1681
1682 QueryPos qPos = QueryPos.getInstance(q);
1683
1684 qPos.add(plid);
1685
1686 if (orderByComparator != null) {
1687 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1688
1689 for (Object value : values) {
1690 qPos.add(value);
1691 }
1692 }
1693
1694 List<LayoutRevision> list = q.list();
1695
1696 if (list.size() == 2) {
1697 return list.get(1);
1698 }
1699 else {
1700 return null;
1701 }
1702 }
1703
1704
1712 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head)
1713 throws SystemException {
1714 return findByL_H(layoutSetBranchId, head, QueryUtil.ALL_POS,
1715 QueryUtil.ALL_POS, null);
1716 }
1717
1718
1732 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1733 int start, int end) throws SystemException {
1734 return findByL_H(layoutSetBranchId, head, start, end, null);
1735 }
1736
1737
1752 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1753 int start, int end, OrderByComparator orderByComparator)
1754 throws SystemException {
1755 FinderPath finderPath = null;
1756 Object[] finderArgs = null;
1757
1758 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1759 (orderByComparator == null)) {
1760 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H;
1761 finderArgs = new Object[] { layoutSetBranchId, head };
1762 }
1763 else {
1764 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_H;
1765 finderArgs = new Object[] {
1766 layoutSetBranchId, head,
1767
1768 start, end, orderByComparator
1769 };
1770 }
1771
1772 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1773 finderArgs, this);
1774
1775 if ((list != null) && !list.isEmpty()) {
1776 for (LayoutRevision layoutRevision : list) {
1777 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
1778 (head != layoutRevision.getHead())) {
1779 list = null;
1780
1781 break;
1782 }
1783 }
1784 }
1785
1786 if (list == null) {
1787 StringBundler query = null;
1788
1789 if (orderByComparator != null) {
1790 query = new StringBundler(4 +
1791 (orderByComparator.getOrderByFields().length * 3));
1792 }
1793 else {
1794 query = new StringBundler(4);
1795 }
1796
1797 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1798
1799 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
1800
1801 query.append(_FINDER_COLUMN_L_H_HEAD_2);
1802
1803 if (orderByComparator != null) {
1804 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1805 orderByComparator);
1806 }
1807
1808 else {
1809 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1810 }
1811
1812 String sql = query.toString();
1813
1814 Session session = null;
1815
1816 try {
1817 session = openSession();
1818
1819 Query q = session.createQuery(sql);
1820
1821 QueryPos qPos = QueryPos.getInstance(q);
1822
1823 qPos.add(layoutSetBranchId);
1824
1825 qPos.add(head);
1826
1827 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1828 start, end);
1829 }
1830 catch (Exception e) {
1831 throw processException(e);
1832 }
1833 finally {
1834 if (list == null) {
1835 FinderCacheUtil.removeResult(finderPath, finderArgs);
1836 }
1837 else {
1838 cacheResult(list);
1839
1840 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1841 }
1842
1843 closeSession(session);
1844 }
1845 }
1846
1847 return list;
1848 }
1849
1850
1860 public LayoutRevision findByL_H_First(long layoutSetBranchId, boolean head,
1861 OrderByComparator orderByComparator)
1862 throws NoSuchLayoutRevisionException, SystemException {
1863 LayoutRevision layoutRevision = fetchByL_H_First(layoutSetBranchId,
1864 head, orderByComparator);
1865
1866 if (layoutRevision != null) {
1867 return layoutRevision;
1868 }
1869
1870 StringBundler msg = new StringBundler(6);
1871
1872 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1873
1874 msg.append("layoutSetBranchId=");
1875 msg.append(layoutSetBranchId);
1876
1877 msg.append(", head=");
1878 msg.append(head);
1879
1880 msg.append(StringPool.CLOSE_CURLY_BRACE);
1881
1882 throw new NoSuchLayoutRevisionException(msg.toString());
1883 }
1884
1885
1894 public LayoutRevision fetchByL_H_First(long layoutSetBranchId,
1895 boolean head, OrderByComparator orderByComparator)
1896 throws SystemException {
1897 List<LayoutRevision> list = findByL_H(layoutSetBranchId, head, 0, 1,
1898 orderByComparator);
1899
1900 if (!list.isEmpty()) {
1901 return list.get(0);
1902 }
1903
1904 return null;
1905 }
1906
1907
1917 public LayoutRevision findByL_H_Last(long layoutSetBranchId, boolean head,
1918 OrderByComparator orderByComparator)
1919 throws NoSuchLayoutRevisionException, SystemException {
1920 LayoutRevision layoutRevision = fetchByL_H_Last(layoutSetBranchId,
1921 head, orderByComparator);
1922
1923 if (layoutRevision != null) {
1924 return layoutRevision;
1925 }
1926
1927 StringBundler msg = new StringBundler(6);
1928
1929 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1930
1931 msg.append("layoutSetBranchId=");
1932 msg.append(layoutSetBranchId);
1933
1934 msg.append(", head=");
1935 msg.append(head);
1936
1937 msg.append(StringPool.CLOSE_CURLY_BRACE);
1938
1939 throw new NoSuchLayoutRevisionException(msg.toString());
1940 }
1941
1942
1951 public LayoutRevision fetchByL_H_Last(long layoutSetBranchId, boolean head,
1952 OrderByComparator orderByComparator) throws SystemException {
1953 int count = countByL_H(layoutSetBranchId, head);
1954
1955 List<LayoutRevision> list = findByL_H(layoutSetBranchId, head,
1956 count - 1, count, orderByComparator);
1957
1958 if (!list.isEmpty()) {
1959 return list.get(0);
1960 }
1961
1962 return null;
1963 }
1964
1965
1976 public LayoutRevision[] findByL_H_PrevAndNext(long layoutRevisionId,
1977 long layoutSetBranchId, boolean head,
1978 OrderByComparator orderByComparator)
1979 throws NoSuchLayoutRevisionException, SystemException {
1980 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1981
1982 Session session = null;
1983
1984 try {
1985 session = openSession();
1986
1987 LayoutRevision[] array = new LayoutRevisionImpl[3];
1988
1989 array[0] = getByL_H_PrevAndNext(session, layoutRevision,
1990 layoutSetBranchId, head, orderByComparator, true);
1991
1992 array[1] = layoutRevision;
1993
1994 array[2] = getByL_H_PrevAndNext(session, layoutRevision,
1995 layoutSetBranchId, head, orderByComparator, false);
1996
1997 return array;
1998 }
1999 catch (Exception e) {
2000 throw processException(e);
2001 }
2002 finally {
2003 closeSession(session);
2004 }
2005 }
2006
2007 protected LayoutRevision getByL_H_PrevAndNext(Session session,
2008 LayoutRevision layoutRevision, long layoutSetBranchId, boolean head,
2009 OrderByComparator orderByComparator, boolean previous) {
2010 StringBundler query = null;
2011
2012 if (orderByComparator != null) {
2013 query = new StringBundler(6 +
2014 (orderByComparator.getOrderByFields().length * 6));
2015 }
2016 else {
2017 query = new StringBundler(3);
2018 }
2019
2020 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2021
2022 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
2023
2024 query.append(_FINDER_COLUMN_L_H_HEAD_2);
2025
2026 if (orderByComparator != null) {
2027 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2028
2029 if (orderByConditionFields.length > 0) {
2030 query.append(WHERE_AND);
2031 }
2032
2033 for (int i = 0; i < orderByConditionFields.length; i++) {
2034 query.append(_ORDER_BY_ENTITY_ALIAS);
2035 query.append(orderByConditionFields[i]);
2036
2037 if ((i + 1) < orderByConditionFields.length) {
2038 if (orderByComparator.isAscending() ^ previous) {
2039 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2040 }
2041 else {
2042 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2043 }
2044 }
2045 else {
2046 if (orderByComparator.isAscending() ^ previous) {
2047 query.append(WHERE_GREATER_THAN);
2048 }
2049 else {
2050 query.append(WHERE_LESSER_THAN);
2051 }
2052 }
2053 }
2054
2055 query.append(ORDER_BY_CLAUSE);
2056
2057 String[] orderByFields = orderByComparator.getOrderByFields();
2058
2059 for (int i = 0; i < orderByFields.length; i++) {
2060 query.append(_ORDER_BY_ENTITY_ALIAS);
2061 query.append(orderByFields[i]);
2062
2063 if ((i + 1) < orderByFields.length) {
2064 if (orderByComparator.isAscending() ^ previous) {
2065 query.append(ORDER_BY_ASC_HAS_NEXT);
2066 }
2067 else {
2068 query.append(ORDER_BY_DESC_HAS_NEXT);
2069 }
2070 }
2071 else {
2072 if (orderByComparator.isAscending() ^ previous) {
2073 query.append(ORDER_BY_ASC);
2074 }
2075 else {
2076 query.append(ORDER_BY_DESC);
2077 }
2078 }
2079 }
2080 }
2081
2082 else {
2083 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2084 }
2085
2086 String sql = query.toString();
2087
2088 Query q = session.createQuery(sql);
2089
2090 q.setFirstResult(0);
2091 q.setMaxResults(2);
2092
2093 QueryPos qPos = QueryPos.getInstance(q);
2094
2095 qPos.add(layoutSetBranchId);
2096
2097 qPos.add(head);
2098
2099 if (orderByComparator != null) {
2100 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2101
2102 for (Object value : values) {
2103 qPos.add(value);
2104 }
2105 }
2106
2107 List<LayoutRevision> list = q.list();
2108
2109 if (list.size() == 2) {
2110 return list.get(1);
2111 }
2112 else {
2113 return null;
2114 }
2115 }
2116
2117
2125 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid)
2126 throws SystemException {
2127 return findByL_P(layoutSetBranchId, plid, QueryUtil.ALL_POS,
2128 QueryUtil.ALL_POS, null);
2129 }
2130
2131
2145 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
2146 int start, int end) throws SystemException {
2147 return findByL_P(layoutSetBranchId, plid, start, end, null);
2148 }
2149
2150
2165 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
2166 int start, int end, OrderByComparator orderByComparator)
2167 throws SystemException {
2168 FinderPath finderPath = null;
2169 Object[] finderArgs = null;
2170
2171 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2172 (orderByComparator == null)) {
2173 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
2174 finderArgs = new Object[] { layoutSetBranchId, plid };
2175 }
2176 else {
2177 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
2178 finderArgs = new Object[] {
2179 layoutSetBranchId, plid,
2180
2181 start, end, orderByComparator
2182 };
2183 }
2184
2185 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2186 finderArgs, this);
2187
2188 if ((list != null) && !list.isEmpty()) {
2189 for (LayoutRevision layoutRevision : list) {
2190 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
2191 (plid != layoutRevision.getPlid())) {
2192 list = null;
2193
2194 break;
2195 }
2196 }
2197 }
2198
2199 if (list == null) {
2200 StringBundler query = null;
2201
2202 if (orderByComparator != null) {
2203 query = new StringBundler(4 +
2204 (orderByComparator.getOrderByFields().length * 3));
2205 }
2206 else {
2207 query = new StringBundler(4);
2208 }
2209
2210 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2211
2212 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
2213
2214 query.append(_FINDER_COLUMN_L_P_PLID_2);
2215
2216 if (orderByComparator != null) {
2217 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2218 orderByComparator);
2219 }
2220
2221 else {
2222 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2223 }
2224
2225 String sql = query.toString();
2226
2227 Session session = null;
2228
2229 try {
2230 session = openSession();
2231
2232 Query q = session.createQuery(sql);
2233
2234 QueryPos qPos = QueryPos.getInstance(q);
2235
2236 qPos.add(layoutSetBranchId);
2237
2238 qPos.add(plid);
2239
2240 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
2241 start, end);
2242 }
2243 catch (Exception e) {
2244 throw processException(e);
2245 }
2246 finally {
2247 if (list == null) {
2248 FinderCacheUtil.removeResult(finderPath, finderArgs);
2249 }
2250 else {
2251 cacheResult(list);
2252
2253 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2254 }
2255
2256 closeSession(session);
2257 }
2258 }
2259
2260 return list;
2261 }
2262
2263
2273 public LayoutRevision findByL_P_First(long layoutSetBranchId, long plid,
2274 OrderByComparator orderByComparator)
2275 throws NoSuchLayoutRevisionException, SystemException {
2276 LayoutRevision layoutRevision = fetchByL_P_First(layoutSetBranchId,
2277 plid, orderByComparator);
2278
2279 if (layoutRevision != null) {
2280 return layoutRevision;
2281 }
2282
2283 StringBundler msg = new StringBundler(6);
2284
2285 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2286
2287 msg.append("layoutSetBranchId=");
2288 msg.append(layoutSetBranchId);
2289
2290 msg.append(", plid=");
2291 msg.append(plid);
2292
2293 msg.append(StringPool.CLOSE_CURLY_BRACE);
2294
2295 throw new NoSuchLayoutRevisionException(msg.toString());
2296 }
2297
2298
2307 public LayoutRevision fetchByL_P_First(long layoutSetBranchId, long plid,
2308 OrderByComparator orderByComparator) throws SystemException {
2309 List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid, 0, 1,
2310 orderByComparator);
2311
2312 if (!list.isEmpty()) {
2313 return list.get(0);
2314 }
2315
2316 return null;
2317 }
2318
2319
2329 public LayoutRevision findByL_P_Last(long layoutSetBranchId, long plid,
2330 OrderByComparator orderByComparator)
2331 throws NoSuchLayoutRevisionException, SystemException {
2332 LayoutRevision layoutRevision = fetchByL_P_Last(layoutSetBranchId,
2333 plid, orderByComparator);
2334
2335 if (layoutRevision != null) {
2336 return layoutRevision;
2337 }
2338
2339 StringBundler msg = new StringBundler(6);
2340
2341 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2342
2343 msg.append("layoutSetBranchId=");
2344 msg.append(layoutSetBranchId);
2345
2346 msg.append(", plid=");
2347 msg.append(plid);
2348
2349 msg.append(StringPool.CLOSE_CURLY_BRACE);
2350
2351 throw new NoSuchLayoutRevisionException(msg.toString());
2352 }
2353
2354
2363 public LayoutRevision fetchByL_P_Last(long layoutSetBranchId, long plid,
2364 OrderByComparator orderByComparator) throws SystemException {
2365 int count = countByL_P(layoutSetBranchId, plid);
2366
2367 List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid,
2368 count - 1, count, orderByComparator);
2369
2370 if (!list.isEmpty()) {
2371 return list.get(0);
2372 }
2373
2374 return null;
2375 }
2376
2377
2388 public LayoutRevision[] findByL_P_PrevAndNext(long layoutRevisionId,
2389 long layoutSetBranchId, long plid, OrderByComparator orderByComparator)
2390 throws NoSuchLayoutRevisionException, SystemException {
2391 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2392
2393 Session session = null;
2394
2395 try {
2396 session = openSession();
2397
2398 LayoutRevision[] array = new LayoutRevisionImpl[3];
2399
2400 array[0] = getByL_P_PrevAndNext(session, layoutRevision,
2401 layoutSetBranchId, plid, orderByComparator, true);
2402
2403 array[1] = layoutRevision;
2404
2405 array[2] = getByL_P_PrevAndNext(session, layoutRevision,
2406 layoutSetBranchId, plid, orderByComparator, false);
2407
2408 return array;
2409 }
2410 catch (Exception e) {
2411 throw processException(e);
2412 }
2413 finally {
2414 closeSession(session);
2415 }
2416 }
2417
2418 protected LayoutRevision getByL_P_PrevAndNext(Session session,
2419 LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
2420 OrderByComparator orderByComparator, boolean previous) {
2421 StringBundler query = null;
2422
2423 if (orderByComparator != null) {
2424 query = new StringBundler(6 +
2425 (orderByComparator.getOrderByFields().length * 6));
2426 }
2427 else {
2428 query = new StringBundler(3);
2429 }
2430
2431 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2432
2433 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
2434
2435 query.append(_FINDER_COLUMN_L_P_PLID_2);
2436
2437 if (orderByComparator != null) {
2438 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2439
2440 if (orderByConditionFields.length > 0) {
2441 query.append(WHERE_AND);
2442 }
2443
2444 for (int i = 0; i < orderByConditionFields.length; i++) {
2445 query.append(_ORDER_BY_ENTITY_ALIAS);
2446 query.append(orderByConditionFields[i]);
2447
2448 if ((i + 1) < orderByConditionFields.length) {
2449 if (orderByComparator.isAscending() ^ previous) {
2450 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2451 }
2452 else {
2453 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2454 }
2455 }
2456 else {
2457 if (orderByComparator.isAscending() ^ previous) {
2458 query.append(WHERE_GREATER_THAN);
2459 }
2460 else {
2461 query.append(WHERE_LESSER_THAN);
2462 }
2463 }
2464 }
2465
2466 query.append(ORDER_BY_CLAUSE);
2467
2468 String[] orderByFields = orderByComparator.getOrderByFields();
2469
2470 for (int i = 0; i < orderByFields.length; i++) {
2471 query.append(_ORDER_BY_ENTITY_ALIAS);
2472 query.append(orderByFields[i]);
2473
2474 if ((i + 1) < orderByFields.length) {
2475 if (orderByComparator.isAscending() ^ previous) {
2476 query.append(ORDER_BY_ASC_HAS_NEXT);
2477 }
2478 else {
2479 query.append(ORDER_BY_DESC_HAS_NEXT);
2480 }
2481 }
2482 else {
2483 if (orderByComparator.isAscending() ^ previous) {
2484 query.append(ORDER_BY_ASC);
2485 }
2486 else {
2487 query.append(ORDER_BY_DESC);
2488 }
2489 }
2490 }
2491 }
2492
2493 else {
2494 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2495 }
2496
2497 String sql = query.toString();
2498
2499 Query q = session.createQuery(sql);
2500
2501 q.setFirstResult(0);
2502 q.setMaxResults(2);
2503
2504 QueryPos qPos = QueryPos.getInstance(q);
2505
2506 qPos.add(layoutSetBranchId);
2507
2508 qPos.add(plid);
2509
2510 if (orderByComparator != null) {
2511 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2512
2513 for (Object value : values) {
2514 qPos.add(value);
2515 }
2516 }
2517
2518 List<LayoutRevision> list = q.list();
2519
2520 if (list.size() == 2) {
2521 return list.get(1);
2522 }
2523 else {
2524 return null;
2525 }
2526 }
2527
2528
2536 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status)
2537 throws SystemException {
2538 return findByL_S(layoutSetBranchId, status, QueryUtil.ALL_POS,
2539 QueryUtil.ALL_POS, null);
2540 }
2541
2542
2556 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2557 int start, int end) throws SystemException {
2558 return findByL_S(layoutSetBranchId, status, start, end, null);
2559 }
2560
2561
2576 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2577 int start, int end, OrderByComparator orderByComparator)
2578 throws SystemException {
2579 FinderPath finderPath = null;
2580 Object[] finderArgs = null;
2581
2582 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2583 (orderByComparator == null)) {
2584 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S;
2585 finderArgs = new Object[] { layoutSetBranchId, status };
2586 }
2587 else {
2588 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_S;
2589 finderArgs = new Object[] {
2590 layoutSetBranchId, status,
2591
2592 start, end, orderByComparator
2593 };
2594 }
2595
2596 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2597 finderArgs, this);
2598
2599 if ((list != null) && !list.isEmpty()) {
2600 for (LayoutRevision layoutRevision : list) {
2601 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
2602 (status != layoutRevision.getStatus())) {
2603 list = null;
2604
2605 break;
2606 }
2607 }
2608 }
2609
2610 if (list == null) {
2611 StringBundler query = null;
2612
2613 if (orderByComparator != null) {
2614 query = new StringBundler(4 +
2615 (orderByComparator.getOrderByFields().length * 3));
2616 }
2617 else {
2618 query = new StringBundler(4);
2619 }
2620
2621 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2622
2623 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2624
2625 query.append(_FINDER_COLUMN_L_S_STATUS_2);
2626
2627 if (orderByComparator != null) {
2628 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2629 orderByComparator);
2630 }
2631
2632 else {
2633 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2634 }
2635
2636 String sql = query.toString();
2637
2638 Session session = null;
2639
2640 try {
2641 session = openSession();
2642
2643 Query q = session.createQuery(sql);
2644
2645 QueryPos qPos = QueryPos.getInstance(q);
2646
2647 qPos.add(layoutSetBranchId);
2648
2649 qPos.add(status);
2650
2651 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
2652 start, end);
2653 }
2654 catch (Exception e) {
2655 throw processException(e);
2656 }
2657 finally {
2658 if (list == null) {
2659 FinderCacheUtil.removeResult(finderPath, finderArgs);
2660 }
2661 else {
2662 cacheResult(list);
2663
2664 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2665 }
2666
2667 closeSession(session);
2668 }
2669 }
2670
2671 return list;
2672 }
2673
2674
2684 public LayoutRevision findByL_S_First(long layoutSetBranchId, int status,
2685 OrderByComparator orderByComparator)
2686 throws NoSuchLayoutRevisionException, SystemException {
2687 LayoutRevision layoutRevision = fetchByL_S_First(layoutSetBranchId,
2688 status, orderByComparator);
2689
2690 if (layoutRevision != null) {
2691 return layoutRevision;
2692 }
2693
2694 StringBundler msg = new StringBundler(6);
2695
2696 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2697
2698 msg.append("layoutSetBranchId=");
2699 msg.append(layoutSetBranchId);
2700
2701 msg.append(", status=");
2702 msg.append(status);
2703
2704 msg.append(StringPool.CLOSE_CURLY_BRACE);
2705
2706 throw new NoSuchLayoutRevisionException(msg.toString());
2707 }
2708
2709
2718 public LayoutRevision fetchByL_S_First(long layoutSetBranchId, int status,
2719 OrderByComparator orderByComparator) throws SystemException {
2720 List<LayoutRevision> list = findByL_S(layoutSetBranchId, status, 0, 1,
2721 orderByComparator);
2722
2723 if (!list.isEmpty()) {
2724 return list.get(0);
2725 }
2726
2727 return null;
2728 }
2729
2730
2740 public LayoutRevision findByL_S_Last(long layoutSetBranchId, int status,
2741 OrderByComparator orderByComparator)
2742 throws NoSuchLayoutRevisionException, SystemException {
2743 LayoutRevision layoutRevision = fetchByL_S_Last(layoutSetBranchId,
2744 status, orderByComparator);
2745
2746 if (layoutRevision != null) {
2747 return layoutRevision;
2748 }
2749
2750 StringBundler msg = new StringBundler(6);
2751
2752 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2753
2754 msg.append("layoutSetBranchId=");
2755 msg.append(layoutSetBranchId);
2756
2757 msg.append(", status=");
2758 msg.append(status);
2759
2760 msg.append(StringPool.CLOSE_CURLY_BRACE);
2761
2762 throw new NoSuchLayoutRevisionException(msg.toString());
2763 }
2764
2765
2774 public LayoutRevision fetchByL_S_Last(long layoutSetBranchId, int status,
2775 OrderByComparator orderByComparator) throws SystemException {
2776 int count = countByL_S(layoutSetBranchId, status);
2777
2778 List<LayoutRevision> list = findByL_S(layoutSetBranchId, status,
2779 count - 1, count, orderByComparator);
2780
2781 if (!list.isEmpty()) {
2782 return list.get(0);
2783 }
2784
2785 return null;
2786 }
2787
2788
2799 public LayoutRevision[] findByL_S_PrevAndNext(long layoutRevisionId,
2800 long layoutSetBranchId, int status, OrderByComparator orderByComparator)
2801 throws NoSuchLayoutRevisionException, SystemException {
2802 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2803
2804 Session session = null;
2805
2806 try {
2807 session = openSession();
2808
2809 LayoutRevision[] array = new LayoutRevisionImpl[3];
2810
2811 array[0] = getByL_S_PrevAndNext(session, layoutRevision,
2812 layoutSetBranchId, status, orderByComparator, true);
2813
2814 array[1] = layoutRevision;
2815
2816 array[2] = getByL_S_PrevAndNext(session, layoutRevision,
2817 layoutSetBranchId, status, orderByComparator, false);
2818
2819 return array;
2820 }
2821 catch (Exception e) {
2822 throw processException(e);
2823 }
2824 finally {
2825 closeSession(session);
2826 }
2827 }
2828
2829 protected LayoutRevision getByL_S_PrevAndNext(Session session,
2830 LayoutRevision layoutRevision, long layoutSetBranchId, int status,
2831 OrderByComparator orderByComparator, boolean previous) {
2832 StringBundler query = null;
2833
2834 if (orderByComparator != null) {
2835 query = new StringBundler(6 +
2836 (orderByComparator.getOrderByFields().length * 6));
2837 }
2838 else {
2839 query = new StringBundler(3);
2840 }
2841
2842 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2843
2844 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2845
2846 query.append(_FINDER_COLUMN_L_S_STATUS_2);
2847
2848 if (orderByComparator != null) {
2849 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2850
2851 if (orderByConditionFields.length > 0) {
2852 query.append(WHERE_AND);
2853 }
2854
2855 for (int i = 0; i < orderByConditionFields.length; i++) {
2856 query.append(_ORDER_BY_ENTITY_ALIAS);
2857 query.append(orderByConditionFields[i]);
2858
2859 if ((i + 1) < orderByConditionFields.length) {
2860 if (orderByComparator.isAscending() ^ previous) {
2861 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2862 }
2863 else {
2864 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2865 }
2866 }
2867 else {
2868 if (orderByComparator.isAscending() ^ previous) {
2869 query.append(WHERE_GREATER_THAN);
2870 }
2871 else {
2872 query.append(WHERE_LESSER_THAN);
2873 }
2874 }
2875 }
2876
2877 query.append(ORDER_BY_CLAUSE);
2878
2879 String[] orderByFields = orderByComparator.getOrderByFields();
2880
2881 for (int i = 0; i < orderByFields.length; i++) {
2882 query.append(_ORDER_BY_ENTITY_ALIAS);
2883 query.append(orderByFields[i]);
2884
2885 if ((i + 1) < orderByFields.length) {
2886 if (orderByComparator.isAscending() ^ previous) {
2887 query.append(ORDER_BY_ASC_HAS_NEXT);
2888 }
2889 else {
2890 query.append(ORDER_BY_DESC_HAS_NEXT);
2891 }
2892 }
2893 else {
2894 if (orderByComparator.isAscending() ^ previous) {
2895 query.append(ORDER_BY_ASC);
2896 }
2897 else {
2898 query.append(ORDER_BY_DESC);
2899 }
2900 }
2901 }
2902 }
2903
2904 else {
2905 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2906 }
2907
2908 String sql = query.toString();
2909
2910 Query q = session.createQuery(sql);
2911
2912 q.setFirstResult(0);
2913 q.setMaxResults(2);
2914
2915 QueryPos qPos = QueryPos.getInstance(q);
2916
2917 qPos.add(layoutSetBranchId);
2918
2919 qPos.add(status);
2920
2921 if (orderByComparator != null) {
2922 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2923
2924 for (Object value : values) {
2925 qPos.add(value);
2926 }
2927 }
2928
2929 List<LayoutRevision> list = q.list();
2930
2931 if (list.size() == 2) {
2932 return list.get(1);
2933 }
2934 else {
2935 return null;
2936 }
2937 }
2938
2939
2947 public List<LayoutRevision> findByH_P(boolean head, long plid)
2948 throws SystemException {
2949 return findByH_P(head, plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2950 }
2951
2952
2966 public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2967 int end) throws SystemException {
2968 return findByH_P(head, plid, start, end, null);
2969 }
2970
2971
2986 public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2987 int end, OrderByComparator orderByComparator) throws SystemException {
2988 FinderPath finderPath = null;
2989 Object[] finderArgs = null;
2990
2991 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2992 (orderByComparator == null)) {
2993 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P;
2994 finderArgs = new Object[] { head, plid };
2995 }
2996 else {
2997 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_H_P;
2998 finderArgs = new Object[] { head, plid, start, end, orderByComparator };
2999 }
3000
3001 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3002 finderArgs, this);
3003
3004 if ((list != null) && !list.isEmpty()) {
3005 for (LayoutRevision layoutRevision : list) {
3006 if ((head != layoutRevision.getHead()) ||
3007 (plid != layoutRevision.getPlid())) {
3008 list = null;
3009
3010 break;
3011 }
3012 }
3013 }
3014
3015 if (list == null) {
3016 StringBundler query = null;
3017
3018 if (orderByComparator != null) {
3019 query = new StringBundler(4 +
3020 (orderByComparator.getOrderByFields().length * 3));
3021 }
3022 else {
3023 query = new StringBundler(4);
3024 }
3025
3026 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3027
3028 query.append(_FINDER_COLUMN_H_P_HEAD_2);
3029
3030 query.append(_FINDER_COLUMN_H_P_PLID_2);
3031
3032 if (orderByComparator != null) {
3033 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3034 orderByComparator);
3035 }
3036
3037 else {
3038 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3039 }
3040
3041 String sql = query.toString();
3042
3043 Session session = null;
3044
3045 try {
3046 session = openSession();
3047
3048 Query q = session.createQuery(sql);
3049
3050 QueryPos qPos = QueryPos.getInstance(q);
3051
3052 qPos.add(head);
3053
3054 qPos.add(plid);
3055
3056 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3057 start, end);
3058 }
3059 catch (Exception e) {
3060 throw processException(e);
3061 }
3062 finally {
3063 if (list == null) {
3064 FinderCacheUtil.removeResult(finderPath, finderArgs);
3065 }
3066 else {
3067 cacheResult(list);
3068
3069 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3070 }
3071
3072 closeSession(session);
3073 }
3074 }
3075
3076 return list;
3077 }
3078
3079
3089 public LayoutRevision findByH_P_First(boolean head, long plid,
3090 OrderByComparator orderByComparator)
3091 throws NoSuchLayoutRevisionException, SystemException {
3092 LayoutRevision layoutRevision = fetchByH_P_First(head, plid,
3093 orderByComparator);
3094
3095 if (layoutRevision != null) {
3096 return layoutRevision;
3097 }
3098
3099 StringBundler msg = new StringBundler(6);
3100
3101 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3102
3103 msg.append("head=");
3104 msg.append(head);
3105
3106 msg.append(", plid=");
3107 msg.append(plid);
3108
3109 msg.append(StringPool.CLOSE_CURLY_BRACE);
3110
3111 throw new NoSuchLayoutRevisionException(msg.toString());
3112 }
3113
3114
3123 public LayoutRevision fetchByH_P_First(boolean head, long plid,
3124 OrderByComparator orderByComparator) throws SystemException {
3125 List<LayoutRevision> list = findByH_P(head, plid, 0, 1,
3126 orderByComparator);
3127
3128 if (!list.isEmpty()) {
3129 return list.get(0);
3130 }
3131
3132 return null;
3133 }
3134
3135
3145 public LayoutRevision findByH_P_Last(boolean head, long plid,
3146 OrderByComparator orderByComparator)
3147 throws NoSuchLayoutRevisionException, SystemException {
3148 LayoutRevision layoutRevision = fetchByH_P_Last(head, plid,
3149 orderByComparator);
3150
3151 if (layoutRevision != null) {
3152 return layoutRevision;
3153 }
3154
3155 StringBundler msg = new StringBundler(6);
3156
3157 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3158
3159 msg.append("head=");
3160 msg.append(head);
3161
3162 msg.append(", plid=");
3163 msg.append(plid);
3164
3165 msg.append(StringPool.CLOSE_CURLY_BRACE);
3166
3167 throw new NoSuchLayoutRevisionException(msg.toString());
3168 }
3169
3170
3179 public LayoutRevision fetchByH_P_Last(boolean head, long plid,
3180 OrderByComparator orderByComparator) throws SystemException {
3181 int count = countByH_P(head, plid);
3182
3183 List<LayoutRevision> list = findByH_P(head, plid, count - 1, count,
3184 orderByComparator);
3185
3186 if (!list.isEmpty()) {
3187 return list.get(0);
3188 }
3189
3190 return null;
3191 }
3192
3193
3204 public LayoutRevision[] findByH_P_PrevAndNext(long layoutRevisionId,
3205 boolean head, long plid, OrderByComparator orderByComparator)
3206 throws NoSuchLayoutRevisionException, SystemException {
3207 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3208
3209 Session session = null;
3210
3211 try {
3212 session = openSession();
3213
3214 LayoutRevision[] array = new LayoutRevisionImpl[3];
3215
3216 array[0] = getByH_P_PrevAndNext(session, layoutRevision, head,
3217 plid, orderByComparator, true);
3218
3219 array[1] = layoutRevision;
3220
3221 array[2] = getByH_P_PrevAndNext(session, layoutRevision, head,
3222 plid, orderByComparator, false);
3223
3224 return array;
3225 }
3226 catch (Exception e) {
3227 throw processException(e);
3228 }
3229 finally {
3230 closeSession(session);
3231 }
3232 }
3233
3234 protected LayoutRevision getByH_P_PrevAndNext(Session session,
3235 LayoutRevision layoutRevision, boolean head, long plid,
3236 OrderByComparator orderByComparator, boolean previous) {
3237 StringBundler query = null;
3238
3239 if (orderByComparator != null) {
3240 query = new StringBundler(6 +
3241 (orderByComparator.getOrderByFields().length * 6));
3242 }
3243 else {
3244 query = new StringBundler(3);
3245 }
3246
3247 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3248
3249 query.append(_FINDER_COLUMN_H_P_HEAD_2);
3250
3251 query.append(_FINDER_COLUMN_H_P_PLID_2);
3252
3253 if (orderByComparator != null) {
3254 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3255
3256 if (orderByConditionFields.length > 0) {
3257 query.append(WHERE_AND);
3258 }
3259
3260 for (int i = 0; i < orderByConditionFields.length; i++) {
3261 query.append(_ORDER_BY_ENTITY_ALIAS);
3262 query.append(orderByConditionFields[i]);
3263
3264 if ((i + 1) < orderByConditionFields.length) {
3265 if (orderByComparator.isAscending() ^ previous) {
3266 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3267 }
3268 else {
3269 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3270 }
3271 }
3272 else {
3273 if (orderByComparator.isAscending() ^ previous) {
3274 query.append(WHERE_GREATER_THAN);
3275 }
3276 else {
3277 query.append(WHERE_LESSER_THAN);
3278 }
3279 }
3280 }
3281
3282 query.append(ORDER_BY_CLAUSE);
3283
3284 String[] orderByFields = orderByComparator.getOrderByFields();
3285
3286 for (int i = 0; i < orderByFields.length; i++) {
3287 query.append(_ORDER_BY_ENTITY_ALIAS);
3288 query.append(orderByFields[i]);
3289
3290 if ((i + 1) < orderByFields.length) {
3291 if (orderByComparator.isAscending() ^ previous) {
3292 query.append(ORDER_BY_ASC_HAS_NEXT);
3293 }
3294 else {
3295 query.append(ORDER_BY_DESC_HAS_NEXT);
3296 }
3297 }
3298 else {
3299 if (orderByComparator.isAscending() ^ previous) {
3300 query.append(ORDER_BY_ASC);
3301 }
3302 else {
3303 query.append(ORDER_BY_DESC);
3304 }
3305 }
3306 }
3307 }
3308
3309 else {
3310 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3311 }
3312
3313 String sql = query.toString();
3314
3315 Query q = session.createQuery(sql);
3316
3317 q.setFirstResult(0);
3318 q.setMaxResults(2);
3319
3320 QueryPos qPos = QueryPos.getInstance(q);
3321
3322 qPos.add(head);
3323
3324 qPos.add(plid);
3325
3326 if (orderByComparator != null) {
3327 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3328
3329 for (Object value : values) {
3330 qPos.add(value);
3331 }
3332 }
3333
3334 List<LayoutRevision> list = q.list();
3335
3336 if (list.size() == 2) {
3337 return list.get(1);
3338 }
3339 else {
3340 return null;
3341 }
3342 }
3343
3344
3352 public List<LayoutRevision> findByP_NotS(long plid, int status)
3353 throws SystemException {
3354 return findByP_NotS(plid, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3355 null);
3356 }
3357
3358
3372 public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3373 int end) throws SystemException {
3374 return findByP_NotS(plid, status, start, end, null);
3375 }
3376
3377
3392 public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3393 int end, OrderByComparator orderByComparator) throws SystemException {
3394 FinderPath finderPath = null;
3395 Object[] finderArgs = null;
3396
3397 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_NOTS;
3398 finderArgs = new Object[] { plid, status, start, end, orderByComparator };
3399
3400 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3401 finderArgs, this);
3402
3403 if ((list != null) && !list.isEmpty()) {
3404 for (LayoutRevision layoutRevision : list) {
3405 if ((plid != layoutRevision.getPlid()) ||
3406 (status != layoutRevision.getStatus())) {
3407 list = null;
3408
3409 break;
3410 }
3411 }
3412 }
3413
3414 if (list == null) {
3415 StringBundler query = null;
3416
3417 if (orderByComparator != null) {
3418 query = new StringBundler(4 +
3419 (orderByComparator.getOrderByFields().length * 3));
3420 }
3421 else {
3422 query = new StringBundler(4);
3423 }
3424
3425 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3426
3427 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3428
3429 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3430
3431 if (orderByComparator != null) {
3432 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3433 orderByComparator);
3434 }
3435
3436 else {
3437 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3438 }
3439
3440 String sql = query.toString();
3441
3442 Session session = null;
3443
3444 try {
3445 session = openSession();
3446
3447 Query q = session.createQuery(sql);
3448
3449 QueryPos qPos = QueryPos.getInstance(q);
3450
3451 qPos.add(plid);
3452
3453 qPos.add(status);
3454
3455 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3456 start, end);
3457 }
3458 catch (Exception e) {
3459 throw processException(e);
3460 }
3461 finally {
3462 if (list == null) {
3463 FinderCacheUtil.removeResult(finderPath, finderArgs);
3464 }
3465 else {
3466 cacheResult(list);
3467
3468 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3469 }
3470
3471 closeSession(session);
3472 }
3473 }
3474
3475 return list;
3476 }
3477
3478
3488 public LayoutRevision findByP_NotS_First(long plid, int status,
3489 OrderByComparator orderByComparator)
3490 throws NoSuchLayoutRevisionException, SystemException {
3491 LayoutRevision layoutRevision = fetchByP_NotS_First(plid, status,
3492 orderByComparator);
3493
3494 if (layoutRevision != null) {
3495 return layoutRevision;
3496 }
3497
3498 StringBundler msg = new StringBundler(6);
3499
3500 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3501
3502 msg.append("plid=");
3503 msg.append(plid);
3504
3505 msg.append(", status=");
3506 msg.append(status);
3507
3508 msg.append(StringPool.CLOSE_CURLY_BRACE);
3509
3510 throw new NoSuchLayoutRevisionException(msg.toString());
3511 }
3512
3513
3522 public LayoutRevision fetchByP_NotS_First(long plid, int status,
3523 OrderByComparator orderByComparator) throws SystemException {
3524 List<LayoutRevision> list = findByP_NotS(plid, status, 0, 1,
3525 orderByComparator);
3526
3527 if (!list.isEmpty()) {
3528 return list.get(0);
3529 }
3530
3531 return null;
3532 }
3533
3534
3544 public LayoutRevision findByP_NotS_Last(long plid, int status,
3545 OrderByComparator orderByComparator)
3546 throws NoSuchLayoutRevisionException, SystemException {
3547 LayoutRevision layoutRevision = fetchByP_NotS_Last(plid, status,
3548 orderByComparator);
3549
3550 if (layoutRevision != null) {
3551 return layoutRevision;
3552 }
3553
3554 StringBundler msg = new StringBundler(6);
3555
3556 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3557
3558 msg.append("plid=");
3559 msg.append(plid);
3560
3561 msg.append(", status=");
3562 msg.append(status);
3563
3564 msg.append(StringPool.CLOSE_CURLY_BRACE);
3565
3566 throw new NoSuchLayoutRevisionException(msg.toString());
3567 }
3568
3569
3578 public LayoutRevision fetchByP_NotS_Last(long plid, int status,
3579 OrderByComparator orderByComparator) throws SystemException {
3580 int count = countByP_NotS(plid, status);
3581
3582 List<LayoutRevision> list = findByP_NotS(plid, status, count - 1,
3583 count, orderByComparator);
3584
3585 if (!list.isEmpty()) {
3586 return list.get(0);
3587 }
3588
3589 return null;
3590 }
3591
3592
3603 public LayoutRevision[] findByP_NotS_PrevAndNext(long layoutRevisionId,
3604 long plid, int status, OrderByComparator orderByComparator)
3605 throws NoSuchLayoutRevisionException, SystemException {
3606 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3607
3608 Session session = null;
3609
3610 try {
3611 session = openSession();
3612
3613 LayoutRevision[] array = new LayoutRevisionImpl[3];
3614
3615 array[0] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3616 status, orderByComparator, true);
3617
3618 array[1] = layoutRevision;
3619
3620 array[2] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3621 status, orderByComparator, false);
3622
3623 return array;
3624 }
3625 catch (Exception e) {
3626 throw processException(e);
3627 }
3628 finally {
3629 closeSession(session);
3630 }
3631 }
3632
3633 protected LayoutRevision getByP_NotS_PrevAndNext(Session session,
3634 LayoutRevision layoutRevision, long plid, int status,
3635 OrderByComparator orderByComparator, boolean previous) {
3636 StringBundler query = null;
3637
3638 if (orderByComparator != null) {
3639 query = new StringBundler(6 +
3640 (orderByComparator.getOrderByFields().length * 6));
3641 }
3642 else {
3643 query = new StringBundler(3);
3644 }
3645
3646 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3647
3648 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3649
3650 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3651
3652 if (orderByComparator != null) {
3653 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3654
3655 if (orderByConditionFields.length > 0) {
3656 query.append(WHERE_AND);
3657 }
3658
3659 for (int i = 0; i < orderByConditionFields.length; i++) {
3660 query.append(_ORDER_BY_ENTITY_ALIAS);
3661 query.append(orderByConditionFields[i]);
3662
3663 if ((i + 1) < orderByConditionFields.length) {
3664 if (orderByComparator.isAscending() ^ previous) {
3665 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3666 }
3667 else {
3668 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3669 }
3670 }
3671 else {
3672 if (orderByComparator.isAscending() ^ previous) {
3673 query.append(WHERE_GREATER_THAN);
3674 }
3675 else {
3676 query.append(WHERE_LESSER_THAN);
3677 }
3678 }
3679 }
3680
3681 query.append(ORDER_BY_CLAUSE);
3682
3683 String[] orderByFields = orderByComparator.getOrderByFields();
3684
3685 for (int i = 0; i < orderByFields.length; i++) {
3686 query.append(_ORDER_BY_ENTITY_ALIAS);
3687 query.append(orderByFields[i]);
3688
3689 if ((i + 1) < orderByFields.length) {
3690 if (orderByComparator.isAscending() ^ previous) {
3691 query.append(ORDER_BY_ASC_HAS_NEXT);
3692 }
3693 else {
3694 query.append(ORDER_BY_DESC_HAS_NEXT);
3695 }
3696 }
3697 else {
3698 if (orderByComparator.isAscending() ^ previous) {
3699 query.append(ORDER_BY_ASC);
3700 }
3701 else {
3702 query.append(ORDER_BY_DESC);
3703 }
3704 }
3705 }
3706 }
3707
3708 else {
3709 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3710 }
3711
3712 String sql = query.toString();
3713
3714 Query q = session.createQuery(sql);
3715
3716 q.setFirstResult(0);
3717 q.setMaxResults(2);
3718
3719 QueryPos qPos = QueryPos.getInstance(q);
3720
3721 qPos.add(plid);
3722
3723 qPos.add(status);
3724
3725 if (orderByComparator != null) {
3726 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3727
3728 for (Object value : values) {
3729 qPos.add(value);
3730 }
3731 }
3732
3733 List<LayoutRevision> list = q.list();
3734
3735 if (list.size() == 2) {
3736 return list.get(1);
3737 }
3738 else {
3739 return null;
3740 }
3741 }
3742
3743
3752 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3753 long layoutBranchId, long plid) throws SystemException {
3754 return findByL_L_P(layoutSetBranchId, layoutBranchId, plid,
3755 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3756 }
3757
3758
3773 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3774 long layoutBranchId, long plid, int start, int end)
3775 throws SystemException {
3776 return findByL_L_P(layoutSetBranchId, layoutBranchId, plid, start, end,
3777 null);
3778 }
3779
3780
3796 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3797 long layoutBranchId, long plid, int start, int end,
3798 OrderByComparator orderByComparator) throws SystemException {
3799 FinderPath finderPath = null;
3800 Object[] finderArgs = null;
3801
3802 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3803 (orderByComparator == null)) {
3804 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P;
3805 finderArgs = new Object[] { layoutSetBranchId, layoutBranchId, plid };
3806 }
3807 else {
3808 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_L_P;
3809 finderArgs = new Object[] {
3810 layoutSetBranchId, layoutBranchId, plid,
3811
3812 start, end, orderByComparator
3813 };
3814 }
3815
3816 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3817 finderArgs, this);
3818
3819 if ((list != null) && !list.isEmpty()) {
3820 for (LayoutRevision layoutRevision : list) {
3821 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
3822 (layoutBranchId != layoutRevision.getLayoutBranchId()) ||
3823 (plid != layoutRevision.getPlid())) {
3824 list = null;
3825
3826 break;
3827 }
3828 }
3829 }
3830
3831 if (list == null) {
3832 StringBundler query = null;
3833
3834 if (orderByComparator != null) {
3835 query = new StringBundler(5 +
3836 (orderByComparator.getOrderByFields().length * 3));
3837 }
3838 else {
3839 query = new StringBundler(5);
3840 }
3841
3842 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3843
3844 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
3845
3846 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
3847
3848 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
3849
3850 if (orderByComparator != null) {
3851 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3852 orderByComparator);
3853 }
3854
3855 else {
3856 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3857 }
3858
3859 String sql = query.toString();
3860
3861 Session session = null;
3862
3863 try {
3864 session = openSession();
3865
3866 Query q = session.createQuery(sql);
3867
3868 QueryPos qPos = QueryPos.getInstance(q);
3869
3870 qPos.add(layoutSetBranchId);
3871
3872 qPos.add(layoutBranchId);
3873
3874 qPos.add(plid);
3875
3876 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3877 start, end);
3878 }
3879 catch (Exception e) {
3880 throw processException(e);
3881 }
3882 finally {
3883 if (list == null) {
3884 FinderCacheUtil.removeResult(finderPath, finderArgs);
3885 }
3886 else {
3887 cacheResult(list);
3888
3889 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3890 }
3891
3892 closeSession(session);
3893 }
3894 }
3895
3896 return list;
3897 }
3898
3899
3910 public LayoutRevision findByL_L_P_First(long layoutSetBranchId,
3911 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3912 throws NoSuchLayoutRevisionException, SystemException {
3913 LayoutRevision layoutRevision = fetchByL_L_P_First(layoutSetBranchId,
3914 layoutBranchId, plid, orderByComparator);
3915
3916 if (layoutRevision != null) {
3917 return layoutRevision;
3918 }
3919
3920 StringBundler msg = new StringBundler(8);
3921
3922 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3923
3924 msg.append("layoutSetBranchId=");
3925 msg.append(layoutSetBranchId);
3926
3927 msg.append(", layoutBranchId=");
3928 msg.append(layoutBranchId);
3929
3930 msg.append(", plid=");
3931 msg.append(plid);
3932
3933 msg.append(StringPool.CLOSE_CURLY_BRACE);
3934
3935 throw new NoSuchLayoutRevisionException(msg.toString());
3936 }
3937
3938
3948 public LayoutRevision fetchByL_L_P_First(long layoutSetBranchId,
3949 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3950 throws SystemException {
3951 List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
3952 layoutBranchId, plid, 0, 1, orderByComparator);
3953
3954 if (!list.isEmpty()) {
3955 return list.get(0);
3956 }
3957
3958 return null;
3959 }
3960
3961
3972 public LayoutRevision findByL_L_P_Last(long layoutSetBranchId,
3973 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3974 throws NoSuchLayoutRevisionException, SystemException {
3975 LayoutRevision layoutRevision = fetchByL_L_P_Last(layoutSetBranchId,
3976 layoutBranchId, plid, orderByComparator);
3977
3978 if (layoutRevision != null) {
3979 return layoutRevision;
3980 }
3981
3982 StringBundler msg = new StringBundler(8);
3983
3984 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3985
3986 msg.append("layoutSetBranchId=");
3987 msg.append(layoutSetBranchId);
3988
3989 msg.append(", layoutBranchId=");
3990 msg.append(layoutBranchId);
3991
3992 msg.append(", plid=");
3993 msg.append(plid);
3994
3995 msg.append(StringPool.CLOSE_CURLY_BRACE);
3996
3997 throw new NoSuchLayoutRevisionException(msg.toString());
3998 }
3999
4000
4010 public LayoutRevision fetchByL_L_P_Last(long layoutSetBranchId,
4011 long layoutBranchId, long plid, OrderByComparator orderByComparator)
4012 throws SystemException {
4013 int count = countByL_L_P(layoutSetBranchId, layoutBranchId, plid);
4014
4015 List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
4016 layoutBranchId, plid, count - 1, count, orderByComparator);
4017
4018 if (!list.isEmpty()) {
4019 return list.get(0);
4020 }
4021
4022 return null;
4023 }
4024
4025
4037 public LayoutRevision[] findByL_L_P_PrevAndNext(long layoutRevisionId,
4038 long layoutSetBranchId, long layoutBranchId, long plid,
4039 OrderByComparator orderByComparator)
4040 throws NoSuchLayoutRevisionException, SystemException {
4041 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
4042
4043 Session session = null;
4044
4045 try {
4046 session = openSession();
4047
4048 LayoutRevision[] array = new LayoutRevisionImpl[3];
4049
4050 array[0] = getByL_L_P_PrevAndNext(session, layoutRevision,
4051 layoutSetBranchId, layoutBranchId, plid, orderByComparator,
4052 true);
4053
4054 array[1] = layoutRevision;
4055
4056 array[2] = getByL_L_P_PrevAndNext(session, layoutRevision,
4057 layoutSetBranchId, layoutBranchId, plid, orderByComparator,
4058 false);
4059
4060 return array;
4061 }
4062 catch (Exception e) {
4063 throw processException(e);
4064 }
4065 finally {
4066 closeSession(session);
4067 }
4068 }
4069
4070 protected LayoutRevision getByL_L_P_PrevAndNext(Session session,
4071 LayoutRevision layoutRevision, long layoutSetBranchId,
4072 long layoutBranchId, long plid, OrderByComparator orderByComparator,
4073 boolean previous) {
4074 StringBundler query = null;
4075
4076 if (orderByComparator != null) {
4077 query = new StringBundler(6 +
4078 (orderByComparator.getOrderByFields().length * 6));
4079 }
4080 else {
4081 query = new StringBundler(3);
4082 }
4083
4084 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4085
4086 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
4087
4088 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
4089
4090 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
4091
4092 if (orderByComparator != null) {
4093 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4094
4095 if (orderByConditionFields.length > 0) {
4096 query.append(WHERE_AND);
4097 }
4098
4099 for (int i = 0; i < orderByConditionFields.length; i++) {
4100 query.append(_ORDER_BY_ENTITY_ALIAS);
4101 query.append(orderByConditionFields[i]);
4102
4103 if ((i + 1) < orderByConditionFields.length) {
4104 if (orderByComparator.isAscending() ^ previous) {
4105 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4106 }
4107 else {
4108 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4109 }
4110 }
4111 else {
4112 if (orderByComparator.isAscending() ^ previous) {
4113 query.append(WHERE_GREATER_THAN);
4114 }
4115 else {
4116 query.append(WHERE_LESSER_THAN);
4117 }
4118 }
4119 }
4120
4121 query.append(ORDER_BY_CLAUSE);
4122
4123 String[] orderByFields = orderByComparator.getOrderByFields();
4124
4125 for (int i = 0; i < orderByFields.length; i++) {
4126 query.append(_ORDER_BY_ENTITY_ALIAS);
4127 query.append(orderByFields[i]);
4128
4129 if ((i + 1) < orderByFields.length) {
4130 if (orderByComparator.isAscending() ^ previous) {
4131 query.append(ORDER_BY_ASC_HAS_NEXT);
4132 }
4133 else {
4134 query.append(ORDER_BY_DESC_HAS_NEXT);
4135 }
4136 }
4137 else {
4138 if (orderByComparator.isAscending() ^ previous) {
4139 query.append(ORDER_BY_ASC);
4140 }
4141 else {
4142 query.append(ORDER_BY_DESC);
4143 }
4144 }
4145 }
4146 }
4147
4148 else {
4149 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4150 }
4151
4152 String sql = query.toString();
4153
4154 Query q = session.createQuery(sql);
4155
4156 q.setFirstResult(0);
4157 q.setMaxResults(2);
4158
4159 QueryPos qPos = QueryPos.getInstance(q);
4160
4161 qPos.add(layoutSetBranchId);
4162
4163 qPos.add(layoutBranchId);
4164
4165 qPos.add(plid);
4166
4167 if (orderByComparator != null) {
4168 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4169
4170 for (Object value : values) {
4171 qPos.add(value);
4172 }
4173 }
4174
4175 List<LayoutRevision> list = q.list();
4176
4177 if (list.size() == 2) {
4178 return list.get(1);
4179 }
4180 else {
4181 return null;
4182 }
4183 }
4184
4185
4194 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4195 long parentLayoutRevisionId, long plid) throws SystemException {
4196 return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4197 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4198 }
4199
4200
4215 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4216 long parentLayoutRevisionId, long plid, int start, int end)
4217 throws SystemException {
4218 return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4219 start, end, null);
4220 }
4221
4222
4238 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4239 long parentLayoutRevisionId, long plid, int start, int end,
4240 OrderByComparator orderByComparator) throws SystemException {
4241 FinderPath finderPath = null;
4242 Object[] finderArgs = null;
4243
4244 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4245 (orderByComparator == null)) {
4246 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P;
4247 finderArgs = new Object[] {
4248 layoutSetBranchId, parentLayoutRevisionId, plid
4249 };
4250 }
4251 else {
4252 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_P;
4253 finderArgs = new Object[] {
4254 layoutSetBranchId, parentLayoutRevisionId, plid,
4255
4256 start, end, orderByComparator
4257 };
4258 }
4259
4260 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
4261 finderArgs, this);
4262
4263 if ((list != null) && !list.isEmpty()) {
4264 for (LayoutRevision layoutRevision : list) {
4265 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4266 (parentLayoutRevisionId != layoutRevision.getParentLayoutRevisionId()) ||
4267 (plid != layoutRevision.getPlid())) {
4268 list = null;
4269
4270 break;
4271 }
4272 }
4273 }
4274
4275 if (list == null) {
4276 StringBundler query = null;
4277
4278 if (orderByComparator != null) {
4279 query = new StringBundler(5 +
4280 (orderByComparator.getOrderByFields().length * 3));
4281 }
4282 else {
4283 query = new StringBundler(5);
4284 }
4285
4286 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4287
4288 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4289
4290 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4291
4292 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4293
4294 if (orderByComparator != null) {
4295 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4296 orderByComparator);
4297 }
4298
4299 else {
4300 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4301 }
4302
4303 String sql = query.toString();
4304
4305 Session session = null;
4306
4307 try {
4308 session = openSession();
4309
4310 Query q = session.createQuery(sql);
4311
4312 QueryPos qPos = QueryPos.getInstance(q);
4313
4314 qPos.add(layoutSetBranchId);
4315
4316 qPos.add(parentLayoutRevisionId);
4317
4318 qPos.add(plid);
4319
4320 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
4321 start, end);
4322 }
4323 catch (Exception e) {
4324 throw processException(e);
4325 }
4326 finally {
4327 if (list == null) {
4328 FinderCacheUtil.removeResult(finderPath, finderArgs);
4329 }
4330 else {
4331 cacheResult(list);
4332
4333 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4334 }
4335
4336 closeSession(session);
4337 }
4338 }
4339
4340 return list;
4341 }
4342
4343
4354 public LayoutRevision findByL_P_P_First(long layoutSetBranchId,
4355 long parentLayoutRevisionId, long plid,
4356 OrderByComparator orderByComparator)
4357 throws NoSuchLayoutRevisionException, SystemException {
4358 LayoutRevision layoutRevision = fetchByL_P_P_First(layoutSetBranchId,
4359 parentLayoutRevisionId, plid, orderByComparator);
4360
4361 if (layoutRevision != null) {
4362 return layoutRevision;
4363 }
4364
4365 StringBundler msg = new StringBundler(8);
4366
4367 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4368
4369 msg.append("layoutSetBranchId=");
4370 msg.append(layoutSetBranchId);
4371
4372 msg.append(", parentLayoutRevisionId=");
4373 msg.append(parentLayoutRevisionId);
4374
4375 msg.append(", plid=");
4376 msg.append(plid);
4377
4378 msg.append(StringPool.CLOSE_CURLY_BRACE);
4379
4380 throw new NoSuchLayoutRevisionException(msg.toString());
4381 }
4382
4383
4393 public LayoutRevision fetchByL_P_P_First(long layoutSetBranchId,
4394 long parentLayoutRevisionId, long plid,
4395 OrderByComparator orderByComparator) throws SystemException {
4396 List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4397 parentLayoutRevisionId, plid, 0, 1, orderByComparator);
4398
4399 if (!list.isEmpty()) {
4400 return list.get(0);
4401 }
4402
4403 return null;
4404 }
4405
4406
4417 public LayoutRevision findByL_P_P_Last(long layoutSetBranchId,
4418 long parentLayoutRevisionId, long plid,
4419 OrderByComparator orderByComparator)
4420 throws NoSuchLayoutRevisionException, SystemException {
4421 LayoutRevision layoutRevision = fetchByL_P_P_Last(layoutSetBranchId,
4422 parentLayoutRevisionId, plid, orderByComparator);
4423
4424 if (layoutRevision != null) {
4425 return layoutRevision;
4426 }
4427
4428 StringBundler msg = new StringBundler(8);
4429
4430 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4431
4432 msg.append("layoutSetBranchId=");
4433 msg.append(layoutSetBranchId);
4434
4435 msg.append(", parentLayoutRevisionId=");
4436 msg.append(parentLayoutRevisionId);
4437
4438 msg.append(", plid=");
4439 msg.append(plid);
4440
4441 msg.append(StringPool.CLOSE_CURLY_BRACE);
4442
4443 throw new NoSuchLayoutRevisionException(msg.toString());
4444 }
4445
4446
4456 public LayoutRevision fetchByL_P_P_Last(long layoutSetBranchId,
4457 long parentLayoutRevisionId, long plid,
4458 OrderByComparator orderByComparator) throws SystemException {
4459 int count = countByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid);
4460
4461 List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4462 parentLayoutRevisionId, plid, count - 1, count,
4463 orderByComparator);
4464
4465 if (!list.isEmpty()) {
4466 return list.get(0);
4467 }
4468
4469 return null;
4470 }
4471
4472
4484 public LayoutRevision[] findByL_P_P_PrevAndNext(long layoutRevisionId,
4485 long layoutSetBranchId, long parentLayoutRevisionId, long plid,
4486 OrderByComparator orderByComparator)
4487 throws NoSuchLayoutRevisionException, SystemException {
4488 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
4489
4490 Session session = null;
4491
4492 try {
4493 session = openSession();
4494
4495 LayoutRevision[] array = new LayoutRevisionImpl[3];
4496
4497 array[0] = getByL_P_P_PrevAndNext(session, layoutRevision,
4498 layoutSetBranchId, parentLayoutRevisionId, plid,
4499 orderByComparator, true);
4500
4501 array[1] = layoutRevision;
4502
4503 array[2] = getByL_P_P_PrevAndNext(session, layoutRevision,
4504 layoutSetBranchId, parentLayoutRevisionId, plid,
4505 orderByComparator, false);
4506
4507 return array;
4508 }
4509 catch (Exception e) {
4510 throw processException(e);
4511 }
4512 finally {
4513 closeSession(session);
4514 }
4515 }
4516
4517 protected LayoutRevision getByL_P_P_PrevAndNext(Session session,
4518 LayoutRevision layoutRevision, long layoutSetBranchId,
4519 long parentLayoutRevisionId, long plid,
4520 OrderByComparator orderByComparator, boolean previous) {
4521 StringBundler query = null;
4522
4523 if (orderByComparator != null) {
4524 query = new StringBundler(6 +
4525 (orderByComparator.getOrderByFields().length * 6));
4526 }
4527 else {
4528 query = new StringBundler(3);
4529 }
4530
4531 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4532
4533 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4534
4535 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4536
4537 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4538
4539 if (orderByComparator != null) {
4540 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4541
4542 if (orderByConditionFields.length > 0) {
4543 query.append(WHERE_AND);
4544 }
4545
4546 for (int i = 0; i < orderByConditionFields.length; i++) {
4547 query.append(_ORDER_BY_ENTITY_ALIAS);
4548 query.append(orderByConditionFields[i]);
4549
4550 if ((i + 1) < orderByConditionFields.length) {
4551 if (orderByComparator.isAscending() ^ previous) {
4552 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4553 }
4554 else {
4555 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4556 }
4557 }
4558 else {
4559 if (orderByComparator.isAscending() ^ previous) {
4560 query.append(WHERE_GREATER_THAN);
4561 }
4562 else {
4563 query.append(WHERE_LESSER_THAN);
4564 }
4565 }
4566 }
4567
4568 query.append(ORDER_BY_CLAUSE);
4569
4570 String[] orderByFields = orderByComparator.getOrderByFields();
4571
4572 for (int i = 0; i < orderByFields.length; i++) {
4573 query.append(_ORDER_BY_ENTITY_ALIAS);
4574 query.append(orderByFields[i]);
4575
4576 if ((i + 1) < orderByFields.length) {
4577 if (orderByComparator.isAscending() ^ previous) {
4578 query.append(ORDER_BY_ASC_HAS_NEXT);
4579 }
4580 else {
4581 query.append(ORDER_BY_DESC_HAS_NEXT);
4582 }
4583 }
4584 else {
4585 if (orderByComparator.isAscending() ^ previous) {
4586 query.append(ORDER_BY_ASC);
4587 }
4588 else {
4589 query.append(ORDER_BY_DESC);
4590 }
4591 }
4592 }
4593 }
4594
4595 else {
4596 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4597 }
4598
4599 String sql = query.toString();
4600
4601 Query q = session.createQuery(sql);
4602
4603 q.setFirstResult(0);
4604 q.setMaxResults(2);
4605
4606 QueryPos qPos = QueryPos.getInstance(q);
4607
4608 qPos.add(layoutSetBranchId);
4609
4610 qPos.add(parentLayoutRevisionId);
4611
4612 qPos.add(plid);
4613
4614 if (orderByComparator != null) {
4615 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4616
4617 for (Object value : values) {
4618 qPos.add(value);
4619 }
4620 }
4621
4622 List<LayoutRevision> list = q.list();
4623
4624 if (list.size() == 2) {
4625 return list.get(1);
4626 }
4627 else {
4628 return null;
4629 }
4630 }
4631
4632
4642 public LayoutRevision findByL_H_P(long layoutSetBranchId, boolean head,
4643 long plid) throws NoSuchLayoutRevisionException, SystemException {
4644 LayoutRevision layoutRevision = fetchByL_H_P(layoutSetBranchId, head,
4645 plid);
4646
4647 if (layoutRevision == null) {
4648 StringBundler msg = new StringBundler(8);
4649
4650 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4651
4652 msg.append("layoutSetBranchId=");
4653 msg.append(layoutSetBranchId);
4654
4655 msg.append(", head=");
4656 msg.append(head);
4657
4658 msg.append(", plid=");
4659 msg.append(plid);
4660
4661 msg.append(StringPool.CLOSE_CURLY_BRACE);
4662
4663 if (_log.isWarnEnabled()) {
4664 _log.warn(msg.toString());
4665 }
4666
4667 throw new NoSuchLayoutRevisionException(msg.toString());
4668 }
4669
4670 return layoutRevision;
4671 }
4672
4673
4682 public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4683 long plid) throws SystemException {
4684 return fetchByL_H_P(layoutSetBranchId, head, plid, true);
4685 }
4686
4687
4697 public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4698 long plid, boolean retrieveFromCache) throws SystemException {
4699 Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
4700
4701 Object result = null;
4702
4703 if (retrieveFromCache) {
4704 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_L_H_P,
4705 finderArgs, this);
4706 }
4707
4708 if (result instanceof LayoutRevision) {
4709 LayoutRevision layoutRevision = (LayoutRevision)result;
4710
4711 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4712 (head != layoutRevision.getHead()) ||
4713 (plid != layoutRevision.getPlid())) {
4714 result = null;
4715 }
4716 }
4717
4718 if (result == null) {
4719 StringBundler query = new StringBundler(5);
4720
4721 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4722
4723 query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
4724
4725 query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
4726
4727 query.append(_FINDER_COLUMN_L_H_P_PLID_2);
4728
4729 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4730
4731 String sql = query.toString();
4732
4733 Session session = null;
4734
4735 try {
4736 session = openSession();
4737
4738 Query q = session.createQuery(sql);
4739
4740 QueryPos qPos = QueryPos.getInstance(q);
4741
4742 qPos.add(layoutSetBranchId);
4743
4744 qPos.add(head);
4745
4746 qPos.add(plid);
4747
4748 List<LayoutRevision> list = q.list();
4749
4750 result = list;
4751
4752 LayoutRevision layoutRevision = null;
4753
4754 if (list.isEmpty()) {
4755 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4756 finderArgs, list);
4757 }
4758 else {
4759 layoutRevision = list.get(0);
4760
4761 cacheResult(layoutRevision);
4762
4763 if ((layoutRevision.getLayoutSetBranchId() != layoutSetBranchId) ||
4764 (layoutRevision.getHead() != head) ||
4765 (layoutRevision.getPlid() != plid)) {
4766 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4767 finderArgs, layoutRevision);
4768 }
4769 }
4770
4771 return layoutRevision;
4772 }
4773 catch (Exception e) {
4774 throw processException(e);
4775 }
4776 finally {
4777 if (result == null) {
4778 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P,
4779 finderArgs);
4780 }
4781
4782 closeSession(session);
4783 }
4784 }
4785 else {
4786 if (result instanceof List<?>) {
4787 return null;
4788 }
4789 else {
4790 return (LayoutRevision)result;
4791 }
4792 }
4793 }
4794
4795
4804 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4805 int status) throws SystemException {
4806 return findByL_P_S(layoutSetBranchId, plid, status, QueryUtil.ALL_POS,
4807 QueryUtil.ALL_POS, null);
4808 }
4809
4810
4825 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4826 int status, int start, int end) throws SystemException {
4827 return findByL_P_S(layoutSetBranchId, plid, status, start, end, null);
4828 }
4829
4830
4846 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4847 int status, int start, int end, OrderByComparator orderByComparator)
4848 throws SystemException {
4849 FinderPath finderPath = null;
4850 Object[] finderArgs = null;
4851
4852 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4853 (orderByComparator == null)) {
4854 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S;
4855 finderArgs = new Object[] { layoutSetBranchId, plid, status };
4856 }
4857 else {
4858 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_S;
4859 finderArgs = new Object[] {
4860 layoutSetBranchId, plid, status,
4861
4862 start, end, orderByComparator
4863 };
4864 }
4865
4866 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
4867 finderArgs, this);
4868
4869 if ((list != null) && !list.isEmpty()) {
4870 for (LayoutRevision layoutRevision : list) {
4871 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4872 (plid != layoutRevision.getPlid()) ||
4873 (status != layoutRevision.getStatus())) {
4874 list = null;
4875
4876 break;
4877 }
4878 }
4879 }
4880
4881 if (list == null) {
4882 StringBundler query = null;
4883
4884 if (orderByComparator != null) {
4885 query = new StringBundler(5 +
4886 (orderByComparator.getOrderByFields().length * 3));
4887 }
4888 else {
4889 query = new StringBundler(5);
4890 }
4891
4892 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4893
4894 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
4895
4896 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
4897
4898 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
4899
4900 if (orderByComparator != null) {
4901 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4902 orderByComparator);
4903 }
4904
4905 else {
4906 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4907 }
4908
4909 String sql = query.toString();
4910
4911 Session session = null;
4912
4913 try {
4914 session = openSession();
4915
4916 Query q = session.createQuery(sql);
4917
4918 QueryPos qPos = QueryPos.getInstance(q);
4919
4920 qPos.add(layoutSetBranchId);
4921
4922 qPos.add(plid);
4923
4924 qPos.add(status);
4925
4926 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
4927 start, end);
4928 }
4929 catch (Exception e) {
4930 throw processException(e);
4931 }
4932 finally {
4933 if (list == null) {
4934 FinderCacheUtil.removeResult(finderPath, finderArgs);
4935 }
4936 else {
4937 cacheResult(list);
4938
4939 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4940 }
4941
4942 closeSession(session);
4943 }
4944 }
4945
4946 return list;
4947 }
4948
4949
4960 public LayoutRevision findByL_P_S_First(long layoutSetBranchId, long plid,
4961 int status, OrderByComparator orderByComparator)
4962 throws NoSuchLayoutRevisionException, SystemException {
4963 LayoutRevision layoutRevision = fetchByL_P_S_First(layoutSetBranchId,
4964 plid, status, orderByComparator);
4965
4966 if (layoutRevision != null) {
4967 return layoutRevision;
4968 }
4969
4970 StringBundler msg = new StringBundler(8);
4971
4972 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4973
4974 msg.append("layoutSetBranchId=");
4975 msg.append(layoutSetBranchId);
4976
4977 msg.append(", plid=");
4978 msg.append(plid);
4979
4980 msg.append(", status=");
4981 msg.append(status);
4982
4983 msg.append(StringPool.CLOSE_CURLY_BRACE);
4984
4985 throw new NoSuchLayoutRevisionException(msg.toString());
4986 }
4987
4988
4998 public LayoutRevision fetchByL_P_S_First(long layoutSetBranchId, long plid,
4999 int status, OrderByComparator orderByComparator)
5000 throws SystemException {
5001 List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
5002 status, 0, 1, orderByComparator);
5003
5004 if (!list.isEmpty()) {
5005 return list.get(0);
5006 }
5007
5008 return null;
5009 }
5010
5011
5022 public LayoutRevision findByL_P_S_Last(long layoutSetBranchId, long plid,
5023 int status, OrderByComparator orderByComparator)
5024 throws NoSuchLayoutRevisionException, SystemException {
5025 LayoutRevision layoutRevision = fetchByL_P_S_Last(layoutSetBranchId,
5026 plid, status, orderByComparator);
5027
5028 if (layoutRevision != null) {
5029 return layoutRevision;
5030 }
5031
5032 StringBundler msg = new StringBundler(8);
5033
5034 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5035
5036 msg.append("layoutSetBranchId=");
5037 msg.append(layoutSetBranchId);
5038
5039 msg.append(", plid=");
5040 msg.append(plid);
5041
5042 msg.append(", status=");
5043 msg.append(status);
5044
5045 msg.append(StringPool.CLOSE_CURLY_BRACE);
5046
5047 throw new NoSuchLayoutRevisionException(msg.toString());
5048 }
5049
5050
5060 public LayoutRevision fetchByL_P_S_Last(long layoutSetBranchId, long plid,
5061 int status, OrderByComparator orderByComparator)
5062 throws SystemException {
5063 int count = countByL_P_S(layoutSetBranchId, plid, status);
5064
5065 List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
5066 status, count - 1, count, orderByComparator);
5067
5068 if (!list.isEmpty()) {
5069 return list.get(0);
5070 }
5071
5072 return null;
5073 }
5074
5075
5087 public LayoutRevision[] findByL_P_S_PrevAndNext(long layoutRevisionId,
5088 long layoutSetBranchId, long plid, int status,
5089 OrderByComparator orderByComparator)
5090 throws NoSuchLayoutRevisionException, SystemException {
5091 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
5092
5093 Session session = null;
5094
5095 try {
5096 session = openSession();
5097
5098 LayoutRevision[] array = new LayoutRevisionImpl[3];
5099
5100 array[0] = getByL_P_S_PrevAndNext(session, layoutRevision,
5101 layoutSetBranchId, plid, status, orderByComparator, true);
5102
5103 array[1] = layoutRevision;
5104
5105 array[2] = getByL_P_S_PrevAndNext(session, layoutRevision,
5106 layoutSetBranchId, plid, status, orderByComparator, false);
5107
5108 return array;
5109 }
5110 catch (Exception e) {
5111 throw processException(e);
5112 }
5113 finally {
5114 closeSession(session);
5115 }
5116 }
5117
5118 protected LayoutRevision getByL_P_S_PrevAndNext(Session session,
5119 LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
5120 int status, OrderByComparator orderByComparator, boolean previous) {
5121 StringBundler query = null;
5122
5123 if (orderByComparator != null) {
5124 query = new StringBundler(6 +
5125 (orderByComparator.getOrderByFields().length * 6));
5126 }
5127 else {
5128 query = new StringBundler(3);
5129 }
5130
5131 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
5132
5133 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
5134
5135 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
5136
5137 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
5138
5139 if (orderByComparator != null) {
5140 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5141
5142 if (orderByConditionFields.length > 0) {
5143 query.append(WHERE_AND);
5144 }
5145
5146 for (int i = 0; i < orderByConditionFields.length; i++) {
5147 query.append(_ORDER_BY_ENTITY_ALIAS);
5148 query.append(orderByConditionFields[i]);
5149
5150 if ((i + 1) < orderByConditionFields.length) {
5151 if (orderByComparator.isAscending() ^ previous) {
5152 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5153 }
5154 else {
5155 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5156 }
5157 }
5158 else {
5159 if (orderByComparator.isAscending() ^ previous) {
5160 query.append(WHERE_GREATER_THAN);
5161 }
5162 else {
5163 query.append(WHERE_LESSER_THAN);
5164 }
5165 }
5166 }
5167
5168 query.append(ORDER_BY_CLAUSE);
5169
5170 String[] orderByFields = orderByComparator.getOrderByFields();
5171
5172 for (int i = 0; i < orderByFields.length; i++) {
5173 query.append(_ORDER_BY_ENTITY_ALIAS);
5174 query.append(orderByFields[i]);
5175
5176 if ((i + 1) < orderByFields.length) {
5177 if (orderByComparator.isAscending() ^ previous) {
5178 query.append(ORDER_BY_ASC_HAS_NEXT);
5179 }
5180 else {
5181 query.append(ORDER_BY_DESC_HAS_NEXT);
5182 }
5183 }
5184 else {
5185 if (orderByComparator.isAscending() ^ previous) {
5186 query.append(ORDER_BY_ASC);
5187 }
5188 else {
5189 query.append(ORDER_BY_DESC);
5190 }
5191 }
5192 }
5193 }
5194
5195 else {
5196 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5197 }
5198
5199 String sql = query.toString();
5200
5201 Query q = session.createQuery(sql);
5202
5203 q.setFirstResult(0);
5204 q.setMaxResults(2);
5205
5206 QueryPos qPos = QueryPos.getInstance(q);
5207
5208 qPos.add(layoutSetBranchId);
5209
5210 qPos.add(plid);
5211
5212 qPos.add(status);
5213
5214 if (orderByComparator != null) {
5215 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
5216
5217 for (Object value : values) {
5218 qPos.add(value);
5219 }
5220 }
5221
5222 List<LayoutRevision> list = q.list();
5223
5224 if (list.size() == 2) {
5225 return list.get(1);
5226 }
5227 else {
5228 return null;
5229 }
5230 }
5231
5232
5238 public List<LayoutRevision> findAll() throws SystemException {
5239 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5240 }
5241
5242
5254 public List<LayoutRevision> findAll(int start, int end)
5255 throws SystemException {
5256 return findAll(start, end, null);
5257 }
5258
5259
5272 public List<LayoutRevision> findAll(int start, int end,
5273 OrderByComparator orderByComparator) throws SystemException {
5274 FinderPath finderPath = null;
5275 Object[] finderArgs = new Object[] { start, end, orderByComparator };
5276
5277 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5278 (orderByComparator == null)) {
5279 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5280 finderArgs = FINDER_ARGS_EMPTY;
5281 }
5282 else {
5283 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5284 finderArgs = new Object[] { start, end, orderByComparator };
5285 }
5286
5287 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
5288 finderArgs, this);
5289
5290 if (list == null) {
5291 StringBundler query = null;
5292 String sql = null;
5293
5294 if (orderByComparator != null) {
5295 query = new StringBundler(2 +
5296 (orderByComparator.getOrderByFields().length * 3));
5297
5298 query.append(_SQL_SELECT_LAYOUTREVISION);
5299
5300 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5301 orderByComparator);
5302
5303 sql = query.toString();
5304 }
5305 else {
5306 sql = _SQL_SELECT_LAYOUTREVISION.concat(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5307 }
5308
5309 Session session = null;
5310
5311 try {
5312 session = openSession();
5313
5314 Query q = session.createQuery(sql);
5315
5316 if (orderByComparator == null) {
5317 list = (List<LayoutRevision>)QueryUtil.list(q,
5318 getDialect(), start, end, false);
5319
5320 Collections.sort(list);
5321 }
5322 else {
5323 list = (List<LayoutRevision>)QueryUtil.list(q,
5324 getDialect(), start, end);
5325 }
5326 }
5327 catch (Exception e) {
5328 throw processException(e);
5329 }
5330 finally {
5331 if (list == null) {
5332 FinderCacheUtil.removeResult(finderPath, finderArgs);
5333 }
5334 else {
5335 cacheResult(list);
5336
5337 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5338 }
5339
5340 closeSession(session);
5341 }
5342 }
5343
5344 return list;
5345 }
5346
5347
5353 public void removeByLayoutSetBranchId(long layoutSetBranchId)
5354 throws SystemException {
5355 for (LayoutRevision layoutRevision : findByLayoutSetBranchId(
5356 layoutSetBranchId)) {
5357 remove(layoutRevision);
5358 }
5359 }
5360
5361
5367 public void removeByPlid(long plid) throws SystemException {
5368 for (LayoutRevision layoutRevision : findByPlid(plid)) {
5369 remove(layoutRevision);
5370 }
5371 }
5372
5373
5380 public void removeByL_H(long layoutSetBranchId, boolean head)
5381 throws SystemException {
5382 for (LayoutRevision layoutRevision : findByL_H(layoutSetBranchId, head)) {
5383 remove(layoutRevision);
5384 }
5385 }
5386
5387
5394 public void removeByL_P(long layoutSetBranchId, long plid)
5395 throws SystemException {
5396 for (LayoutRevision layoutRevision : findByL_P(layoutSetBranchId, plid)) {
5397 remove(layoutRevision);
5398 }
5399 }
5400
5401
5408 public void removeByL_S(long layoutSetBranchId, int status)
5409 throws SystemException {
5410 for (LayoutRevision layoutRevision : findByL_S(layoutSetBranchId, status)) {
5411 remove(layoutRevision);
5412 }
5413 }
5414
5415
5422 public void removeByH_P(boolean head, long plid) throws SystemException {
5423 for (LayoutRevision layoutRevision : findByH_P(head, plid)) {
5424 remove(layoutRevision);
5425 }
5426 }
5427
5428
5435 public void removeByP_NotS(long plid, int status) throws SystemException {
5436 for (LayoutRevision layoutRevision : findByP_NotS(plid, status)) {
5437 remove(layoutRevision);
5438 }
5439 }
5440
5441
5449 public void removeByL_L_P(long layoutSetBranchId, long layoutBranchId,
5450 long plid) throws SystemException {
5451 for (LayoutRevision layoutRevision : findByL_L_P(layoutSetBranchId,
5452 layoutBranchId, plid)) {
5453 remove(layoutRevision);
5454 }
5455 }
5456
5457
5465 public void removeByL_P_P(long layoutSetBranchId,
5466 long parentLayoutRevisionId, long plid) throws SystemException {
5467 for (LayoutRevision layoutRevision : findByL_P_P(layoutSetBranchId,
5468 parentLayoutRevisionId, plid)) {
5469 remove(layoutRevision);
5470 }
5471 }
5472
5473
5482 public LayoutRevision removeByL_H_P(long layoutSetBranchId, boolean head,
5483 long plid) throws NoSuchLayoutRevisionException, SystemException {
5484 LayoutRevision layoutRevision = findByL_H_P(layoutSetBranchId, head,
5485 plid);
5486
5487 return remove(layoutRevision);
5488 }
5489
5490
5498 public void removeByL_P_S(long layoutSetBranchId, long plid, int status)
5499 throws SystemException {
5500 for (LayoutRevision layoutRevision : findByL_P_S(layoutSetBranchId,
5501 plid, status)) {
5502 remove(layoutRevision);
5503 }
5504 }
5505
5506
5511 public void removeAll() throws SystemException {
5512 for (LayoutRevision layoutRevision : findAll()) {
5513 remove(layoutRevision);
5514 }
5515 }
5516
5517
5524 public int countByLayoutSetBranchId(long layoutSetBranchId)
5525 throws SystemException {
5526 Object[] finderArgs = new Object[] { layoutSetBranchId };
5527
5528 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5529 finderArgs, this);
5530
5531 if (count == null) {
5532 StringBundler query = new StringBundler(2);
5533
5534 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5535
5536 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
5537
5538 String sql = query.toString();
5539
5540 Session session = null;
5541
5542 try {
5543 session = openSession();
5544
5545 Query q = session.createQuery(sql);
5546
5547 QueryPos qPos = QueryPos.getInstance(q);
5548
5549 qPos.add(layoutSetBranchId);
5550
5551 count = (Long)q.uniqueResult();
5552 }
5553 catch (Exception e) {
5554 throw processException(e);
5555 }
5556 finally {
5557 if (count == null) {
5558 count = Long.valueOf(0);
5559 }
5560
5561 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5562 finderArgs, count);
5563
5564 closeSession(session);
5565 }
5566 }
5567
5568 return count.intValue();
5569 }
5570
5571
5578 public int countByPlid(long plid) throws SystemException {
5579 Object[] finderArgs = new Object[] { plid };
5580
5581 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PLID,
5582 finderArgs, this);
5583
5584 if (count == null) {
5585 StringBundler query = new StringBundler(2);
5586
5587 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5588
5589 query.append(_FINDER_COLUMN_PLID_PLID_2);
5590
5591 String sql = query.toString();
5592
5593 Session session = null;
5594
5595 try {
5596 session = openSession();
5597
5598 Query q = session.createQuery(sql);
5599
5600 QueryPos qPos = QueryPos.getInstance(q);
5601
5602 qPos.add(plid);
5603
5604 count = (Long)q.uniqueResult();
5605 }
5606 catch (Exception e) {
5607 throw processException(e);
5608 }
5609 finally {
5610 if (count == null) {
5611 count = Long.valueOf(0);
5612 }
5613
5614 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PLID,
5615 finderArgs, count);
5616
5617 closeSession(session);
5618 }
5619 }
5620
5621 return count.intValue();
5622 }
5623
5624
5632 public int countByL_H(long layoutSetBranchId, boolean head)
5633 throws SystemException {
5634 Object[] finderArgs = new Object[] { layoutSetBranchId, head };
5635
5636 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_H,
5637 finderArgs, this);
5638
5639 if (count == null) {
5640 StringBundler query = new StringBundler(3);
5641
5642 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5643
5644 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
5645
5646 query.append(_FINDER_COLUMN_L_H_HEAD_2);
5647
5648 String sql = query.toString();
5649
5650 Session session = null;
5651
5652 try {
5653 session = openSession();
5654
5655 Query q = session.createQuery(sql);
5656
5657 QueryPos qPos = QueryPos.getInstance(q);
5658
5659 qPos.add(layoutSetBranchId);
5660
5661 qPos.add(head);
5662
5663 count = (Long)q.uniqueResult();
5664 }
5665 catch (Exception e) {
5666 throw processException(e);
5667 }
5668 finally {
5669 if (count == null) {
5670 count = Long.valueOf(0);
5671 }
5672
5673 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H, finderArgs,
5674 count);
5675
5676 closeSession(session);
5677 }
5678 }
5679
5680 return count.intValue();
5681 }
5682
5683
5691 public int countByL_P(long layoutSetBranchId, long plid)
5692 throws SystemException {
5693 Object[] finderArgs = new Object[] { layoutSetBranchId, plid };
5694
5695 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P,
5696 finderArgs, this);
5697
5698 if (count == null) {
5699 StringBundler query = new StringBundler(3);
5700
5701 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5702
5703 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
5704
5705 query.append(_FINDER_COLUMN_L_P_PLID_2);
5706
5707 String sql = query.toString();
5708
5709 Session session = null;
5710
5711 try {
5712 session = openSession();
5713
5714 Query q = session.createQuery(sql);
5715
5716 QueryPos qPos = QueryPos.getInstance(q);
5717
5718 qPos.add(layoutSetBranchId);
5719
5720 qPos.add(plid);
5721
5722 count = (Long)q.uniqueResult();
5723 }
5724 catch (Exception e) {
5725 throw processException(e);
5726 }
5727 finally {
5728 if (count == null) {
5729 count = Long.valueOf(0);
5730 }
5731
5732 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P, finderArgs,
5733 count);
5734
5735 closeSession(session);
5736 }
5737 }
5738
5739 return count.intValue();
5740 }
5741
5742
5750 public int countByL_S(long layoutSetBranchId, int status)
5751 throws SystemException {
5752 Object[] finderArgs = new Object[] { layoutSetBranchId, status };
5753
5754 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_S,
5755 finderArgs, this);
5756
5757 if (count == null) {
5758 StringBundler query = new StringBundler(3);
5759
5760 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5761
5762 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
5763
5764 query.append(_FINDER_COLUMN_L_S_STATUS_2);
5765
5766 String sql = query.toString();
5767
5768 Session session = null;
5769
5770 try {
5771 session = openSession();
5772
5773 Query q = session.createQuery(sql);
5774
5775 QueryPos qPos = QueryPos.getInstance(q);
5776
5777 qPos.add(layoutSetBranchId);
5778
5779 qPos.add(status);
5780
5781 count = (Long)q.uniqueResult();
5782 }
5783 catch (Exception e) {
5784 throw processException(e);
5785 }
5786 finally {
5787 if (count == null) {
5788 count = Long.valueOf(0);
5789 }
5790
5791 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_S, finderArgs,
5792 count);
5793
5794 closeSession(session);
5795 }
5796 }
5797
5798 return count.intValue();
5799 }
5800
5801
5809 public int countByH_P(boolean head, long plid) throws SystemException {
5810 Object[] finderArgs = new Object[] { head, plid };
5811
5812 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_H_P,
5813 finderArgs, this);
5814
5815 if (count == null) {
5816 StringBundler query = new StringBundler(3);
5817
5818 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5819
5820 query.append(_FINDER_COLUMN_H_P_HEAD_2);
5821
5822 query.append(_FINDER_COLUMN_H_P_PLID_2);
5823
5824 String sql = query.toString();
5825
5826 Session session = null;
5827
5828 try {
5829 session = openSession();
5830
5831 Query q = session.createQuery(sql);
5832
5833 QueryPos qPos = QueryPos.getInstance(q);
5834
5835 qPos.add(head);
5836
5837 qPos.add(plid);
5838
5839 count = (Long)q.uniqueResult();
5840 }
5841 catch (Exception e) {
5842 throw processException(e);
5843 }
5844 finally {
5845 if (count == null) {
5846 count = Long.valueOf(0);
5847 }
5848
5849 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_H_P, finderArgs,
5850 count);
5851
5852 closeSession(session);
5853 }
5854 }
5855
5856 return count.intValue();
5857 }
5858
5859
5867 public int countByP_NotS(long plid, int status) throws SystemException {
5868 Object[] finderArgs = new Object[] { plid, status };
5869
5870 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS,
5871 finderArgs, this);
5872
5873 if (count == null) {
5874 StringBundler query = new StringBundler(3);
5875
5876 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5877
5878 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
5879
5880 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
5881
5882 String sql = query.toString();
5883
5884 Session session = null;
5885
5886 try {
5887 session = openSession();
5888
5889 Query q = session.createQuery(sql);
5890
5891 QueryPos qPos = QueryPos.getInstance(q);
5892
5893 qPos.add(plid);
5894
5895 qPos.add(status);
5896
5897 count = (Long)q.uniqueResult();
5898 }
5899 catch (Exception e) {
5900 throw processException(e);
5901 }
5902 finally {
5903 if (count == null) {
5904 count = Long.valueOf(0);
5905 }
5906
5907 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS,
5908 finderArgs, count);
5909
5910 closeSession(session);
5911 }
5912 }
5913
5914 return count.intValue();
5915 }
5916
5917
5926 public int countByL_L_P(long layoutSetBranchId, long layoutBranchId,
5927 long plid) throws SystemException {
5928 Object[] finderArgs = new Object[] {
5929 layoutSetBranchId, layoutBranchId, plid
5930 };
5931
5932 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_L_P,
5933 finderArgs, this);
5934
5935 if (count == null) {
5936 StringBundler query = new StringBundler(4);
5937
5938 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5939
5940 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
5941
5942 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
5943
5944 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
5945
5946 String sql = query.toString();
5947
5948 Session session = null;
5949
5950 try {
5951 session = openSession();
5952
5953 Query q = session.createQuery(sql);
5954
5955 QueryPos qPos = QueryPos.getInstance(q);
5956
5957 qPos.add(layoutSetBranchId);
5958
5959 qPos.add(layoutBranchId);
5960
5961 qPos.add(plid);
5962
5963 count = (Long)q.uniqueResult();
5964 }
5965 catch (Exception e) {
5966 throw processException(e);
5967 }
5968 finally {
5969 if (count == null) {
5970 count = Long.valueOf(0);
5971 }
5972
5973 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_L_P,
5974 finderArgs, count);
5975
5976 closeSession(session);
5977 }
5978 }
5979
5980 return count.intValue();
5981 }
5982
5983
5992 public int countByL_P_P(long layoutSetBranchId,
5993 long parentLayoutRevisionId, long plid) throws SystemException {
5994 Object[] finderArgs = new Object[] {
5995 layoutSetBranchId, parentLayoutRevisionId, plid
5996 };
5997
5998 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_P,
5999 finderArgs, this);
6000
6001 if (count == null) {
6002 StringBundler query = new StringBundler(4);
6003
6004 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6005
6006 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
6007
6008 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
6009
6010 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
6011
6012 String sql = query.toString();
6013
6014 Session session = null;
6015
6016 try {
6017 session = openSession();
6018
6019 Query q = session.createQuery(sql);
6020
6021 QueryPos qPos = QueryPos.getInstance(q);
6022
6023 qPos.add(layoutSetBranchId);
6024
6025 qPos.add(parentLayoutRevisionId);
6026
6027 qPos.add(plid);
6028
6029 count = (Long)q.uniqueResult();
6030 }
6031 catch (Exception e) {
6032 throw processException(e);
6033 }
6034 finally {
6035 if (count == null) {
6036 count = Long.valueOf(0);
6037 }
6038
6039 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_P,
6040 finderArgs, count);
6041
6042 closeSession(session);
6043 }
6044 }
6045
6046 return count.intValue();
6047 }
6048
6049
6058 public int countByL_H_P(long layoutSetBranchId, boolean head, long plid)
6059 throws SystemException {
6060 Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
6061
6062 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_H_P,
6063 finderArgs, this);
6064
6065 if (count == null) {
6066 StringBundler query = new StringBundler(4);
6067
6068 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6069
6070 query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
6071
6072 query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
6073
6074 query.append(_FINDER_COLUMN_L_H_P_PLID_2);
6075
6076 String sql = query.toString();
6077
6078 Session session = null;
6079
6080 try {
6081 session = openSession();
6082
6083 Query q = session.createQuery(sql);
6084
6085 QueryPos qPos = QueryPos.getInstance(q);
6086
6087 qPos.add(layoutSetBranchId);
6088
6089 qPos.add(head);
6090
6091 qPos.add(plid);
6092
6093 count = (Long)q.uniqueResult();
6094 }
6095 catch (Exception e) {
6096 throw processException(e);
6097 }
6098 finally {
6099 if (count == null) {
6100 count = Long.valueOf(0);
6101 }
6102
6103 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H_P,
6104 finderArgs, count);
6105
6106 closeSession(session);
6107 }
6108 }
6109
6110 return count.intValue();
6111 }
6112
6113
6122 public int countByL_P_S(long layoutSetBranchId, long plid, int status)
6123 throws SystemException {
6124 Object[] finderArgs = new Object[] { layoutSetBranchId, plid, status };
6125
6126 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_S,
6127 finderArgs, this);
6128
6129 if (count == null) {
6130 StringBundler query = new StringBundler(4);
6131
6132 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6133
6134 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
6135
6136 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
6137
6138 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
6139
6140 String sql = query.toString();
6141
6142 Session session = null;
6143
6144 try {
6145 session = openSession();
6146
6147 Query q = session.createQuery(sql);
6148
6149 QueryPos qPos = QueryPos.getInstance(q);
6150
6151 qPos.add(layoutSetBranchId);
6152
6153 qPos.add(plid);
6154
6155 qPos.add(status);
6156
6157 count = (Long)q.uniqueResult();
6158 }
6159 catch (Exception e) {
6160 throw processException(e);
6161 }
6162 finally {
6163 if (count == null) {
6164 count = Long.valueOf(0);
6165 }
6166
6167 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_S,
6168 finderArgs, count);
6169
6170 closeSession(session);
6171 }
6172 }
6173
6174 return count.intValue();
6175 }
6176
6177
6183 public int countAll() throws SystemException {
6184 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
6185 FINDER_ARGS_EMPTY, this);
6186
6187 if (count == null) {
6188 Session session = null;
6189
6190 try {
6191 session = openSession();
6192
6193 Query q = session.createQuery(_SQL_COUNT_LAYOUTREVISION);
6194
6195 count = (Long)q.uniqueResult();
6196 }
6197 catch (Exception e) {
6198 throw processException(e);
6199 }
6200 finally {
6201 if (count == null) {
6202 count = Long.valueOf(0);
6203 }
6204
6205 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
6206 FINDER_ARGS_EMPTY, count);
6207
6208 closeSession(session);
6209 }
6210 }
6211
6212 return count.intValue();
6213 }
6214
6215
6218 public void afterPropertiesSet() {
6219 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6220 com.liferay.portal.util.PropsUtil.get(
6221 "value.object.listener.com.liferay.portal.model.LayoutRevision")));
6222
6223 if (listenerClassNames.length > 0) {
6224 try {
6225 List<ModelListener<LayoutRevision>> listenersList = new ArrayList<ModelListener<LayoutRevision>>();
6226
6227 for (String listenerClassName : listenerClassNames) {
6228 listenersList.add((ModelListener<LayoutRevision>)InstanceFactory.newInstance(
6229 listenerClassName));
6230 }
6231
6232 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6233 }
6234 catch (Exception e) {
6235 _log.error(e);
6236 }
6237 }
6238 }
6239
6240 public void destroy() {
6241 EntityCacheUtil.removeCache(LayoutRevisionImpl.class.getName());
6242 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6243 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6244 }
6245
6246 @BeanReference(type = AccountPersistence.class)
6247 protected AccountPersistence accountPersistence;
6248 @BeanReference(type = AddressPersistence.class)
6249 protected AddressPersistence addressPersistence;
6250 @BeanReference(type = BrowserTrackerPersistence.class)
6251 protected BrowserTrackerPersistence browserTrackerPersistence;
6252 @BeanReference(type = ClassNamePersistence.class)
6253 protected ClassNamePersistence classNamePersistence;
6254 @BeanReference(type = ClusterGroupPersistence.class)
6255 protected ClusterGroupPersistence clusterGroupPersistence;
6256 @BeanReference(type = CompanyPersistence.class)
6257 protected CompanyPersistence companyPersistence;
6258 @BeanReference(type = ContactPersistence.class)
6259 protected ContactPersistence contactPersistence;
6260 @BeanReference(type = CountryPersistence.class)
6261 protected CountryPersistence countryPersistence;
6262 @BeanReference(type = EmailAddressPersistence.class)
6263 protected EmailAddressPersistence emailAddressPersistence;
6264 @BeanReference(type = GroupPersistence.class)
6265 protected GroupPersistence groupPersistence;
6266 @BeanReference(type = ImagePersistence.class)
6267 protected ImagePersistence imagePersistence;
6268 @BeanReference(type = LayoutPersistence.class)
6269 protected LayoutPersistence layoutPersistence;
6270 @BeanReference(type = LayoutBranchPersistence.class)
6271 protected LayoutBranchPersistence layoutBranchPersistence;
6272 @BeanReference(type = LayoutPrototypePersistence.class)
6273 protected LayoutPrototypePersistence layoutPrototypePersistence;
6274 @BeanReference(type = LayoutRevisionPersistence.class)
6275 protected LayoutRevisionPersistence layoutRevisionPersistence;
6276 @BeanReference(type = LayoutSetPersistence.class)
6277 protected LayoutSetPersistence layoutSetPersistence;
6278 @BeanReference(type = LayoutSetBranchPersistence.class)
6279 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6280 @BeanReference(type = LayoutSetPrototypePersistence.class)
6281 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6282 @BeanReference(type = ListTypePersistence.class)
6283 protected ListTypePersistence listTypePersistence;
6284 @BeanReference(type = LockPersistence.class)
6285 protected LockPersistence lockPersistence;
6286 @BeanReference(type = MembershipRequestPersistence.class)
6287 protected MembershipRequestPersistence membershipRequestPersistence;
6288 @BeanReference(type = OrganizationPersistence.class)
6289 protected OrganizationPersistence organizationPersistence;
6290 @BeanReference(type = OrgGroupRolePersistence.class)
6291 protected OrgGroupRolePersistence orgGroupRolePersistence;
6292 @BeanReference(type = OrgLaborPersistence.class)
6293 protected OrgLaborPersistence orgLaborPersistence;
6294 @BeanReference(type = PasswordPolicyPersistence.class)
6295 protected PasswordPolicyPersistence passwordPolicyPersistence;
6296 @BeanReference(type = PasswordPolicyRelPersistence.class)
6297 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6298 @BeanReference(type = PasswordTrackerPersistence.class)
6299 protected PasswordTrackerPersistence passwordTrackerPersistence;
6300 @BeanReference(type = PhonePersistence.class)
6301 protected PhonePersistence phonePersistence;
6302 @BeanReference(type = PluginSettingPersistence.class)
6303 protected PluginSettingPersistence pluginSettingPersistence;
6304 @BeanReference(type = PortalPreferencesPersistence.class)
6305 protected PortalPreferencesPersistence portalPreferencesPersistence;
6306 @BeanReference(type = PortletPersistence.class)
6307 protected PortletPersistence portletPersistence;
6308 @BeanReference(type = PortletItemPersistence.class)
6309 protected PortletItemPersistence portletItemPersistence;
6310 @BeanReference(type = PortletPreferencesPersistence.class)
6311 protected PortletPreferencesPersistence portletPreferencesPersistence;
6312 @BeanReference(type = RegionPersistence.class)
6313 protected RegionPersistence regionPersistence;
6314 @BeanReference(type = ReleasePersistence.class)
6315 protected ReleasePersistence releasePersistence;
6316 @BeanReference(type = RepositoryPersistence.class)
6317 protected RepositoryPersistence repositoryPersistence;
6318 @BeanReference(type = RepositoryEntryPersistence.class)
6319 protected RepositoryEntryPersistence repositoryEntryPersistence;
6320 @BeanReference(type = ResourceActionPersistence.class)
6321 protected ResourceActionPersistence resourceActionPersistence;
6322 @BeanReference(type = ResourceBlockPersistence.class)
6323 protected ResourceBlockPersistence resourceBlockPersistence;
6324 @BeanReference(type = ResourceBlockPermissionPersistence.class)
6325 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6326 @BeanReference(type = ResourcePermissionPersistence.class)
6327 protected ResourcePermissionPersistence resourcePermissionPersistence;
6328 @BeanReference(type = ResourceTypePermissionPersistence.class)
6329 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6330 @BeanReference(type = RolePersistence.class)
6331 protected RolePersistence rolePersistence;
6332 @BeanReference(type = ServiceComponentPersistence.class)
6333 protected ServiceComponentPersistence serviceComponentPersistence;
6334 @BeanReference(type = ShardPersistence.class)
6335 protected ShardPersistence shardPersistence;
6336 @BeanReference(type = SubscriptionPersistence.class)
6337 protected SubscriptionPersistence subscriptionPersistence;
6338 @BeanReference(type = TeamPersistence.class)
6339 protected TeamPersistence teamPersistence;
6340 @BeanReference(type = TicketPersistence.class)
6341 protected TicketPersistence ticketPersistence;
6342 @BeanReference(type = UserPersistence.class)
6343 protected UserPersistence userPersistence;
6344 @BeanReference(type = UserGroupPersistence.class)
6345 protected UserGroupPersistence userGroupPersistence;
6346 @BeanReference(type = UserGroupGroupRolePersistence.class)
6347 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6348 @BeanReference(type = UserGroupRolePersistence.class)
6349 protected UserGroupRolePersistence userGroupRolePersistence;
6350 @BeanReference(type = UserIdMapperPersistence.class)
6351 protected UserIdMapperPersistence userIdMapperPersistence;
6352 @BeanReference(type = UserNotificationEventPersistence.class)
6353 protected UserNotificationEventPersistence userNotificationEventPersistence;
6354 @BeanReference(type = UserTrackerPersistence.class)
6355 protected UserTrackerPersistence userTrackerPersistence;
6356 @BeanReference(type = UserTrackerPathPersistence.class)
6357 protected UserTrackerPathPersistence userTrackerPathPersistence;
6358 @BeanReference(type = VirtualHostPersistence.class)
6359 protected VirtualHostPersistence virtualHostPersistence;
6360 @BeanReference(type = WebDAVPropsPersistence.class)
6361 protected WebDAVPropsPersistence webDAVPropsPersistence;
6362 @BeanReference(type = WebsitePersistence.class)
6363 protected WebsitePersistence websitePersistence;
6364 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6365 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6366 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6367 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6368 private static final String _SQL_SELECT_LAYOUTREVISION = "SELECT layoutRevision FROM LayoutRevision layoutRevision";
6369 private static final String _SQL_SELECT_LAYOUTREVISION_WHERE = "SELECT layoutRevision FROM LayoutRevision layoutRevision WHERE ";
6370 private static final String _SQL_COUNT_LAYOUTREVISION = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision";
6371 private static final String _SQL_COUNT_LAYOUTREVISION_WHERE = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision WHERE ";
6372 private static final String _FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2 =
6373 "layoutRevision.layoutSetBranchId = ?";
6374 private static final String _FINDER_COLUMN_PLID_PLID_2 = "layoutRevision.plid = ?";
6375 private static final String _FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6376 private static final String _FINDER_COLUMN_L_H_HEAD_2 = "layoutRevision.head = ?";
6377 private static final String _FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6378 private static final String _FINDER_COLUMN_L_P_PLID_2 = "layoutRevision.plid = ?";
6379 private static final String _FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6380 private static final String _FINDER_COLUMN_L_S_STATUS_2 = "layoutRevision.status = ?";
6381 private static final String _FINDER_COLUMN_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
6382 private static final String _FINDER_COLUMN_H_P_PLID_2 = "layoutRevision.plid = ?";
6383 private static final String _FINDER_COLUMN_P_NOTS_PLID_2 = "layoutRevision.plid = ? AND ";
6384 private static final String _FINDER_COLUMN_P_NOTS_STATUS_2 = "layoutRevision.status != ?";
6385 private static final String _FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6386 private static final String _FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2 = "layoutRevision.layoutBranchId = ? AND ";
6387 private static final String _FINDER_COLUMN_L_L_P_PLID_2 = "layoutRevision.plid = ? AND layoutRevision.status != 5";
6388 private static final String _FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6389 private static final String _FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2 = "layoutRevision.parentLayoutRevisionId = ? AND ";
6390 private static final String _FINDER_COLUMN_L_P_P_PLID_2 = "layoutRevision.plid = ?";
6391 private static final String _FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6392 private static final String _FINDER_COLUMN_L_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
6393 private static final String _FINDER_COLUMN_L_H_P_PLID_2 = "layoutRevision.plid = ?";
6394 private static final String _FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6395 private static final String _FINDER_COLUMN_L_P_S_PLID_2 = "layoutRevision.plid = ? AND ";
6396 private static final String _FINDER_COLUMN_L_P_S_STATUS_2 = "layoutRevision.status = ?";
6397 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutRevision.";
6398 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutRevision exists with the primary key ";
6399 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutRevision exists with the key {";
6400 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6401 private static Log _log = LogFactoryUtil.getLog(LayoutRevisionPersistenceImpl.class);
6402 private static LayoutRevision _nullLayoutRevision = new LayoutRevisionImpl() {
6403 @Override
6404 public Object clone() {
6405 return this;
6406 }
6407
6408 @Override
6409 public CacheModel<LayoutRevision> toCacheModel() {
6410 return _nullLayoutRevisionCacheModel;
6411 }
6412 };
6413
6414 private static CacheModel<LayoutRevision> _nullLayoutRevisionCacheModel = new CacheModel<LayoutRevision>() {
6415 public LayoutRevision toEntityModel() {
6416 return _nullLayoutRevision;
6417 }
6418 };
6419 }