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 BatchSessionUtil.delete(session, layoutRevision);
502 }
503 catch (Exception e) {
504 throw processException(e);
505 }
506 finally {
507 closeSession(session);
508 }
509
510 clearCache(layoutRevision);
511
512 return layoutRevision;
513 }
514
515 @Override
516 public LayoutRevision updateImpl(
517 com.liferay.portal.model.LayoutRevision layoutRevision, boolean merge)
518 throws SystemException {
519 layoutRevision = toUnwrappedModel(layoutRevision);
520
521 boolean isNew = layoutRevision.isNew();
522
523 LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
524
525 Session session = null;
526
527 try {
528 session = openSession();
529
530 BatchSessionUtil.update(session, layoutRevision, merge);
531
532 layoutRevision.setNew(false);
533 }
534 catch (Exception e) {
535 throw processException(e);
536 }
537 finally {
538 closeSession(session);
539 }
540
541 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
542
543 if (isNew || !LayoutRevisionModelImpl.COLUMN_BITMASK_ENABLED) {
544 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
545 }
546
547 else {
548 if ((layoutRevisionModelImpl.getColumnBitmask() &
549 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID.getColumnBitmask()) != 0) {
550 Object[] args = new Object[] {
551 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId())
552 };
553
554 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
555 args);
556 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
557 args);
558
559 args = new Object[] {
560 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId())
561 };
562
563 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
564 args);
565 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
566 args);
567 }
568
569 if ((layoutRevisionModelImpl.getColumnBitmask() &
570 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID.getColumnBitmask()) != 0) {
571 Object[] args = new Object[] {
572 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
573 };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
576 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
577 args);
578
579 args = new Object[] {
580 Long.valueOf(layoutRevisionModelImpl.getPlid())
581 };
582
583 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
584 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
585 args);
586 }
587
588 if ((layoutRevisionModelImpl.getColumnBitmask() &
589 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H.getColumnBitmask()) != 0) {
590 Object[] args = new Object[] {
591 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
592 Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead())
593 };
594
595 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
596 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
597 args);
598
599 args = new Object[] {
600 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
601 Boolean.valueOf(layoutRevisionModelImpl.getHead())
602 };
603
604 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
605 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
606 args);
607 }
608
609 if ((layoutRevisionModelImpl.getColumnBitmask() &
610 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
611 Object[] args = new Object[] {
612 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
613 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
614 };
615
616 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
617 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
618 args);
619
620 args = new Object[] {
621 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
622 Long.valueOf(layoutRevisionModelImpl.getPlid())
623 };
624
625 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
626 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
627 args);
628 }
629
630 if ((layoutRevisionModelImpl.getColumnBitmask() &
631 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S.getColumnBitmask()) != 0) {
632 Object[] args = new Object[] {
633 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
634 Integer.valueOf(layoutRevisionModelImpl.getOriginalStatus())
635 };
636
637 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
638 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
639 args);
640
641 args = new Object[] {
642 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
643 Integer.valueOf(layoutRevisionModelImpl.getStatus())
644 };
645
646 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
647 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
648 args);
649 }
650
651 if ((layoutRevisionModelImpl.getColumnBitmask() &
652 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P.getColumnBitmask()) != 0) {
653 Object[] args = new Object[] {
654 Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead()),
655 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
656 };
657
658 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
659 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
660 args);
661
662 args = new Object[] {
663 Boolean.valueOf(layoutRevisionModelImpl.getHead()),
664 Long.valueOf(layoutRevisionModelImpl.getPlid())
665 };
666
667 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
668 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
669 args);
670 }
671
672 if ((layoutRevisionModelImpl.getColumnBitmask() &
673 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P.getColumnBitmask()) != 0) {
674 Object[] args = new Object[] {
675 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
676 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutBranchId()),
677 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
678 };
679
680 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_L_P, args);
681 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P,
682 args);
683
684 args = new Object[] {
685 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
686 Long.valueOf(layoutRevisionModelImpl.getLayoutBranchId()),
687 Long.valueOf(layoutRevisionModelImpl.getPlid())
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
695 if ((layoutRevisionModelImpl.getColumnBitmask() &
696 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P.getColumnBitmask()) != 0) {
697 Object[] args = new Object[] {
698 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
699 Long.valueOf(layoutRevisionModelImpl.getOriginalParentLayoutRevisionId()),
700 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
701 };
702
703 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_P, args);
704 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P,
705 args);
706
707 args = new Object[] {
708 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
709 Long.valueOf(layoutRevisionModelImpl.getParentLayoutRevisionId()),
710 Long.valueOf(layoutRevisionModelImpl.getPlid())
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
718 if ((layoutRevisionModelImpl.getColumnBitmask() &
719 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S.getColumnBitmask()) != 0) {
720 Object[] args = new Object[] {
721 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
722 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid()),
723 Integer.valueOf(layoutRevisionModelImpl.getOriginalStatus())
724 };
725
726 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_S, args);
727 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S,
728 args);
729
730 args = new Object[] {
731 Long.valueOf(layoutRevisionModelImpl.getLayoutSetBranchId()),
732 Long.valueOf(layoutRevisionModelImpl.getPlid()),
733 Integer.valueOf(layoutRevisionModelImpl.getStatus())
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 }
741
742 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
743 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey(),
744 layoutRevision);
745
746 if (isNew) {
747 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
748 new Object[] {
749 Long.valueOf(layoutRevision.getLayoutSetBranchId()),
750 Boolean.valueOf(layoutRevision.getHead()),
751 Long.valueOf(layoutRevision.getPlid())
752 }, layoutRevision);
753 }
754 else {
755 if ((layoutRevisionModelImpl.getColumnBitmask() &
756 FINDER_PATH_FETCH_BY_L_H_P.getColumnBitmask()) != 0) {
757 Object[] args = new Object[] {
758 Long.valueOf(layoutRevisionModelImpl.getOriginalLayoutSetBranchId()),
759 Boolean.valueOf(layoutRevisionModelImpl.getOriginalHead()),
760 Long.valueOf(layoutRevisionModelImpl.getOriginalPlid())
761 };
762
763 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H_P, args);
764
765 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P, args);
766
767 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
768 new Object[] {
769 Long.valueOf(layoutRevision.getLayoutSetBranchId()),
770 Boolean.valueOf(layoutRevision.getHead()),
771 Long.valueOf(layoutRevision.getPlid())
772 }, layoutRevision);
773 }
774 }
775
776 return layoutRevision;
777 }
778
779 protected LayoutRevision toUnwrappedModel(LayoutRevision layoutRevision) {
780 if (layoutRevision instanceof LayoutRevisionImpl) {
781 return layoutRevision;
782 }
783
784 LayoutRevisionImpl layoutRevisionImpl = new LayoutRevisionImpl();
785
786 layoutRevisionImpl.setNew(layoutRevision.isNew());
787 layoutRevisionImpl.setPrimaryKey(layoutRevision.getPrimaryKey());
788
789 layoutRevisionImpl.setLayoutRevisionId(layoutRevision.getLayoutRevisionId());
790 layoutRevisionImpl.setGroupId(layoutRevision.getGroupId());
791 layoutRevisionImpl.setCompanyId(layoutRevision.getCompanyId());
792 layoutRevisionImpl.setUserId(layoutRevision.getUserId());
793 layoutRevisionImpl.setUserName(layoutRevision.getUserName());
794 layoutRevisionImpl.setCreateDate(layoutRevision.getCreateDate());
795 layoutRevisionImpl.setModifiedDate(layoutRevision.getModifiedDate());
796 layoutRevisionImpl.setLayoutSetBranchId(layoutRevision.getLayoutSetBranchId());
797 layoutRevisionImpl.setLayoutBranchId(layoutRevision.getLayoutBranchId());
798 layoutRevisionImpl.setParentLayoutRevisionId(layoutRevision.getParentLayoutRevisionId());
799 layoutRevisionImpl.setHead(layoutRevision.isHead());
800 layoutRevisionImpl.setMajor(layoutRevision.isMajor());
801 layoutRevisionImpl.setPlid(layoutRevision.getPlid());
802 layoutRevisionImpl.setPrivateLayout(layoutRevision.isPrivateLayout());
803 layoutRevisionImpl.setName(layoutRevision.getName());
804 layoutRevisionImpl.setTitle(layoutRevision.getTitle());
805 layoutRevisionImpl.setDescription(layoutRevision.getDescription());
806 layoutRevisionImpl.setKeywords(layoutRevision.getKeywords());
807 layoutRevisionImpl.setRobots(layoutRevision.getRobots());
808 layoutRevisionImpl.setTypeSettings(layoutRevision.getTypeSettings());
809 layoutRevisionImpl.setIconImage(layoutRevision.isIconImage());
810 layoutRevisionImpl.setIconImageId(layoutRevision.getIconImageId());
811 layoutRevisionImpl.setThemeId(layoutRevision.getThemeId());
812 layoutRevisionImpl.setColorSchemeId(layoutRevision.getColorSchemeId());
813 layoutRevisionImpl.setWapThemeId(layoutRevision.getWapThemeId());
814 layoutRevisionImpl.setWapColorSchemeId(layoutRevision.getWapColorSchemeId());
815 layoutRevisionImpl.setCss(layoutRevision.getCss());
816 layoutRevisionImpl.setStatus(layoutRevision.getStatus());
817 layoutRevisionImpl.setStatusByUserId(layoutRevision.getStatusByUserId());
818 layoutRevisionImpl.setStatusByUserName(layoutRevision.getStatusByUserName());
819 layoutRevisionImpl.setStatusDate(layoutRevision.getStatusDate());
820
821 return layoutRevisionImpl;
822 }
823
824
832 @Override
833 public LayoutRevision findByPrimaryKey(Serializable primaryKey)
834 throws NoSuchModelException, SystemException {
835 return findByPrimaryKey(((Long)primaryKey).longValue());
836 }
837
838
846 public LayoutRevision findByPrimaryKey(long layoutRevisionId)
847 throws NoSuchLayoutRevisionException, SystemException {
848 LayoutRevision layoutRevision = fetchByPrimaryKey(layoutRevisionId);
849
850 if (layoutRevision == null) {
851 if (_log.isWarnEnabled()) {
852 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutRevisionId);
853 }
854
855 throw new NoSuchLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
856 layoutRevisionId);
857 }
858
859 return layoutRevision;
860 }
861
862
869 @Override
870 public LayoutRevision fetchByPrimaryKey(Serializable primaryKey)
871 throws SystemException {
872 return fetchByPrimaryKey(((Long)primaryKey).longValue());
873 }
874
875
882 public LayoutRevision fetchByPrimaryKey(long layoutRevisionId)
883 throws SystemException {
884 LayoutRevision layoutRevision = (LayoutRevision)EntityCacheUtil.getResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
885 LayoutRevisionImpl.class, layoutRevisionId);
886
887 if (layoutRevision == _nullLayoutRevision) {
888 return null;
889 }
890
891 if (layoutRevision == null) {
892 Session session = null;
893
894 boolean hasException = false;
895
896 try {
897 session = openSession();
898
899 layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
900 Long.valueOf(layoutRevisionId));
901 }
902 catch (Exception e) {
903 hasException = true;
904
905 throw processException(e);
906 }
907 finally {
908 if (layoutRevision != null) {
909 cacheResult(layoutRevision);
910 }
911 else if (!hasException) {
912 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
913 LayoutRevisionImpl.class, layoutRevisionId,
914 _nullLayoutRevision);
915 }
916
917 closeSession(session);
918 }
919 }
920
921 return layoutRevision;
922 }
923
924
931 public List<LayoutRevision> findByLayoutSetBranchId(long layoutSetBranchId)
932 throws SystemException {
933 return findByLayoutSetBranchId(layoutSetBranchId, QueryUtil.ALL_POS,
934 QueryUtil.ALL_POS, null);
935 }
936
937
950 public List<LayoutRevision> findByLayoutSetBranchId(
951 long layoutSetBranchId, int start, int end) throws SystemException {
952 return findByLayoutSetBranchId(layoutSetBranchId, start, end, null);
953 }
954
955
969 public List<LayoutRevision> findByLayoutSetBranchId(
970 long layoutSetBranchId, int start, int end,
971 OrderByComparator orderByComparator) throws SystemException {
972 FinderPath finderPath = null;
973 Object[] finderArgs = null;
974
975 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
976 (orderByComparator == null)) {
977 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
978 finderArgs = new Object[] { layoutSetBranchId };
979 }
980 else {
981 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
982 finderArgs = new Object[] {
983 layoutSetBranchId,
984
985 start, end, orderByComparator
986 };
987 }
988
989 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
990 finderArgs, this);
991
992 if ((list != null) && !list.isEmpty()) {
993 for (LayoutRevision layoutRevision : list) {
994 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId())) {
995 list = null;
996
997 break;
998 }
999 }
1000 }
1001
1002 if (list == null) {
1003 StringBundler query = null;
1004
1005 if (orderByComparator != null) {
1006 query = new StringBundler(3 +
1007 (orderByComparator.getOrderByFields().length * 3));
1008 }
1009 else {
1010 query = new StringBundler(3);
1011 }
1012
1013 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1014
1015 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
1016
1017 if (orderByComparator != null) {
1018 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1019 orderByComparator);
1020 }
1021
1022 else {
1023 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1024 }
1025
1026 String sql = query.toString();
1027
1028 Session session = null;
1029
1030 try {
1031 session = openSession();
1032
1033 Query q = session.createQuery(sql);
1034
1035 QueryPos qPos = QueryPos.getInstance(q);
1036
1037 qPos.add(layoutSetBranchId);
1038
1039 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1040 start, end);
1041 }
1042 catch (Exception e) {
1043 throw processException(e);
1044 }
1045 finally {
1046 if (list == null) {
1047 FinderCacheUtil.removeResult(finderPath, finderArgs);
1048 }
1049 else {
1050 cacheResult(list);
1051
1052 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1053 }
1054
1055 closeSession(session);
1056 }
1057 }
1058
1059 return list;
1060 }
1061
1062
1071 public LayoutRevision findByLayoutSetBranchId_First(
1072 long layoutSetBranchId, OrderByComparator orderByComparator)
1073 throws NoSuchLayoutRevisionException, SystemException {
1074 LayoutRevision layoutRevision = fetchByLayoutSetBranchId_First(layoutSetBranchId,
1075 orderByComparator);
1076
1077 if (layoutRevision != null) {
1078 return layoutRevision;
1079 }
1080
1081 StringBundler msg = new StringBundler(4);
1082
1083 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1084
1085 msg.append("layoutSetBranchId=");
1086 msg.append(layoutSetBranchId);
1087
1088 msg.append(StringPool.CLOSE_CURLY_BRACE);
1089
1090 throw new NoSuchLayoutRevisionException(msg.toString());
1091 }
1092
1093
1101 public LayoutRevision fetchByLayoutSetBranchId_First(
1102 long layoutSetBranchId, OrderByComparator orderByComparator)
1103 throws SystemException {
1104 List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
1105 0, 1, orderByComparator);
1106
1107 if (!list.isEmpty()) {
1108 return list.get(0);
1109 }
1110
1111 return null;
1112 }
1113
1114
1123 public LayoutRevision findByLayoutSetBranchId_Last(long layoutSetBranchId,
1124 OrderByComparator orderByComparator)
1125 throws NoSuchLayoutRevisionException, SystemException {
1126 LayoutRevision layoutRevision = fetchByLayoutSetBranchId_Last(layoutSetBranchId,
1127 orderByComparator);
1128
1129 if (layoutRevision != null) {
1130 return layoutRevision;
1131 }
1132
1133 StringBundler msg = new StringBundler(4);
1134
1135 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1136
1137 msg.append("layoutSetBranchId=");
1138 msg.append(layoutSetBranchId);
1139
1140 msg.append(StringPool.CLOSE_CURLY_BRACE);
1141
1142 throw new NoSuchLayoutRevisionException(msg.toString());
1143 }
1144
1145
1153 public LayoutRevision fetchByLayoutSetBranchId_Last(
1154 long layoutSetBranchId, OrderByComparator orderByComparator)
1155 throws SystemException {
1156 int count = countByLayoutSetBranchId(layoutSetBranchId);
1157
1158 List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
1159 count - 1, count, orderByComparator);
1160
1161 if (!list.isEmpty()) {
1162 return list.get(0);
1163 }
1164
1165 return null;
1166 }
1167
1168
1178 public LayoutRevision[] findByLayoutSetBranchId_PrevAndNext(
1179 long layoutRevisionId, long layoutSetBranchId,
1180 OrderByComparator orderByComparator)
1181 throws NoSuchLayoutRevisionException, SystemException {
1182 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1183
1184 Session session = null;
1185
1186 try {
1187 session = openSession();
1188
1189 LayoutRevision[] array = new LayoutRevisionImpl[3];
1190
1191 array[0] = getByLayoutSetBranchId_PrevAndNext(session,
1192 layoutRevision, layoutSetBranchId, orderByComparator, true);
1193
1194 array[1] = layoutRevision;
1195
1196 array[2] = getByLayoutSetBranchId_PrevAndNext(session,
1197 layoutRevision, layoutSetBranchId, orderByComparator, false);
1198
1199 return array;
1200 }
1201 catch (Exception e) {
1202 throw processException(e);
1203 }
1204 finally {
1205 closeSession(session);
1206 }
1207 }
1208
1209 protected LayoutRevision getByLayoutSetBranchId_PrevAndNext(
1210 Session session, LayoutRevision layoutRevision, long layoutSetBranchId,
1211 OrderByComparator orderByComparator, boolean previous) {
1212 StringBundler query = null;
1213
1214 if (orderByComparator != null) {
1215 query = new StringBundler(6 +
1216 (orderByComparator.getOrderByFields().length * 6));
1217 }
1218 else {
1219 query = new StringBundler(3);
1220 }
1221
1222 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1223
1224 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
1225
1226 if (orderByComparator != null) {
1227 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1228
1229 if (orderByConditionFields.length > 0) {
1230 query.append(WHERE_AND);
1231 }
1232
1233 for (int i = 0; i < orderByConditionFields.length; i++) {
1234 query.append(_ORDER_BY_ENTITY_ALIAS);
1235 query.append(orderByConditionFields[i]);
1236
1237 if ((i + 1) < orderByConditionFields.length) {
1238 if (orderByComparator.isAscending() ^ previous) {
1239 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1240 }
1241 else {
1242 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1243 }
1244 }
1245 else {
1246 if (orderByComparator.isAscending() ^ previous) {
1247 query.append(WHERE_GREATER_THAN);
1248 }
1249 else {
1250 query.append(WHERE_LESSER_THAN);
1251 }
1252 }
1253 }
1254
1255 query.append(ORDER_BY_CLAUSE);
1256
1257 String[] orderByFields = orderByComparator.getOrderByFields();
1258
1259 for (int i = 0; i < orderByFields.length; i++) {
1260 query.append(_ORDER_BY_ENTITY_ALIAS);
1261 query.append(orderByFields[i]);
1262
1263 if ((i + 1) < orderByFields.length) {
1264 if (orderByComparator.isAscending() ^ previous) {
1265 query.append(ORDER_BY_ASC_HAS_NEXT);
1266 }
1267 else {
1268 query.append(ORDER_BY_DESC_HAS_NEXT);
1269 }
1270 }
1271 else {
1272 if (orderByComparator.isAscending() ^ previous) {
1273 query.append(ORDER_BY_ASC);
1274 }
1275 else {
1276 query.append(ORDER_BY_DESC);
1277 }
1278 }
1279 }
1280 }
1281
1282 else {
1283 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1284 }
1285
1286 String sql = query.toString();
1287
1288 Query q = session.createQuery(sql);
1289
1290 q.setFirstResult(0);
1291 q.setMaxResults(2);
1292
1293 QueryPos qPos = QueryPos.getInstance(q);
1294
1295 qPos.add(layoutSetBranchId);
1296
1297 if (orderByComparator != null) {
1298 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1299
1300 for (Object value : values) {
1301 qPos.add(value);
1302 }
1303 }
1304
1305 List<LayoutRevision> list = q.list();
1306
1307 if (list.size() == 2) {
1308 return list.get(1);
1309 }
1310 else {
1311 return null;
1312 }
1313 }
1314
1315
1322 public List<LayoutRevision> findByPlid(long plid) throws SystemException {
1323 return findByPlid(plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1324 }
1325
1326
1339 public List<LayoutRevision> findByPlid(long plid, int start, int end)
1340 throws SystemException {
1341 return findByPlid(plid, start, end, null);
1342 }
1343
1344
1358 public List<LayoutRevision> findByPlid(long plid, int start, int end,
1359 OrderByComparator orderByComparator) throws SystemException {
1360 FinderPath finderPath = null;
1361 Object[] finderArgs = null;
1362
1363 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1364 (orderByComparator == null)) {
1365 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID;
1366 finderArgs = new Object[] { plid };
1367 }
1368 else {
1369 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID;
1370 finderArgs = new Object[] { plid, start, end, orderByComparator };
1371 }
1372
1373 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1374 finderArgs, this);
1375
1376 if ((list != null) && !list.isEmpty()) {
1377 for (LayoutRevision layoutRevision : list) {
1378 if ((plid != layoutRevision.getPlid())) {
1379 list = null;
1380
1381 break;
1382 }
1383 }
1384 }
1385
1386 if (list == null) {
1387 StringBundler query = null;
1388
1389 if (orderByComparator != null) {
1390 query = new StringBundler(3 +
1391 (orderByComparator.getOrderByFields().length * 3));
1392 }
1393 else {
1394 query = new StringBundler(3);
1395 }
1396
1397 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1398
1399 query.append(_FINDER_COLUMN_PLID_PLID_2);
1400
1401 if (orderByComparator != null) {
1402 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1403 orderByComparator);
1404 }
1405
1406 else {
1407 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1408 }
1409
1410 String sql = query.toString();
1411
1412 Session session = null;
1413
1414 try {
1415 session = openSession();
1416
1417 Query q = session.createQuery(sql);
1418
1419 QueryPos qPos = QueryPos.getInstance(q);
1420
1421 qPos.add(plid);
1422
1423 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1424 start, end);
1425 }
1426 catch (Exception e) {
1427 throw processException(e);
1428 }
1429 finally {
1430 if (list == null) {
1431 FinderCacheUtil.removeResult(finderPath, finderArgs);
1432 }
1433 else {
1434 cacheResult(list);
1435
1436 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1437 }
1438
1439 closeSession(session);
1440 }
1441 }
1442
1443 return list;
1444 }
1445
1446
1455 public LayoutRevision findByPlid_First(long plid,
1456 OrderByComparator orderByComparator)
1457 throws NoSuchLayoutRevisionException, SystemException {
1458 LayoutRevision layoutRevision = fetchByPlid_First(plid,
1459 orderByComparator);
1460
1461 if (layoutRevision != null) {
1462 return layoutRevision;
1463 }
1464
1465 StringBundler msg = new StringBundler(4);
1466
1467 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1468
1469 msg.append("plid=");
1470 msg.append(plid);
1471
1472 msg.append(StringPool.CLOSE_CURLY_BRACE);
1473
1474 throw new NoSuchLayoutRevisionException(msg.toString());
1475 }
1476
1477
1485 public LayoutRevision fetchByPlid_First(long plid,
1486 OrderByComparator orderByComparator) throws SystemException {
1487 List<LayoutRevision> list = findByPlid(plid, 0, 1, orderByComparator);
1488
1489 if (!list.isEmpty()) {
1490 return list.get(0);
1491 }
1492
1493 return null;
1494 }
1495
1496
1505 public LayoutRevision findByPlid_Last(long plid,
1506 OrderByComparator orderByComparator)
1507 throws NoSuchLayoutRevisionException, SystemException {
1508 LayoutRevision layoutRevision = fetchByPlid_Last(plid, orderByComparator);
1509
1510 if (layoutRevision != null) {
1511 return layoutRevision;
1512 }
1513
1514 StringBundler msg = new StringBundler(4);
1515
1516 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1517
1518 msg.append("plid=");
1519 msg.append(plid);
1520
1521 msg.append(StringPool.CLOSE_CURLY_BRACE);
1522
1523 throw new NoSuchLayoutRevisionException(msg.toString());
1524 }
1525
1526
1534 public LayoutRevision fetchByPlid_Last(long plid,
1535 OrderByComparator orderByComparator) throws SystemException {
1536 int count = countByPlid(plid);
1537
1538 List<LayoutRevision> list = findByPlid(plid, count - 1, count,
1539 orderByComparator);
1540
1541 if (!list.isEmpty()) {
1542 return list.get(0);
1543 }
1544
1545 return null;
1546 }
1547
1548
1558 public LayoutRevision[] findByPlid_PrevAndNext(long layoutRevisionId,
1559 long plid, OrderByComparator orderByComparator)
1560 throws NoSuchLayoutRevisionException, SystemException {
1561 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1562
1563 Session session = null;
1564
1565 try {
1566 session = openSession();
1567
1568 LayoutRevision[] array = new LayoutRevisionImpl[3];
1569
1570 array[0] = getByPlid_PrevAndNext(session, layoutRevision, plid,
1571 orderByComparator, true);
1572
1573 array[1] = layoutRevision;
1574
1575 array[2] = getByPlid_PrevAndNext(session, layoutRevision, plid,
1576 orderByComparator, false);
1577
1578 return array;
1579 }
1580 catch (Exception e) {
1581 throw processException(e);
1582 }
1583 finally {
1584 closeSession(session);
1585 }
1586 }
1587
1588 protected LayoutRevision getByPlid_PrevAndNext(Session session,
1589 LayoutRevision layoutRevision, long plid,
1590 OrderByComparator orderByComparator, boolean previous) {
1591 StringBundler query = null;
1592
1593 if (orderByComparator != null) {
1594 query = new StringBundler(6 +
1595 (orderByComparator.getOrderByFields().length * 6));
1596 }
1597 else {
1598 query = new StringBundler(3);
1599 }
1600
1601 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1602
1603 query.append(_FINDER_COLUMN_PLID_PLID_2);
1604
1605 if (orderByComparator != null) {
1606 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1607
1608 if (orderByConditionFields.length > 0) {
1609 query.append(WHERE_AND);
1610 }
1611
1612 for (int i = 0; i < orderByConditionFields.length; i++) {
1613 query.append(_ORDER_BY_ENTITY_ALIAS);
1614 query.append(orderByConditionFields[i]);
1615
1616 if ((i + 1) < orderByConditionFields.length) {
1617 if (orderByComparator.isAscending() ^ previous) {
1618 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1619 }
1620 else {
1621 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1622 }
1623 }
1624 else {
1625 if (orderByComparator.isAscending() ^ previous) {
1626 query.append(WHERE_GREATER_THAN);
1627 }
1628 else {
1629 query.append(WHERE_LESSER_THAN);
1630 }
1631 }
1632 }
1633
1634 query.append(ORDER_BY_CLAUSE);
1635
1636 String[] orderByFields = orderByComparator.getOrderByFields();
1637
1638 for (int i = 0; i < orderByFields.length; i++) {
1639 query.append(_ORDER_BY_ENTITY_ALIAS);
1640 query.append(orderByFields[i]);
1641
1642 if ((i + 1) < orderByFields.length) {
1643 if (orderByComparator.isAscending() ^ previous) {
1644 query.append(ORDER_BY_ASC_HAS_NEXT);
1645 }
1646 else {
1647 query.append(ORDER_BY_DESC_HAS_NEXT);
1648 }
1649 }
1650 else {
1651 if (orderByComparator.isAscending() ^ previous) {
1652 query.append(ORDER_BY_ASC);
1653 }
1654 else {
1655 query.append(ORDER_BY_DESC);
1656 }
1657 }
1658 }
1659 }
1660
1661 else {
1662 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1663 }
1664
1665 String sql = query.toString();
1666
1667 Query q = session.createQuery(sql);
1668
1669 q.setFirstResult(0);
1670 q.setMaxResults(2);
1671
1672 QueryPos qPos = QueryPos.getInstance(q);
1673
1674 qPos.add(plid);
1675
1676 if (orderByComparator != null) {
1677 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1678
1679 for (Object value : values) {
1680 qPos.add(value);
1681 }
1682 }
1683
1684 List<LayoutRevision> list = q.list();
1685
1686 if (list.size() == 2) {
1687 return list.get(1);
1688 }
1689 else {
1690 return null;
1691 }
1692 }
1693
1694
1702 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head)
1703 throws SystemException {
1704 return findByL_H(layoutSetBranchId, head, QueryUtil.ALL_POS,
1705 QueryUtil.ALL_POS, null);
1706 }
1707
1708
1722 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1723 int start, int end) throws SystemException {
1724 return findByL_H(layoutSetBranchId, head, start, end, null);
1725 }
1726
1727
1742 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1743 int start, int end, OrderByComparator orderByComparator)
1744 throws SystemException {
1745 FinderPath finderPath = null;
1746 Object[] finderArgs = null;
1747
1748 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1749 (orderByComparator == null)) {
1750 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H;
1751 finderArgs = new Object[] { layoutSetBranchId, head };
1752 }
1753 else {
1754 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_H;
1755 finderArgs = new Object[] {
1756 layoutSetBranchId, head,
1757
1758 start, end, orderByComparator
1759 };
1760 }
1761
1762 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1763 finderArgs, this);
1764
1765 if ((list != null) && !list.isEmpty()) {
1766 for (LayoutRevision layoutRevision : list) {
1767 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
1768 (head != layoutRevision.getHead())) {
1769 list = null;
1770
1771 break;
1772 }
1773 }
1774 }
1775
1776 if (list == null) {
1777 StringBundler query = null;
1778
1779 if (orderByComparator != null) {
1780 query = new StringBundler(4 +
1781 (orderByComparator.getOrderByFields().length * 3));
1782 }
1783 else {
1784 query = new StringBundler(4);
1785 }
1786
1787 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1788
1789 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
1790
1791 query.append(_FINDER_COLUMN_L_H_HEAD_2);
1792
1793 if (orderByComparator != null) {
1794 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1795 orderByComparator);
1796 }
1797
1798 else {
1799 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1800 }
1801
1802 String sql = query.toString();
1803
1804 Session session = null;
1805
1806 try {
1807 session = openSession();
1808
1809 Query q = session.createQuery(sql);
1810
1811 QueryPos qPos = QueryPos.getInstance(q);
1812
1813 qPos.add(layoutSetBranchId);
1814
1815 qPos.add(head);
1816
1817 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
1818 start, end);
1819 }
1820 catch (Exception e) {
1821 throw processException(e);
1822 }
1823 finally {
1824 if (list == null) {
1825 FinderCacheUtil.removeResult(finderPath, finderArgs);
1826 }
1827 else {
1828 cacheResult(list);
1829
1830 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1831 }
1832
1833 closeSession(session);
1834 }
1835 }
1836
1837 return list;
1838 }
1839
1840
1850 public LayoutRevision findByL_H_First(long layoutSetBranchId, boolean head,
1851 OrderByComparator orderByComparator)
1852 throws NoSuchLayoutRevisionException, SystemException {
1853 LayoutRevision layoutRevision = fetchByL_H_First(layoutSetBranchId,
1854 head, orderByComparator);
1855
1856 if (layoutRevision != null) {
1857 return layoutRevision;
1858 }
1859
1860 StringBundler msg = new StringBundler(6);
1861
1862 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1863
1864 msg.append("layoutSetBranchId=");
1865 msg.append(layoutSetBranchId);
1866
1867 msg.append(", head=");
1868 msg.append(head);
1869
1870 msg.append(StringPool.CLOSE_CURLY_BRACE);
1871
1872 throw new NoSuchLayoutRevisionException(msg.toString());
1873 }
1874
1875
1884 public LayoutRevision fetchByL_H_First(long layoutSetBranchId,
1885 boolean head, OrderByComparator orderByComparator)
1886 throws SystemException {
1887 List<LayoutRevision> list = findByL_H(layoutSetBranchId, head, 0, 1,
1888 orderByComparator);
1889
1890 if (!list.isEmpty()) {
1891 return list.get(0);
1892 }
1893
1894 return null;
1895 }
1896
1897
1907 public LayoutRevision findByL_H_Last(long layoutSetBranchId, boolean head,
1908 OrderByComparator orderByComparator)
1909 throws NoSuchLayoutRevisionException, SystemException {
1910 LayoutRevision layoutRevision = fetchByL_H_Last(layoutSetBranchId,
1911 head, orderByComparator);
1912
1913 if (layoutRevision != null) {
1914 return layoutRevision;
1915 }
1916
1917 StringBundler msg = new StringBundler(6);
1918
1919 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1920
1921 msg.append("layoutSetBranchId=");
1922 msg.append(layoutSetBranchId);
1923
1924 msg.append(", head=");
1925 msg.append(head);
1926
1927 msg.append(StringPool.CLOSE_CURLY_BRACE);
1928
1929 throw new NoSuchLayoutRevisionException(msg.toString());
1930 }
1931
1932
1941 public LayoutRevision fetchByL_H_Last(long layoutSetBranchId, boolean head,
1942 OrderByComparator orderByComparator) throws SystemException {
1943 int count = countByL_H(layoutSetBranchId, head);
1944
1945 List<LayoutRevision> list = findByL_H(layoutSetBranchId, head,
1946 count - 1, count, orderByComparator);
1947
1948 if (!list.isEmpty()) {
1949 return list.get(0);
1950 }
1951
1952 return null;
1953 }
1954
1955
1966 public LayoutRevision[] findByL_H_PrevAndNext(long layoutRevisionId,
1967 long layoutSetBranchId, boolean head,
1968 OrderByComparator orderByComparator)
1969 throws NoSuchLayoutRevisionException, SystemException {
1970 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1971
1972 Session session = null;
1973
1974 try {
1975 session = openSession();
1976
1977 LayoutRevision[] array = new LayoutRevisionImpl[3];
1978
1979 array[0] = getByL_H_PrevAndNext(session, layoutRevision,
1980 layoutSetBranchId, head, orderByComparator, true);
1981
1982 array[1] = layoutRevision;
1983
1984 array[2] = getByL_H_PrevAndNext(session, layoutRevision,
1985 layoutSetBranchId, head, orderByComparator, false);
1986
1987 return array;
1988 }
1989 catch (Exception e) {
1990 throw processException(e);
1991 }
1992 finally {
1993 closeSession(session);
1994 }
1995 }
1996
1997 protected LayoutRevision getByL_H_PrevAndNext(Session session,
1998 LayoutRevision layoutRevision, long layoutSetBranchId, boolean head,
1999 OrderByComparator orderByComparator, boolean previous) {
2000 StringBundler query = null;
2001
2002 if (orderByComparator != null) {
2003 query = new StringBundler(6 +
2004 (orderByComparator.getOrderByFields().length * 6));
2005 }
2006 else {
2007 query = new StringBundler(3);
2008 }
2009
2010 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2011
2012 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
2013
2014 query.append(_FINDER_COLUMN_L_H_HEAD_2);
2015
2016 if (orderByComparator != null) {
2017 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2018
2019 if (orderByConditionFields.length > 0) {
2020 query.append(WHERE_AND);
2021 }
2022
2023 for (int i = 0; i < orderByConditionFields.length; i++) {
2024 query.append(_ORDER_BY_ENTITY_ALIAS);
2025 query.append(orderByConditionFields[i]);
2026
2027 if ((i + 1) < orderByConditionFields.length) {
2028 if (orderByComparator.isAscending() ^ previous) {
2029 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2030 }
2031 else {
2032 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2033 }
2034 }
2035 else {
2036 if (orderByComparator.isAscending() ^ previous) {
2037 query.append(WHERE_GREATER_THAN);
2038 }
2039 else {
2040 query.append(WHERE_LESSER_THAN);
2041 }
2042 }
2043 }
2044
2045 query.append(ORDER_BY_CLAUSE);
2046
2047 String[] orderByFields = orderByComparator.getOrderByFields();
2048
2049 for (int i = 0; i < orderByFields.length; i++) {
2050 query.append(_ORDER_BY_ENTITY_ALIAS);
2051 query.append(orderByFields[i]);
2052
2053 if ((i + 1) < orderByFields.length) {
2054 if (orderByComparator.isAscending() ^ previous) {
2055 query.append(ORDER_BY_ASC_HAS_NEXT);
2056 }
2057 else {
2058 query.append(ORDER_BY_DESC_HAS_NEXT);
2059 }
2060 }
2061 else {
2062 if (orderByComparator.isAscending() ^ previous) {
2063 query.append(ORDER_BY_ASC);
2064 }
2065 else {
2066 query.append(ORDER_BY_DESC);
2067 }
2068 }
2069 }
2070 }
2071
2072 else {
2073 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2074 }
2075
2076 String sql = query.toString();
2077
2078 Query q = session.createQuery(sql);
2079
2080 q.setFirstResult(0);
2081 q.setMaxResults(2);
2082
2083 QueryPos qPos = QueryPos.getInstance(q);
2084
2085 qPos.add(layoutSetBranchId);
2086
2087 qPos.add(head);
2088
2089 if (orderByComparator != null) {
2090 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2091
2092 for (Object value : values) {
2093 qPos.add(value);
2094 }
2095 }
2096
2097 List<LayoutRevision> list = q.list();
2098
2099 if (list.size() == 2) {
2100 return list.get(1);
2101 }
2102 else {
2103 return null;
2104 }
2105 }
2106
2107
2115 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid)
2116 throws SystemException {
2117 return findByL_P(layoutSetBranchId, plid, QueryUtil.ALL_POS,
2118 QueryUtil.ALL_POS, null);
2119 }
2120
2121
2135 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
2136 int start, int end) throws SystemException {
2137 return findByL_P(layoutSetBranchId, plid, start, end, null);
2138 }
2139
2140
2155 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
2156 int start, int end, OrderByComparator orderByComparator)
2157 throws SystemException {
2158 FinderPath finderPath = null;
2159 Object[] finderArgs = null;
2160
2161 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2162 (orderByComparator == null)) {
2163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
2164 finderArgs = new Object[] { layoutSetBranchId, plid };
2165 }
2166 else {
2167 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
2168 finderArgs = new Object[] {
2169 layoutSetBranchId, plid,
2170
2171 start, end, orderByComparator
2172 };
2173 }
2174
2175 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2176 finderArgs, this);
2177
2178 if ((list != null) && !list.isEmpty()) {
2179 for (LayoutRevision layoutRevision : list) {
2180 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
2181 (plid != layoutRevision.getPlid())) {
2182 list = null;
2183
2184 break;
2185 }
2186 }
2187 }
2188
2189 if (list == null) {
2190 StringBundler query = null;
2191
2192 if (orderByComparator != null) {
2193 query = new StringBundler(4 +
2194 (orderByComparator.getOrderByFields().length * 3));
2195 }
2196 else {
2197 query = new StringBundler(4);
2198 }
2199
2200 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2201
2202 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
2203
2204 query.append(_FINDER_COLUMN_L_P_PLID_2);
2205
2206 if (orderByComparator != null) {
2207 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2208 orderByComparator);
2209 }
2210
2211 else {
2212 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2213 }
2214
2215 String sql = query.toString();
2216
2217 Session session = null;
2218
2219 try {
2220 session = openSession();
2221
2222 Query q = session.createQuery(sql);
2223
2224 QueryPos qPos = QueryPos.getInstance(q);
2225
2226 qPos.add(layoutSetBranchId);
2227
2228 qPos.add(plid);
2229
2230 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
2231 start, end);
2232 }
2233 catch (Exception e) {
2234 throw processException(e);
2235 }
2236 finally {
2237 if (list == null) {
2238 FinderCacheUtil.removeResult(finderPath, finderArgs);
2239 }
2240 else {
2241 cacheResult(list);
2242
2243 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2244 }
2245
2246 closeSession(session);
2247 }
2248 }
2249
2250 return list;
2251 }
2252
2253
2263 public LayoutRevision findByL_P_First(long layoutSetBranchId, long plid,
2264 OrderByComparator orderByComparator)
2265 throws NoSuchLayoutRevisionException, SystemException {
2266 LayoutRevision layoutRevision = fetchByL_P_First(layoutSetBranchId,
2267 plid, orderByComparator);
2268
2269 if (layoutRevision != null) {
2270 return layoutRevision;
2271 }
2272
2273 StringBundler msg = new StringBundler(6);
2274
2275 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2276
2277 msg.append("layoutSetBranchId=");
2278 msg.append(layoutSetBranchId);
2279
2280 msg.append(", plid=");
2281 msg.append(plid);
2282
2283 msg.append(StringPool.CLOSE_CURLY_BRACE);
2284
2285 throw new NoSuchLayoutRevisionException(msg.toString());
2286 }
2287
2288
2297 public LayoutRevision fetchByL_P_First(long layoutSetBranchId, long plid,
2298 OrderByComparator orderByComparator) throws SystemException {
2299 List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid, 0, 1,
2300 orderByComparator);
2301
2302 if (!list.isEmpty()) {
2303 return list.get(0);
2304 }
2305
2306 return null;
2307 }
2308
2309
2319 public LayoutRevision findByL_P_Last(long layoutSetBranchId, long plid,
2320 OrderByComparator orderByComparator)
2321 throws NoSuchLayoutRevisionException, SystemException {
2322 LayoutRevision layoutRevision = fetchByL_P_Last(layoutSetBranchId,
2323 plid, orderByComparator);
2324
2325 if (layoutRevision != null) {
2326 return layoutRevision;
2327 }
2328
2329 StringBundler msg = new StringBundler(6);
2330
2331 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2332
2333 msg.append("layoutSetBranchId=");
2334 msg.append(layoutSetBranchId);
2335
2336 msg.append(", plid=");
2337 msg.append(plid);
2338
2339 msg.append(StringPool.CLOSE_CURLY_BRACE);
2340
2341 throw new NoSuchLayoutRevisionException(msg.toString());
2342 }
2343
2344
2353 public LayoutRevision fetchByL_P_Last(long layoutSetBranchId, long plid,
2354 OrderByComparator orderByComparator) throws SystemException {
2355 int count = countByL_P(layoutSetBranchId, plid);
2356
2357 List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid,
2358 count - 1, count, orderByComparator);
2359
2360 if (!list.isEmpty()) {
2361 return list.get(0);
2362 }
2363
2364 return null;
2365 }
2366
2367
2378 public LayoutRevision[] findByL_P_PrevAndNext(long layoutRevisionId,
2379 long layoutSetBranchId, long plid, OrderByComparator orderByComparator)
2380 throws NoSuchLayoutRevisionException, SystemException {
2381 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2382
2383 Session session = null;
2384
2385 try {
2386 session = openSession();
2387
2388 LayoutRevision[] array = new LayoutRevisionImpl[3];
2389
2390 array[0] = getByL_P_PrevAndNext(session, layoutRevision,
2391 layoutSetBranchId, plid, orderByComparator, true);
2392
2393 array[1] = layoutRevision;
2394
2395 array[2] = getByL_P_PrevAndNext(session, layoutRevision,
2396 layoutSetBranchId, plid, orderByComparator, false);
2397
2398 return array;
2399 }
2400 catch (Exception e) {
2401 throw processException(e);
2402 }
2403 finally {
2404 closeSession(session);
2405 }
2406 }
2407
2408 protected LayoutRevision getByL_P_PrevAndNext(Session session,
2409 LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
2410 OrderByComparator orderByComparator, boolean previous) {
2411 StringBundler query = null;
2412
2413 if (orderByComparator != null) {
2414 query = new StringBundler(6 +
2415 (orderByComparator.getOrderByFields().length * 6));
2416 }
2417 else {
2418 query = new StringBundler(3);
2419 }
2420
2421 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2422
2423 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
2424
2425 query.append(_FINDER_COLUMN_L_P_PLID_2);
2426
2427 if (orderByComparator != null) {
2428 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2429
2430 if (orderByConditionFields.length > 0) {
2431 query.append(WHERE_AND);
2432 }
2433
2434 for (int i = 0; i < orderByConditionFields.length; i++) {
2435 query.append(_ORDER_BY_ENTITY_ALIAS);
2436 query.append(orderByConditionFields[i]);
2437
2438 if ((i + 1) < orderByConditionFields.length) {
2439 if (orderByComparator.isAscending() ^ previous) {
2440 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2441 }
2442 else {
2443 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2444 }
2445 }
2446 else {
2447 if (orderByComparator.isAscending() ^ previous) {
2448 query.append(WHERE_GREATER_THAN);
2449 }
2450 else {
2451 query.append(WHERE_LESSER_THAN);
2452 }
2453 }
2454 }
2455
2456 query.append(ORDER_BY_CLAUSE);
2457
2458 String[] orderByFields = orderByComparator.getOrderByFields();
2459
2460 for (int i = 0; i < orderByFields.length; i++) {
2461 query.append(_ORDER_BY_ENTITY_ALIAS);
2462 query.append(orderByFields[i]);
2463
2464 if ((i + 1) < orderByFields.length) {
2465 if (orderByComparator.isAscending() ^ previous) {
2466 query.append(ORDER_BY_ASC_HAS_NEXT);
2467 }
2468 else {
2469 query.append(ORDER_BY_DESC_HAS_NEXT);
2470 }
2471 }
2472 else {
2473 if (orderByComparator.isAscending() ^ previous) {
2474 query.append(ORDER_BY_ASC);
2475 }
2476 else {
2477 query.append(ORDER_BY_DESC);
2478 }
2479 }
2480 }
2481 }
2482
2483 else {
2484 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2485 }
2486
2487 String sql = query.toString();
2488
2489 Query q = session.createQuery(sql);
2490
2491 q.setFirstResult(0);
2492 q.setMaxResults(2);
2493
2494 QueryPos qPos = QueryPos.getInstance(q);
2495
2496 qPos.add(layoutSetBranchId);
2497
2498 qPos.add(plid);
2499
2500 if (orderByComparator != null) {
2501 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2502
2503 for (Object value : values) {
2504 qPos.add(value);
2505 }
2506 }
2507
2508 List<LayoutRevision> list = q.list();
2509
2510 if (list.size() == 2) {
2511 return list.get(1);
2512 }
2513 else {
2514 return null;
2515 }
2516 }
2517
2518
2526 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status)
2527 throws SystemException {
2528 return findByL_S(layoutSetBranchId, status, QueryUtil.ALL_POS,
2529 QueryUtil.ALL_POS, null);
2530 }
2531
2532
2546 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2547 int start, int end) throws SystemException {
2548 return findByL_S(layoutSetBranchId, status, start, end, null);
2549 }
2550
2551
2566 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2567 int start, int end, OrderByComparator orderByComparator)
2568 throws SystemException {
2569 FinderPath finderPath = null;
2570 Object[] finderArgs = null;
2571
2572 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2573 (orderByComparator == null)) {
2574 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S;
2575 finderArgs = new Object[] { layoutSetBranchId, status };
2576 }
2577 else {
2578 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_S;
2579 finderArgs = new Object[] {
2580 layoutSetBranchId, status,
2581
2582 start, end, orderByComparator
2583 };
2584 }
2585
2586 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2587 finderArgs, this);
2588
2589 if ((list != null) && !list.isEmpty()) {
2590 for (LayoutRevision layoutRevision : list) {
2591 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
2592 (status != layoutRevision.getStatus())) {
2593 list = null;
2594
2595 break;
2596 }
2597 }
2598 }
2599
2600 if (list == null) {
2601 StringBundler query = null;
2602
2603 if (orderByComparator != null) {
2604 query = new StringBundler(4 +
2605 (orderByComparator.getOrderByFields().length * 3));
2606 }
2607 else {
2608 query = new StringBundler(4);
2609 }
2610
2611 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2612
2613 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2614
2615 query.append(_FINDER_COLUMN_L_S_STATUS_2);
2616
2617 if (orderByComparator != null) {
2618 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2619 orderByComparator);
2620 }
2621
2622 else {
2623 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2624 }
2625
2626 String sql = query.toString();
2627
2628 Session session = null;
2629
2630 try {
2631 session = openSession();
2632
2633 Query q = session.createQuery(sql);
2634
2635 QueryPos qPos = QueryPos.getInstance(q);
2636
2637 qPos.add(layoutSetBranchId);
2638
2639 qPos.add(status);
2640
2641 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
2642 start, end);
2643 }
2644 catch (Exception e) {
2645 throw processException(e);
2646 }
2647 finally {
2648 if (list == null) {
2649 FinderCacheUtil.removeResult(finderPath, finderArgs);
2650 }
2651 else {
2652 cacheResult(list);
2653
2654 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2655 }
2656
2657 closeSession(session);
2658 }
2659 }
2660
2661 return list;
2662 }
2663
2664
2674 public LayoutRevision findByL_S_First(long layoutSetBranchId, int status,
2675 OrderByComparator orderByComparator)
2676 throws NoSuchLayoutRevisionException, SystemException {
2677 LayoutRevision layoutRevision = fetchByL_S_First(layoutSetBranchId,
2678 status, orderByComparator);
2679
2680 if (layoutRevision != null) {
2681 return layoutRevision;
2682 }
2683
2684 StringBundler msg = new StringBundler(6);
2685
2686 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2687
2688 msg.append("layoutSetBranchId=");
2689 msg.append(layoutSetBranchId);
2690
2691 msg.append(", status=");
2692 msg.append(status);
2693
2694 msg.append(StringPool.CLOSE_CURLY_BRACE);
2695
2696 throw new NoSuchLayoutRevisionException(msg.toString());
2697 }
2698
2699
2708 public LayoutRevision fetchByL_S_First(long layoutSetBranchId, int status,
2709 OrderByComparator orderByComparator) throws SystemException {
2710 List<LayoutRevision> list = findByL_S(layoutSetBranchId, status, 0, 1,
2711 orderByComparator);
2712
2713 if (!list.isEmpty()) {
2714 return list.get(0);
2715 }
2716
2717 return null;
2718 }
2719
2720
2730 public LayoutRevision findByL_S_Last(long layoutSetBranchId, int status,
2731 OrderByComparator orderByComparator)
2732 throws NoSuchLayoutRevisionException, SystemException {
2733 LayoutRevision layoutRevision = fetchByL_S_Last(layoutSetBranchId,
2734 status, orderByComparator);
2735
2736 if (layoutRevision != null) {
2737 return layoutRevision;
2738 }
2739
2740 StringBundler msg = new StringBundler(6);
2741
2742 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2743
2744 msg.append("layoutSetBranchId=");
2745 msg.append(layoutSetBranchId);
2746
2747 msg.append(", status=");
2748 msg.append(status);
2749
2750 msg.append(StringPool.CLOSE_CURLY_BRACE);
2751
2752 throw new NoSuchLayoutRevisionException(msg.toString());
2753 }
2754
2755
2764 public LayoutRevision fetchByL_S_Last(long layoutSetBranchId, int status,
2765 OrderByComparator orderByComparator) throws SystemException {
2766 int count = countByL_S(layoutSetBranchId, status);
2767
2768 List<LayoutRevision> list = findByL_S(layoutSetBranchId, status,
2769 count - 1, count, orderByComparator);
2770
2771 if (!list.isEmpty()) {
2772 return list.get(0);
2773 }
2774
2775 return null;
2776 }
2777
2778
2789 public LayoutRevision[] findByL_S_PrevAndNext(long layoutRevisionId,
2790 long layoutSetBranchId, int status, OrderByComparator orderByComparator)
2791 throws NoSuchLayoutRevisionException, SystemException {
2792 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2793
2794 Session session = null;
2795
2796 try {
2797 session = openSession();
2798
2799 LayoutRevision[] array = new LayoutRevisionImpl[3];
2800
2801 array[0] = getByL_S_PrevAndNext(session, layoutRevision,
2802 layoutSetBranchId, status, orderByComparator, true);
2803
2804 array[1] = layoutRevision;
2805
2806 array[2] = getByL_S_PrevAndNext(session, layoutRevision,
2807 layoutSetBranchId, status, orderByComparator, false);
2808
2809 return array;
2810 }
2811 catch (Exception e) {
2812 throw processException(e);
2813 }
2814 finally {
2815 closeSession(session);
2816 }
2817 }
2818
2819 protected LayoutRevision getByL_S_PrevAndNext(Session session,
2820 LayoutRevision layoutRevision, long layoutSetBranchId, int status,
2821 OrderByComparator orderByComparator, boolean previous) {
2822 StringBundler query = null;
2823
2824 if (orderByComparator != null) {
2825 query = new StringBundler(6 +
2826 (orderByComparator.getOrderByFields().length * 6));
2827 }
2828 else {
2829 query = new StringBundler(3);
2830 }
2831
2832 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2833
2834 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2835
2836 query.append(_FINDER_COLUMN_L_S_STATUS_2);
2837
2838 if (orderByComparator != null) {
2839 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2840
2841 if (orderByConditionFields.length > 0) {
2842 query.append(WHERE_AND);
2843 }
2844
2845 for (int i = 0; i < orderByConditionFields.length; i++) {
2846 query.append(_ORDER_BY_ENTITY_ALIAS);
2847 query.append(orderByConditionFields[i]);
2848
2849 if ((i + 1) < orderByConditionFields.length) {
2850 if (orderByComparator.isAscending() ^ previous) {
2851 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2852 }
2853 else {
2854 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2855 }
2856 }
2857 else {
2858 if (orderByComparator.isAscending() ^ previous) {
2859 query.append(WHERE_GREATER_THAN);
2860 }
2861 else {
2862 query.append(WHERE_LESSER_THAN);
2863 }
2864 }
2865 }
2866
2867 query.append(ORDER_BY_CLAUSE);
2868
2869 String[] orderByFields = orderByComparator.getOrderByFields();
2870
2871 for (int i = 0; i < orderByFields.length; i++) {
2872 query.append(_ORDER_BY_ENTITY_ALIAS);
2873 query.append(orderByFields[i]);
2874
2875 if ((i + 1) < orderByFields.length) {
2876 if (orderByComparator.isAscending() ^ previous) {
2877 query.append(ORDER_BY_ASC_HAS_NEXT);
2878 }
2879 else {
2880 query.append(ORDER_BY_DESC_HAS_NEXT);
2881 }
2882 }
2883 else {
2884 if (orderByComparator.isAscending() ^ previous) {
2885 query.append(ORDER_BY_ASC);
2886 }
2887 else {
2888 query.append(ORDER_BY_DESC);
2889 }
2890 }
2891 }
2892 }
2893
2894 else {
2895 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2896 }
2897
2898 String sql = query.toString();
2899
2900 Query q = session.createQuery(sql);
2901
2902 q.setFirstResult(0);
2903 q.setMaxResults(2);
2904
2905 QueryPos qPos = QueryPos.getInstance(q);
2906
2907 qPos.add(layoutSetBranchId);
2908
2909 qPos.add(status);
2910
2911 if (orderByComparator != null) {
2912 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2913
2914 for (Object value : values) {
2915 qPos.add(value);
2916 }
2917 }
2918
2919 List<LayoutRevision> list = q.list();
2920
2921 if (list.size() == 2) {
2922 return list.get(1);
2923 }
2924 else {
2925 return null;
2926 }
2927 }
2928
2929
2937 public List<LayoutRevision> findByH_P(boolean head, long plid)
2938 throws SystemException {
2939 return findByH_P(head, plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2940 }
2941
2942
2956 public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2957 int end) throws SystemException {
2958 return findByH_P(head, plid, start, end, null);
2959 }
2960
2961
2976 public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2977 int end, OrderByComparator orderByComparator) throws SystemException {
2978 FinderPath finderPath = null;
2979 Object[] finderArgs = null;
2980
2981 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2982 (orderByComparator == null)) {
2983 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P;
2984 finderArgs = new Object[] { head, plid };
2985 }
2986 else {
2987 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_H_P;
2988 finderArgs = new Object[] { head, plid, start, end, orderByComparator };
2989 }
2990
2991 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2992 finderArgs, this);
2993
2994 if ((list != null) && !list.isEmpty()) {
2995 for (LayoutRevision layoutRevision : list) {
2996 if ((head != layoutRevision.getHead()) ||
2997 (plid != layoutRevision.getPlid())) {
2998 list = null;
2999
3000 break;
3001 }
3002 }
3003 }
3004
3005 if (list == null) {
3006 StringBundler query = null;
3007
3008 if (orderByComparator != null) {
3009 query = new StringBundler(4 +
3010 (orderByComparator.getOrderByFields().length * 3));
3011 }
3012 else {
3013 query = new StringBundler(4);
3014 }
3015
3016 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3017
3018 query.append(_FINDER_COLUMN_H_P_HEAD_2);
3019
3020 query.append(_FINDER_COLUMN_H_P_PLID_2);
3021
3022 if (orderByComparator != null) {
3023 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3024 orderByComparator);
3025 }
3026
3027 else {
3028 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3029 }
3030
3031 String sql = query.toString();
3032
3033 Session session = null;
3034
3035 try {
3036 session = openSession();
3037
3038 Query q = session.createQuery(sql);
3039
3040 QueryPos qPos = QueryPos.getInstance(q);
3041
3042 qPos.add(head);
3043
3044 qPos.add(plid);
3045
3046 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3047 start, end);
3048 }
3049 catch (Exception e) {
3050 throw processException(e);
3051 }
3052 finally {
3053 if (list == null) {
3054 FinderCacheUtil.removeResult(finderPath, finderArgs);
3055 }
3056 else {
3057 cacheResult(list);
3058
3059 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3060 }
3061
3062 closeSession(session);
3063 }
3064 }
3065
3066 return list;
3067 }
3068
3069
3079 public LayoutRevision findByH_P_First(boolean head, long plid,
3080 OrderByComparator orderByComparator)
3081 throws NoSuchLayoutRevisionException, SystemException {
3082 LayoutRevision layoutRevision = fetchByH_P_First(head, plid,
3083 orderByComparator);
3084
3085 if (layoutRevision != null) {
3086 return layoutRevision;
3087 }
3088
3089 StringBundler msg = new StringBundler(6);
3090
3091 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3092
3093 msg.append("head=");
3094 msg.append(head);
3095
3096 msg.append(", plid=");
3097 msg.append(plid);
3098
3099 msg.append(StringPool.CLOSE_CURLY_BRACE);
3100
3101 throw new NoSuchLayoutRevisionException(msg.toString());
3102 }
3103
3104
3113 public LayoutRevision fetchByH_P_First(boolean head, long plid,
3114 OrderByComparator orderByComparator) throws SystemException {
3115 List<LayoutRevision> list = findByH_P(head, plid, 0, 1,
3116 orderByComparator);
3117
3118 if (!list.isEmpty()) {
3119 return list.get(0);
3120 }
3121
3122 return null;
3123 }
3124
3125
3135 public LayoutRevision findByH_P_Last(boolean head, long plid,
3136 OrderByComparator orderByComparator)
3137 throws NoSuchLayoutRevisionException, SystemException {
3138 LayoutRevision layoutRevision = fetchByH_P_Last(head, plid,
3139 orderByComparator);
3140
3141 if (layoutRevision != null) {
3142 return layoutRevision;
3143 }
3144
3145 StringBundler msg = new StringBundler(6);
3146
3147 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3148
3149 msg.append("head=");
3150 msg.append(head);
3151
3152 msg.append(", plid=");
3153 msg.append(plid);
3154
3155 msg.append(StringPool.CLOSE_CURLY_BRACE);
3156
3157 throw new NoSuchLayoutRevisionException(msg.toString());
3158 }
3159
3160
3169 public LayoutRevision fetchByH_P_Last(boolean head, long plid,
3170 OrderByComparator orderByComparator) throws SystemException {
3171 int count = countByH_P(head, plid);
3172
3173 List<LayoutRevision> list = findByH_P(head, plid, count - 1, count,
3174 orderByComparator);
3175
3176 if (!list.isEmpty()) {
3177 return list.get(0);
3178 }
3179
3180 return null;
3181 }
3182
3183
3194 public LayoutRevision[] findByH_P_PrevAndNext(long layoutRevisionId,
3195 boolean head, long plid, OrderByComparator orderByComparator)
3196 throws NoSuchLayoutRevisionException, SystemException {
3197 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3198
3199 Session session = null;
3200
3201 try {
3202 session = openSession();
3203
3204 LayoutRevision[] array = new LayoutRevisionImpl[3];
3205
3206 array[0] = getByH_P_PrevAndNext(session, layoutRevision, head,
3207 plid, orderByComparator, true);
3208
3209 array[1] = layoutRevision;
3210
3211 array[2] = getByH_P_PrevAndNext(session, layoutRevision, head,
3212 plid, orderByComparator, false);
3213
3214 return array;
3215 }
3216 catch (Exception e) {
3217 throw processException(e);
3218 }
3219 finally {
3220 closeSession(session);
3221 }
3222 }
3223
3224 protected LayoutRevision getByH_P_PrevAndNext(Session session,
3225 LayoutRevision layoutRevision, boolean head, long plid,
3226 OrderByComparator orderByComparator, boolean previous) {
3227 StringBundler query = null;
3228
3229 if (orderByComparator != null) {
3230 query = new StringBundler(6 +
3231 (orderByComparator.getOrderByFields().length * 6));
3232 }
3233 else {
3234 query = new StringBundler(3);
3235 }
3236
3237 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3238
3239 query.append(_FINDER_COLUMN_H_P_HEAD_2);
3240
3241 query.append(_FINDER_COLUMN_H_P_PLID_2);
3242
3243 if (orderByComparator != null) {
3244 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3245
3246 if (orderByConditionFields.length > 0) {
3247 query.append(WHERE_AND);
3248 }
3249
3250 for (int i = 0; i < orderByConditionFields.length; i++) {
3251 query.append(_ORDER_BY_ENTITY_ALIAS);
3252 query.append(orderByConditionFields[i]);
3253
3254 if ((i + 1) < orderByConditionFields.length) {
3255 if (orderByComparator.isAscending() ^ previous) {
3256 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3257 }
3258 else {
3259 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3260 }
3261 }
3262 else {
3263 if (orderByComparator.isAscending() ^ previous) {
3264 query.append(WHERE_GREATER_THAN);
3265 }
3266 else {
3267 query.append(WHERE_LESSER_THAN);
3268 }
3269 }
3270 }
3271
3272 query.append(ORDER_BY_CLAUSE);
3273
3274 String[] orderByFields = orderByComparator.getOrderByFields();
3275
3276 for (int i = 0; i < orderByFields.length; i++) {
3277 query.append(_ORDER_BY_ENTITY_ALIAS);
3278 query.append(orderByFields[i]);
3279
3280 if ((i + 1) < orderByFields.length) {
3281 if (orderByComparator.isAscending() ^ previous) {
3282 query.append(ORDER_BY_ASC_HAS_NEXT);
3283 }
3284 else {
3285 query.append(ORDER_BY_DESC_HAS_NEXT);
3286 }
3287 }
3288 else {
3289 if (orderByComparator.isAscending() ^ previous) {
3290 query.append(ORDER_BY_ASC);
3291 }
3292 else {
3293 query.append(ORDER_BY_DESC);
3294 }
3295 }
3296 }
3297 }
3298
3299 else {
3300 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3301 }
3302
3303 String sql = query.toString();
3304
3305 Query q = session.createQuery(sql);
3306
3307 q.setFirstResult(0);
3308 q.setMaxResults(2);
3309
3310 QueryPos qPos = QueryPos.getInstance(q);
3311
3312 qPos.add(head);
3313
3314 qPos.add(plid);
3315
3316 if (orderByComparator != null) {
3317 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3318
3319 for (Object value : values) {
3320 qPos.add(value);
3321 }
3322 }
3323
3324 List<LayoutRevision> list = q.list();
3325
3326 if (list.size() == 2) {
3327 return list.get(1);
3328 }
3329 else {
3330 return null;
3331 }
3332 }
3333
3334
3342 public List<LayoutRevision> findByP_NotS(long plid, int status)
3343 throws SystemException {
3344 return findByP_NotS(plid, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3345 null);
3346 }
3347
3348
3362 public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3363 int end) throws SystemException {
3364 return findByP_NotS(plid, status, start, end, null);
3365 }
3366
3367
3382 public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3383 int end, OrderByComparator orderByComparator) throws SystemException {
3384 FinderPath finderPath = null;
3385 Object[] finderArgs = null;
3386
3387 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_NOTS;
3388 finderArgs = new Object[] { plid, status, start, end, orderByComparator };
3389
3390 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3391 finderArgs, this);
3392
3393 if ((list != null) && !list.isEmpty()) {
3394 for (LayoutRevision layoutRevision : list) {
3395 if ((plid != layoutRevision.getPlid()) ||
3396 (status != layoutRevision.getStatus())) {
3397 list = null;
3398
3399 break;
3400 }
3401 }
3402 }
3403
3404 if (list == null) {
3405 StringBundler query = null;
3406
3407 if (orderByComparator != null) {
3408 query = new StringBundler(4 +
3409 (orderByComparator.getOrderByFields().length * 3));
3410 }
3411 else {
3412 query = new StringBundler(4);
3413 }
3414
3415 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3416
3417 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3418
3419 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3420
3421 if (orderByComparator != null) {
3422 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3423 orderByComparator);
3424 }
3425
3426 else {
3427 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3428 }
3429
3430 String sql = query.toString();
3431
3432 Session session = null;
3433
3434 try {
3435 session = openSession();
3436
3437 Query q = session.createQuery(sql);
3438
3439 QueryPos qPos = QueryPos.getInstance(q);
3440
3441 qPos.add(plid);
3442
3443 qPos.add(status);
3444
3445 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3446 start, end);
3447 }
3448 catch (Exception e) {
3449 throw processException(e);
3450 }
3451 finally {
3452 if (list == null) {
3453 FinderCacheUtil.removeResult(finderPath, finderArgs);
3454 }
3455 else {
3456 cacheResult(list);
3457
3458 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3459 }
3460
3461 closeSession(session);
3462 }
3463 }
3464
3465 return list;
3466 }
3467
3468
3478 public LayoutRevision findByP_NotS_First(long plid, int status,
3479 OrderByComparator orderByComparator)
3480 throws NoSuchLayoutRevisionException, SystemException {
3481 LayoutRevision layoutRevision = fetchByP_NotS_First(plid, status,
3482 orderByComparator);
3483
3484 if (layoutRevision != null) {
3485 return layoutRevision;
3486 }
3487
3488 StringBundler msg = new StringBundler(6);
3489
3490 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3491
3492 msg.append("plid=");
3493 msg.append(plid);
3494
3495 msg.append(", status=");
3496 msg.append(status);
3497
3498 msg.append(StringPool.CLOSE_CURLY_BRACE);
3499
3500 throw new NoSuchLayoutRevisionException(msg.toString());
3501 }
3502
3503
3512 public LayoutRevision fetchByP_NotS_First(long plid, int status,
3513 OrderByComparator orderByComparator) throws SystemException {
3514 List<LayoutRevision> list = findByP_NotS(plid, status, 0, 1,
3515 orderByComparator);
3516
3517 if (!list.isEmpty()) {
3518 return list.get(0);
3519 }
3520
3521 return null;
3522 }
3523
3524
3534 public LayoutRevision findByP_NotS_Last(long plid, int status,
3535 OrderByComparator orderByComparator)
3536 throws NoSuchLayoutRevisionException, SystemException {
3537 LayoutRevision layoutRevision = fetchByP_NotS_Last(plid, status,
3538 orderByComparator);
3539
3540 if (layoutRevision != null) {
3541 return layoutRevision;
3542 }
3543
3544 StringBundler msg = new StringBundler(6);
3545
3546 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3547
3548 msg.append("plid=");
3549 msg.append(plid);
3550
3551 msg.append(", status=");
3552 msg.append(status);
3553
3554 msg.append(StringPool.CLOSE_CURLY_BRACE);
3555
3556 throw new NoSuchLayoutRevisionException(msg.toString());
3557 }
3558
3559
3568 public LayoutRevision fetchByP_NotS_Last(long plid, int status,
3569 OrderByComparator orderByComparator) throws SystemException {
3570 int count = countByP_NotS(plid, status);
3571
3572 List<LayoutRevision> list = findByP_NotS(plid, status, count - 1,
3573 count, orderByComparator);
3574
3575 if (!list.isEmpty()) {
3576 return list.get(0);
3577 }
3578
3579 return null;
3580 }
3581
3582
3593 public LayoutRevision[] findByP_NotS_PrevAndNext(long layoutRevisionId,
3594 long plid, int status, OrderByComparator orderByComparator)
3595 throws NoSuchLayoutRevisionException, SystemException {
3596 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3597
3598 Session session = null;
3599
3600 try {
3601 session = openSession();
3602
3603 LayoutRevision[] array = new LayoutRevisionImpl[3];
3604
3605 array[0] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3606 status, orderByComparator, true);
3607
3608 array[1] = layoutRevision;
3609
3610 array[2] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3611 status, orderByComparator, false);
3612
3613 return array;
3614 }
3615 catch (Exception e) {
3616 throw processException(e);
3617 }
3618 finally {
3619 closeSession(session);
3620 }
3621 }
3622
3623 protected LayoutRevision getByP_NotS_PrevAndNext(Session session,
3624 LayoutRevision layoutRevision, long plid, int status,
3625 OrderByComparator orderByComparator, boolean previous) {
3626 StringBundler query = null;
3627
3628 if (orderByComparator != null) {
3629 query = new StringBundler(6 +
3630 (orderByComparator.getOrderByFields().length * 6));
3631 }
3632 else {
3633 query = new StringBundler(3);
3634 }
3635
3636 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3637
3638 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3639
3640 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3641
3642 if (orderByComparator != null) {
3643 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3644
3645 if (orderByConditionFields.length > 0) {
3646 query.append(WHERE_AND);
3647 }
3648
3649 for (int i = 0; i < orderByConditionFields.length; i++) {
3650 query.append(_ORDER_BY_ENTITY_ALIAS);
3651 query.append(orderByConditionFields[i]);
3652
3653 if ((i + 1) < orderByConditionFields.length) {
3654 if (orderByComparator.isAscending() ^ previous) {
3655 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3656 }
3657 else {
3658 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3659 }
3660 }
3661 else {
3662 if (orderByComparator.isAscending() ^ previous) {
3663 query.append(WHERE_GREATER_THAN);
3664 }
3665 else {
3666 query.append(WHERE_LESSER_THAN);
3667 }
3668 }
3669 }
3670
3671 query.append(ORDER_BY_CLAUSE);
3672
3673 String[] orderByFields = orderByComparator.getOrderByFields();
3674
3675 for (int i = 0; i < orderByFields.length; i++) {
3676 query.append(_ORDER_BY_ENTITY_ALIAS);
3677 query.append(orderByFields[i]);
3678
3679 if ((i + 1) < orderByFields.length) {
3680 if (orderByComparator.isAscending() ^ previous) {
3681 query.append(ORDER_BY_ASC_HAS_NEXT);
3682 }
3683 else {
3684 query.append(ORDER_BY_DESC_HAS_NEXT);
3685 }
3686 }
3687 else {
3688 if (orderByComparator.isAscending() ^ previous) {
3689 query.append(ORDER_BY_ASC);
3690 }
3691 else {
3692 query.append(ORDER_BY_DESC);
3693 }
3694 }
3695 }
3696 }
3697
3698 else {
3699 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3700 }
3701
3702 String sql = query.toString();
3703
3704 Query q = session.createQuery(sql);
3705
3706 q.setFirstResult(0);
3707 q.setMaxResults(2);
3708
3709 QueryPos qPos = QueryPos.getInstance(q);
3710
3711 qPos.add(plid);
3712
3713 qPos.add(status);
3714
3715 if (orderByComparator != null) {
3716 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3717
3718 for (Object value : values) {
3719 qPos.add(value);
3720 }
3721 }
3722
3723 List<LayoutRevision> list = q.list();
3724
3725 if (list.size() == 2) {
3726 return list.get(1);
3727 }
3728 else {
3729 return null;
3730 }
3731 }
3732
3733
3742 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3743 long layoutBranchId, long plid) throws SystemException {
3744 return findByL_L_P(layoutSetBranchId, layoutBranchId, plid,
3745 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3746 }
3747
3748
3763 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3764 long layoutBranchId, long plid, int start, int end)
3765 throws SystemException {
3766 return findByL_L_P(layoutSetBranchId, layoutBranchId, plid, start, end,
3767 null);
3768 }
3769
3770
3786 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3787 long layoutBranchId, long plid, int start, int end,
3788 OrderByComparator orderByComparator) throws SystemException {
3789 FinderPath finderPath = null;
3790 Object[] finderArgs = null;
3791
3792 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3793 (orderByComparator == null)) {
3794 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P;
3795 finderArgs = new Object[] { layoutSetBranchId, layoutBranchId, plid };
3796 }
3797 else {
3798 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_L_P;
3799 finderArgs = new Object[] {
3800 layoutSetBranchId, layoutBranchId, plid,
3801
3802 start, end, orderByComparator
3803 };
3804 }
3805
3806 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3807 finderArgs, this);
3808
3809 if ((list != null) && !list.isEmpty()) {
3810 for (LayoutRevision layoutRevision : list) {
3811 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
3812 (layoutBranchId != layoutRevision.getLayoutBranchId()) ||
3813 (plid != layoutRevision.getPlid())) {
3814 list = null;
3815
3816 break;
3817 }
3818 }
3819 }
3820
3821 if (list == null) {
3822 StringBundler query = null;
3823
3824 if (orderByComparator != null) {
3825 query = new StringBundler(5 +
3826 (orderByComparator.getOrderByFields().length * 3));
3827 }
3828 else {
3829 query = new StringBundler(5);
3830 }
3831
3832 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3833
3834 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
3835
3836 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
3837
3838 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
3839
3840 if (orderByComparator != null) {
3841 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3842 orderByComparator);
3843 }
3844
3845 else {
3846 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3847 }
3848
3849 String sql = query.toString();
3850
3851 Session session = null;
3852
3853 try {
3854 session = openSession();
3855
3856 Query q = session.createQuery(sql);
3857
3858 QueryPos qPos = QueryPos.getInstance(q);
3859
3860 qPos.add(layoutSetBranchId);
3861
3862 qPos.add(layoutBranchId);
3863
3864 qPos.add(plid);
3865
3866 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
3867 start, end);
3868 }
3869 catch (Exception e) {
3870 throw processException(e);
3871 }
3872 finally {
3873 if (list == null) {
3874 FinderCacheUtil.removeResult(finderPath, finderArgs);
3875 }
3876 else {
3877 cacheResult(list);
3878
3879 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3880 }
3881
3882 closeSession(session);
3883 }
3884 }
3885
3886 return list;
3887 }
3888
3889
3900 public LayoutRevision findByL_L_P_First(long layoutSetBranchId,
3901 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3902 throws NoSuchLayoutRevisionException, SystemException {
3903 LayoutRevision layoutRevision = fetchByL_L_P_First(layoutSetBranchId,
3904 layoutBranchId, plid, orderByComparator);
3905
3906 if (layoutRevision != null) {
3907 return layoutRevision;
3908 }
3909
3910 StringBundler msg = new StringBundler(8);
3911
3912 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3913
3914 msg.append("layoutSetBranchId=");
3915 msg.append(layoutSetBranchId);
3916
3917 msg.append(", layoutBranchId=");
3918 msg.append(layoutBranchId);
3919
3920 msg.append(", plid=");
3921 msg.append(plid);
3922
3923 msg.append(StringPool.CLOSE_CURLY_BRACE);
3924
3925 throw new NoSuchLayoutRevisionException(msg.toString());
3926 }
3927
3928
3938 public LayoutRevision fetchByL_L_P_First(long layoutSetBranchId,
3939 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3940 throws SystemException {
3941 List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
3942 layoutBranchId, plid, 0, 1, orderByComparator);
3943
3944 if (!list.isEmpty()) {
3945 return list.get(0);
3946 }
3947
3948 return null;
3949 }
3950
3951
3962 public LayoutRevision findByL_L_P_Last(long layoutSetBranchId,
3963 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3964 throws NoSuchLayoutRevisionException, SystemException {
3965 LayoutRevision layoutRevision = fetchByL_L_P_Last(layoutSetBranchId,
3966 layoutBranchId, plid, orderByComparator);
3967
3968 if (layoutRevision != null) {
3969 return layoutRevision;
3970 }
3971
3972 StringBundler msg = new StringBundler(8);
3973
3974 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3975
3976 msg.append("layoutSetBranchId=");
3977 msg.append(layoutSetBranchId);
3978
3979 msg.append(", layoutBranchId=");
3980 msg.append(layoutBranchId);
3981
3982 msg.append(", plid=");
3983 msg.append(plid);
3984
3985 msg.append(StringPool.CLOSE_CURLY_BRACE);
3986
3987 throw new NoSuchLayoutRevisionException(msg.toString());
3988 }
3989
3990
4000 public LayoutRevision fetchByL_L_P_Last(long layoutSetBranchId,
4001 long layoutBranchId, long plid, OrderByComparator orderByComparator)
4002 throws SystemException {
4003 int count = countByL_L_P(layoutSetBranchId, layoutBranchId, plid);
4004
4005 List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
4006 layoutBranchId, plid, count - 1, count, orderByComparator);
4007
4008 if (!list.isEmpty()) {
4009 return list.get(0);
4010 }
4011
4012 return null;
4013 }
4014
4015
4027 public LayoutRevision[] findByL_L_P_PrevAndNext(long layoutRevisionId,
4028 long layoutSetBranchId, long layoutBranchId, long plid,
4029 OrderByComparator orderByComparator)
4030 throws NoSuchLayoutRevisionException, SystemException {
4031 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
4032
4033 Session session = null;
4034
4035 try {
4036 session = openSession();
4037
4038 LayoutRevision[] array = new LayoutRevisionImpl[3];
4039
4040 array[0] = getByL_L_P_PrevAndNext(session, layoutRevision,
4041 layoutSetBranchId, layoutBranchId, plid, orderByComparator,
4042 true);
4043
4044 array[1] = layoutRevision;
4045
4046 array[2] = getByL_L_P_PrevAndNext(session, layoutRevision,
4047 layoutSetBranchId, layoutBranchId, plid, orderByComparator,
4048 false);
4049
4050 return array;
4051 }
4052 catch (Exception e) {
4053 throw processException(e);
4054 }
4055 finally {
4056 closeSession(session);
4057 }
4058 }
4059
4060 protected LayoutRevision getByL_L_P_PrevAndNext(Session session,
4061 LayoutRevision layoutRevision, long layoutSetBranchId,
4062 long layoutBranchId, long plid, OrderByComparator orderByComparator,
4063 boolean previous) {
4064 StringBundler query = null;
4065
4066 if (orderByComparator != null) {
4067 query = new StringBundler(6 +
4068 (orderByComparator.getOrderByFields().length * 6));
4069 }
4070 else {
4071 query = new StringBundler(3);
4072 }
4073
4074 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4075
4076 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
4077
4078 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
4079
4080 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
4081
4082 if (orderByComparator != null) {
4083 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4084
4085 if (orderByConditionFields.length > 0) {
4086 query.append(WHERE_AND);
4087 }
4088
4089 for (int i = 0; i < orderByConditionFields.length; i++) {
4090 query.append(_ORDER_BY_ENTITY_ALIAS);
4091 query.append(orderByConditionFields[i]);
4092
4093 if ((i + 1) < orderByConditionFields.length) {
4094 if (orderByComparator.isAscending() ^ previous) {
4095 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4096 }
4097 else {
4098 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4099 }
4100 }
4101 else {
4102 if (orderByComparator.isAscending() ^ previous) {
4103 query.append(WHERE_GREATER_THAN);
4104 }
4105 else {
4106 query.append(WHERE_LESSER_THAN);
4107 }
4108 }
4109 }
4110
4111 query.append(ORDER_BY_CLAUSE);
4112
4113 String[] orderByFields = orderByComparator.getOrderByFields();
4114
4115 for (int i = 0; i < orderByFields.length; i++) {
4116 query.append(_ORDER_BY_ENTITY_ALIAS);
4117 query.append(orderByFields[i]);
4118
4119 if ((i + 1) < orderByFields.length) {
4120 if (orderByComparator.isAscending() ^ previous) {
4121 query.append(ORDER_BY_ASC_HAS_NEXT);
4122 }
4123 else {
4124 query.append(ORDER_BY_DESC_HAS_NEXT);
4125 }
4126 }
4127 else {
4128 if (orderByComparator.isAscending() ^ previous) {
4129 query.append(ORDER_BY_ASC);
4130 }
4131 else {
4132 query.append(ORDER_BY_DESC);
4133 }
4134 }
4135 }
4136 }
4137
4138 else {
4139 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4140 }
4141
4142 String sql = query.toString();
4143
4144 Query q = session.createQuery(sql);
4145
4146 q.setFirstResult(0);
4147 q.setMaxResults(2);
4148
4149 QueryPos qPos = QueryPos.getInstance(q);
4150
4151 qPos.add(layoutSetBranchId);
4152
4153 qPos.add(layoutBranchId);
4154
4155 qPos.add(plid);
4156
4157 if (orderByComparator != null) {
4158 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4159
4160 for (Object value : values) {
4161 qPos.add(value);
4162 }
4163 }
4164
4165 List<LayoutRevision> list = q.list();
4166
4167 if (list.size() == 2) {
4168 return list.get(1);
4169 }
4170 else {
4171 return null;
4172 }
4173 }
4174
4175
4184 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4185 long parentLayoutRevisionId, long plid) throws SystemException {
4186 return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4187 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4188 }
4189
4190
4205 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4206 long parentLayoutRevisionId, long plid, int start, int end)
4207 throws SystemException {
4208 return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4209 start, end, null);
4210 }
4211
4212
4228 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4229 long parentLayoutRevisionId, long plid, int start, int end,
4230 OrderByComparator orderByComparator) throws SystemException {
4231 FinderPath finderPath = null;
4232 Object[] finderArgs = null;
4233
4234 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4235 (orderByComparator == null)) {
4236 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P;
4237 finderArgs = new Object[] {
4238 layoutSetBranchId, parentLayoutRevisionId, plid
4239 };
4240 }
4241 else {
4242 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_P;
4243 finderArgs = new Object[] {
4244 layoutSetBranchId, parentLayoutRevisionId, plid,
4245
4246 start, end, orderByComparator
4247 };
4248 }
4249
4250 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
4251 finderArgs, this);
4252
4253 if ((list != null) && !list.isEmpty()) {
4254 for (LayoutRevision layoutRevision : list) {
4255 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4256 (parentLayoutRevisionId != layoutRevision.getParentLayoutRevisionId()) ||
4257 (plid != layoutRevision.getPlid())) {
4258 list = null;
4259
4260 break;
4261 }
4262 }
4263 }
4264
4265 if (list == null) {
4266 StringBundler query = null;
4267
4268 if (orderByComparator != null) {
4269 query = new StringBundler(5 +
4270 (orderByComparator.getOrderByFields().length * 3));
4271 }
4272 else {
4273 query = new StringBundler(5);
4274 }
4275
4276 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4277
4278 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4279
4280 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4281
4282 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4283
4284 if (orderByComparator != null) {
4285 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4286 orderByComparator);
4287 }
4288
4289 else {
4290 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4291 }
4292
4293 String sql = query.toString();
4294
4295 Session session = null;
4296
4297 try {
4298 session = openSession();
4299
4300 Query q = session.createQuery(sql);
4301
4302 QueryPos qPos = QueryPos.getInstance(q);
4303
4304 qPos.add(layoutSetBranchId);
4305
4306 qPos.add(parentLayoutRevisionId);
4307
4308 qPos.add(plid);
4309
4310 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
4311 start, end);
4312 }
4313 catch (Exception e) {
4314 throw processException(e);
4315 }
4316 finally {
4317 if (list == null) {
4318 FinderCacheUtil.removeResult(finderPath, finderArgs);
4319 }
4320 else {
4321 cacheResult(list);
4322
4323 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4324 }
4325
4326 closeSession(session);
4327 }
4328 }
4329
4330 return list;
4331 }
4332
4333
4344 public LayoutRevision findByL_P_P_First(long layoutSetBranchId,
4345 long parentLayoutRevisionId, long plid,
4346 OrderByComparator orderByComparator)
4347 throws NoSuchLayoutRevisionException, SystemException {
4348 LayoutRevision layoutRevision = fetchByL_P_P_First(layoutSetBranchId,
4349 parentLayoutRevisionId, plid, orderByComparator);
4350
4351 if (layoutRevision != null) {
4352 return layoutRevision;
4353 }
4354
4355 StringBundler msg = new StringBundler(8);
4356
4357 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4358
4359 msg.append("layoutSetBranchId=");
4360 msg.append(layoutSetBranchId);
4361
4362 msg.append(", parentLayoutRevisionId=");
4363 msg.append(parentLayoutRevisionId);
4364
4365 msg.append(", plid=");
4366 msg.append(plid);
4367
4368 msg.append(StringPool.CLOSE_CURLY_BRACE);
4369
4370 throw new NoSuchLayoutRevisionException(msg.toString());
4371 }
4372
4373
4383 public LayoutRevision fetchByL_P_P_First(long layoutSetBranchId,
4384 long parentLayoutRevisionId, long plid,
4385 OrderByComparator orderByComparator) throws SystemException {
4386 List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4387 parentLayoutRevisionId, plid, 0, 1, orderByComparator);
4388
4389 if (!list.isEmpty()) {
4390 return list.get(0);
4391 }
4392
4393 return null;
4394 }
4395
4396
4407 public LayoutRevision findByL_P_P_Last(long layoutSetBranchId,
4408 long parentLayoutRevisionId, long plid,
4409 OrderByComparator orderByComparator)
4410 throws NoSuchLayoutRevisionException, SystemException {
4411 LayoutRevision layoutRevision = fetchByL_P_P_Last(layoutSetBranchId,
4412 parentLayoutRevisionId, plid, orderByComparator);
4413
4414 if (layoutRevision != null) {
4415 return layoutRevision;
4416 }
4417
4418 StringBundler msg = new StringBundler(8);
4419
4420 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4421
4422 msg.append("layoutSetBranchId=");
4423 msg.append(layoutSetBranchId);
4424
4425 msg.append(", parentLayoutRevisionId=");
4426 msg.append(parentLayoutRevisionId);
4427
4428 msg.append(", plid=");
4429 msg.append(plid);
4430
4431 msg.append(StringPool.CLOSE_CURLY_BRACE);
4432
4433 throw new NoSuchLayoutRevisionException(msg.toString());
4434 }
4435
4436
4446 public LayoutRevision fetchByL_P_P_Last(long layoutSetBranchId,
4447 long parentLayoutRevisionId, long plid,
4448 OrderByComparator orderByComparator) throws SystemException {
4449 int count = countByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid);
4450
4451 List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4452 parentLayoutRevisionId, plid, count - 1, count,
4453 orderByComparator);
4454
4455 if (!list.isEmpty()) {
4456 return list.get(0);
4457 }
4458
4459 return null;
4460 }
4461
4462
4474 public LayoutRevision[] findByL_P_P_PrevAndNext(long layoutRevisionId,
4475 long layoutSetBranchId, long parentLayoutRevisionId, long plid,
4476 OrderByComparator orderByComparator)
4477 throws NoSuchLayoutRevisionException, SystemException {
4478 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
4479
4480 Session session = null;
4481
4482 try {
4483 session = openSession();
4484
4485 LayoutRevision[] array = new LayoutRevisionImpl[3];
4486
4487 array[0] = getByL_P_P_PrevAndNext(session, layoutRevision,
4488 layoutSetBranchId, parentLayoutRevisionId, plid,
4489 orderByComparator, true);
4490
4491 array[1] = layoutRevision;
4492
4493 array[2] = getByL_P_P_PrevAndNext(session, layoutRevision,
4494 layoutSetBranchId, parentLayoutRevisionId, plid,
4495 orderByComparator, false);
4496
4497 return array;
4498 }
4499 catch (Exception e) {
4500 throw processException(e);
4501 }
4502 finally {
4503 closeSession(session);
4504 }
4505 }
4506
4507 protected LayoutRevision getByL_P_P_PrevAndNext(Session session,
4508 LayoutRevision layoutRevision, long layoutSetBranchId,
4509 long parentLayoutRevisionId, long plid,
4510 OrderByComparator orderByComparator, boolean previous) {
4511 StringBundler query = null;
4512
4513 if (orderByComparator != null) {
4514 query = new StringBundler(6 +
4515 (orderByComparator.getOrderByFields().length * 6));
4516 }
4517 else {
4518 query = new StringBundler(3);
4519 }
4520
4521 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4522
4523 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4524
4525 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4526
4527 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4528
4529 if (orderByComparator != null) {
4530 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4531
4532 if (orderByConditionFields.length > 0) {
4533 query.append(WHERE_AND);
4534 }
4535
4536 for (int i = 0; i < orderByConditionFields.length; i++) {
4537 query.append(_ORDER_BY_ENTITY_ALIAS);
4538 query.append(orderByConditionFields[i]);
4539
4540 if ((i + 1) < orderByConditionFields.length) {
4541 if (orderByComparator.isAscending() ^ previous) {
4542 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4543 }
4544 else {
4545 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4546 }
4547 }
4548 else {
4549 if (orderByComparator.isAscending() ^ previous) {
4550 query.append(WHERE_GREATER_THAN);
4551 }
4552 else {
4553 query.append(WHERE_LESSER_THAN);
4554 }
4555 }
4556 }
4557
4558 query.append(ORDER_BY_CLAUSE);
4559
4560 String[] orderByFields = orderByComparator.getOrderByFields();
4561
4562 for (int i = 0; i < orderByFields.length; i++) {
4563 query.append(_ORDER_BY_ENTITY_ALIAS);
4564 query.append(orderByFields[i]);
4565
4566 if ((i + 1) < orderByFields.length) {
4567 if (orderByComparator.isAscending() ^ previous) {
4568 query.append(ORDER_BY_ASC_HAS_NEXT);
4569 }
4570 else {
4571 query.append(ORDER_BY_DESC_HAS_NEXT);
4572 }
4573 }
4574 else {
4575 if (orderByComparator.isAscending() ^ previous) {
4576 query.append(ORDER_BY_ASC);
4577 }
4578 else {
4579 query.append(ORDER_BY_DESC);
4580 }
4581 }
4582 }
4583 }
4584
4585 else {
4586 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4587 }
4588
4589 String sql = query.toString();
4590
4591 Query q = session.createQuery(sql);
4592
4593 q.setFirstResult(0);
4594 q.setMaxResults(2);
4595
4596 QueryPos qPos = QueryPos.getInstance(q);
4597
4598 qPos.add(layoutSetBranchId);
4599
4600 qPos.add(parentLayoutRevisionId);
4601
4602 qPos.add(plid);
4603
4604 if (orderByComparator != null) {
4605 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4606
4607 for (Object value : values) {
4608 qPos.add(value);
4609 }
4610 }
4611
4612 List<LayoutRevision> list = q.list();
4613
4614 if (list.size() == 2) {
4615 return list.get(1);
4616 }
4617 else {
4618 return null;
4619 }
4620 }
4621
4622
4632 public LayoutRevision findByL_H_P(long layoutSetBranchId, boolean head,
4633 long plid) throws NoSuchLayoutRevisionException, SystemException {
4634 LayoutRevision layoutRevision = fetchByL_H_P(layoutSetBranchId, head,
4635 plid);
4636
4637 if (layoutRevision == null) {
4638 StringBundler msg = new StringBundler(8);
4639
4640 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4641
4642 msg.append("layoutSetBranchId=");
4643 msg.append(layoutSetBranchId);
4644
4645 msg.append(", head=");
4646 msg.append(head);
4647
4648 msg.append(", plid=");
4649 msg.append(plid);
4650
4651 msg.append(StringPool.CLOSE_CURLY_BRACE);
4652
4653 if (_log.isWarnEnabled()) {
4654 _log.warn(msg.toString());
4655 }
4656
4657 throw new NoSuchLayoutRevisionException(msg.toString());
4658 }
4659
4660 return layoutRevision;
4661 }
4662
4663
4672 public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4673 long plid) throws SystemException {
4674 return fetchByL_H_P(layoutSetBranchId, head, plid, true);
4675 }
4676
4677
4687 public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4688 long plid, boolean retrieveFromCache) throws SystemException {
4689 Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
4690
4691 Object result = null;
4692
4693 if (retrieveFromCache) {
4694 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_L_H_P,
4695 finderArgs, this);
4696 }
4697
4698 if (result instanceof LayoutRevision) {
4699 LayoutRevision layoutRevision = (LayoutRevision)result;
4700
4701 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4702 (head != layoutRevision.getHead()) ||
4703 (plid != layoutRevision.getPlid())) {
4704 result = null;
4705 }
4706 }
4707
4708 if (result == null) {
4709 StringBundler query = new StringBundler(5);
4710
4711 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4712
4713 query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
4714
4715 query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
4716
4717 query.append(_FINDER_COLUMN_L_H_P_PLID_2);
4718
4719 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4720
4721 String sql = query.toString();
4722
4723 Session session = null;
4724
4725 try {
4726 session = openSession();
4727
4728 Query q = session.createQuery(sql);
4729
4730 QueryPos qPos = QueryPos.getInstance(q);
4731
4732 qPos.add(layoutSetBranchId);
4733
4734 qPos.add(head);
4735
4736 qPos.add(plid);
4737
4738 List<LayoutRevision> list = q.list();
4739
4740 result = list;
4741
4742 LayoutRevision layoutRevision = null;
4743
4744 if (list.isEmpty()) {
4745 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4746 finderArgs, list);
4747 }
4748 else {
4749 layoutRevision = list.get(0);
4750
4751 cacheResult(layoutRevision);
4752
4753 if ((layoutRevision.getLayoutSetBranchId() != layoutSetBranchId) ||
4754 (layoutRevision.getHead() != head) ||
4755 (layoutRevision.getPlid() != plid)) {
4756 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4757 finderArgs, layoutRevision);
4758 }
4759 }
4760
4761 return layoutRevision;
4762 }
4763 catch (Exception e) {
4764 throw processException(e);
4765 }
4766 finally {
4767 if (result == null) {
4768 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P,
4769 finderArgs);
4770 }
4771
4772 closeSession(session);
4773 }
4774 }
4775 else {
4776 if (result instanceof List<?>) {
4777 return null;
4778 }
4779 else {
4780 return (LayoutRevision)result;
4781 }
4782 }
4783 }
4784
4785
4794 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4795 int status) throws SystemException {
4796 return findByL_P_S(layoutSetBranchId, plid, status, QueryUtil.ALL_POS,
4797 QueryUtil.ALL_POS, null);
4798 }
4799
4800
4815 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4816 int status, int start, int end) throws SystemException {
4817 return findByL_P_S(layoutSetBranchId, plid, status, start, end, null);
4818 }
4819
4820
4836 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
4837 int status, int start, int end, OrderByComparator orderByComparator)
4838 throws SystemException {
4839 FinderPath finderPath = null;
4840 Object[] finderArgs = null;
4841
4842 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4843 (orderByComparator == null)) {
4844 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S;
4845 finderArgs = new Object[] { layoutSetBranchId, plid, status };
4846 }
4847 else {
4848 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_S;
4849 finderArgs = new Object[] {
4850 layoutSetBranchId, plid, status,
4851
4852 start, end, orderByComparator
4853 };
4854 }
4855
4856 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
4857 finderArgs, this);
4858
4859 if ((list != null) && !list.isEmpty()) {
4860 for (LayoutRevision layoutRevision : list) {
4861 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4862 (plid != layoutRevision.getPlid()) ||
4863 (status != layoutRevision.getStatus())) {
4864 list = null;
4865
4866 break;
4867 }
4868 }
4869 }
4870
4871 if (list == null) {
4872 StringBundler query = null;
4873
4874 if (orderByComparator != null) {
4875 query = new StringBundler(5 +
4876 (orderByComparator.getOrderByFields().length * 3));
4877 }
4878 else {
4879 query = new StringBundler(5);
4880 }
4881
4882 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4883
4884 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
4885
4886 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
4887
4888 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
4889
4890 if (orderByComparator != null) {
4891 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4892 orderByComparator);
4893 }
4894
4895 else {
4896 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4897 }
4898
4899 String sql = query.toString();
4900
4901 Session session = null;
4902
4903 try {
4904 session = openSession();
4905
4906 Query q = session.createQuery(sql);
4907
4908 QueryPos qPos = QueryPos.getInstance(q);
4909
4910 qPos.add(layoutSetBranchId);
4911
4912 qPos.add(plid);
4913
4914 qPos.add(status);
4915
4916 list = (List<LayoutRevision>)QueryUtil.list(q, getDialect(),
4917 start, end);
4918 }
4919 catch (Exception e) {
4920 throw processException(e);
4921 }
4922 finally {
4923 if (list == null) {
4924 FinderCacheUtil.removeResult(finderPath, finderArgs);
4925 }
4926 else {
4927 cacheResult(list);
4928
4929 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4930 }
4931
4932 closeSession(session);
4933 }
4934 }
4935
4936 return list;
4937 }
4938
4939
4950 public LayoutRevision findByL_P_S_First(long layoutSetBranchId, long plid,
4951 int status, OrderByComparator orderByComparator)
4952 throws NoSuchLayoutRevisionException, SystemException {
4953 LayoutRevision layoutRevision = fetchByL_P_S_First(layoutSetBranchId,
4954 plid, status, orderByComparator);
4955
4956 if (layoutRevision != null) {
4957 return layoutRevision;
4958 }
4959
4960 StringBundler msg = new StringBundler(8);
4961
4962 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4963
4964 msg.append("layoutSetBranchId=");
4965 msg.append(layoutSetBranchId);
4966
4967 msg.append(", plid=");
4968 msg.append(plid);
4969
4970 msg.append(", status=");
4971 msg.append(status);
4972
4973 msg.append(StringPool.CLOSE_CURLY_BRACE);
4974
4975 throw new NoSuchLayoutRevisionException(msg.toString());
4976 }
4977
4978
4988 public LayoutRevision fetchByL_P_S_First(long layoutSetBranchId, long plid,
4989 int status, OrderByComparator orderByComparator)
4990 throws SystemException {
4991 List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
4992 status, 0, 1, orderByComparator);
4993
4994 if (!list.isEmpty()) {
4995 return list.get(0);
4996 }
4997
4998 return null;
4999 }
5000
5001
5012 public LayoutRevision findByL_P_S_Last(long layoutSetBranchId, long plid,
5013 int status, OrderByComparator orderByComparator)
5014 throws NoSuchLayoutRevisionException, SystemException {
5015 LayoutRevision layoutRevision = fetchByL_P_S_Last(layoutSetBranchId,
5016 plid, status, orderByComparator);
5017
5018 if (layoutRevision != null) {
5019 return layoutRevision;
5020 }
5021
5022 StringBundler msg = new StringBundler(8);
5023
5024 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5025
5026 msg.append("layoutSetBranchId=");
5027 msg.append(layoutSetBranchId);
5028
5029 msg.append(", plid=");
5030 msg.append(plid);
5031
5032 msg.append(", status=");
5033 msg.append(status);
5034
5035 msg.append(StringPool.CLOSE_CURLY_BRACE);
5036
5037 throw new NoSuchLayoutRevisionException(msg.toString());
5038 }
5039
5040
5050 public LayoutRevision fetchByL_P_S_Last(long layoutSetBranchId, long plid,
5051 int status, OrderByComparator orderByComparator)
5052 throws SystemException {
5053 int count = countByL_P_S(layoutSetBranchId, plid, status);
5054
5055 List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
5056 status, count - 1, count, orderByComparator);
5057
5058 if (!list.isEmpty()) {
5059 return list.get(0);
5060 }
5061
5062 return null;
5063 }
5064
5065
5077 public LayoutRevision[] findByL_P_S_PrevAndNext(long layoutRevisionId,
5078 long layoutSetBranchId, long plid, int status,
5079 OrderByComparator orderByComparator)
5080 throws NoSuchLayoutRevisionException, SystemException {
5081 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
5082
5083 Session session = null;
5084
5085 try {
5086 session = openSession();
5087
5088 LayoutRevision[] array = new LayoutRevisionImpl[3];
5089
5090 array[0] = getByL_P_S_PrevAndNext(session, layoutRevision,
5091 layoutSetBranchId, plid, status, orderByComparator, true);
5092
5093 array[1] = layoutRevision;
5094
5095 array[2] = getByL_P_S_PrevAndNext(session, layoutRevision,
5096 layoutSetBranchId, plid, status, orderByComparator, false);
5097
5098 return array;
5099 }
5100 catch (Exception e) {
5101 throw processException(e);
5102 }
5103 finally {
5104 closeSession(session);
5105 }
5106 }
5107
5108 protected LayoutRevision getByL_P_S_PrevAndNext(Session session,
5109 LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
5110 int status, OrderByComparator orderByComparator, boolean previous) {
5111 StringBundler query = null;
5112
5113 if (orderByComparator != null) {
5114 query = new StringBundler(6 +
5115 (orderByComparator.getOrderByFields().length * 6));
5116 }
5117 else {
5118 query = new StringBundler(3);
5119 }
5120
5121 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
5122
5123 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
5124
5125 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
5126
5127 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
5128
5129 if (orderByComparator != null) {
5130 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5131
5132 if (orderByConditionFields.length > 0) {
5133 query.append(WHERE_AND);
5134 }
5135
5136 for (int i = 0; i < orderByConditionFields.length; i++) {
5137 query.append(_ORDER_BY_ENTITY_ALIAS);
5138 query.append(orderByConditionFields[i]);
5139
5140 if ((i + 1) < orderByConditionFields.length) {
5141 if (orderByComparator.isAscending() ^ previous) {
5142 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5143 }
5144 else {
5145 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5146 }
5147 }
5148 else {
5149 if (orderByComparator.isAscending() ^ previous) {
5150 query.append(WHERE_GREATER_THAN);
5151 }
5152 else {
5153 query.append(WHERE_LESSER_THAN);
5154 }
5155 }
5156 }
5157
5158 query.append(ORDER_BY_CLAUSE);
5159
5160 String[] orderByFields = orderByComparator.getOrderByFields();
5161
5162 for (int i = 0; i < orderByFields.length; i++) {
5163 query.append(_ORDER_BY_ENTITY_ALIAS);
5164 query.append(orderByFields[i]);
5165
5166 if ((i + 1) < orderByFields.length) {
5167 if (orderByComparator.isAscending() ^ previous) {
5168 query.append(ORDER_BY_ASC_HAS_NEXT);
5169 }
5170 else {
5171 query.append(ORDER_BY_DESC_HAS_NEXT);
5172 }
5173 }
5174 else {
5175 if (orderByComparator.isAscending() ^ previous) {
5176 query.append(ORDER_BY_ASC);
5177 }
5178 else {
5179 query.append(ORDER_BY_DESC);
5180 }
5181 }
5182 }
5183 }
5184
5185 else {
5186 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5187 }
5188
5189 String sql = query.toString();
5190
5191 Query q = session.createQuery(sql);
5192
5193 q.setFirstResult(0);
5194 q.setMaxResults(2);
5195
5196 QueryPos qPos = QueryPos.getInstance(q);
5197
5198 qPos.add(layoutSetBranchId);
5199
5200 qPos.add(plid);
5201
5202 qPos.add(status);
5203
5204 if (orderByComparator != null) {
5205 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
5206
5207 for (Object value : values) {
5208 qPos.add(value);
5209 }
5210 }
5211
5212 List<LayoutRevision> list = q.list();
5213
5214 if (list.size() == 2) {
5215 return list.get(1);
5216 }
5217 else {
5218 return null;
5219 }
5220 }
5221
5222
5228 public List<LayoutRevision> findAll() throws SystemException {
5229 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5230 }
5231
5232
5244 public List<LayoutRevision> findAll(int start, int end)
5245 throws SystemException {
5246 return findAll(start, end, null);
5247 }
5248
5249
5262 public List<LayoutRevision> findAll(int start, int end,
5263 OrderByComparator orderByComparator) throws SystemException {
5264 FinderPath finderPath = null;
5265 Object[] finderArgs = new Object[] { start, end, orderByComparator };
5266
5267 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5268 (orderByComparator == null)) {
5269 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5270 finderArgs = FINDER_ARGS_EMPTY;
5271 }
5272 else {
5273 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5274 finderArgs = new Object[] { start, end, orderByComparator };
5275 }
5276
5277 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
5278 finderArgs, this);
5279
5280 if (list == null) {
5281 StringBundler query = null;
5282 String sql = null;
5283
5284 if (orderByComparator != null) {
5285 query = new StringBundler(2 +
5286 (orderByComparator.getOrderByFields().length * 3));
5287
5288 query.append(_SQL_SELECT_LAYOUTREVISION);
5289
5290 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5291 orderByComparator);
5292
5293 sql = query.toString();
5294 }
5295 else {
5296 sql = _SQL_SELECT_LAYOUTREVISION.concat(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5297 }
5298
5299 Session session = null;
5300
5301 try {
5302 session = openSession();
5303
5304 Query q = session.createQuery(sql);
5305
5306 if (orderByComparator == null) {
5307 list = (List<LayoutRevision>)QueryUtil.list(q,
5308 getDialect(), start, end, false);
5309
5310 Collections.sort(list);
5311 }
5312 else {
5313 list = (List<LayoutRevision>)QueryUtil.list(q,
5314 getDialect(), start, end);
5315 }
5316 }
5317 catch (Exception e) {
5318 throw processException(e);
5319 }
5320 finally {
5321 if (list == null) {
5322 FinderCacheUtil.removeResult(finderPath, finderArgs);
5323 }
5324 else {
5325 cacheResult(list);
5326
5327 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5328 }
5329
5330 closeSession(session);
5331 }
5332 }
5333
5334 return list;
5335 }
5336
5337
5343 public void removeByLayoutSetBranchId(long layoutSetBranchId)
5344 throws SystemException {
5345 for (LayoutRevision layoutRevision : findByLayoutSetBranchId(
5346 layoutSetBranchId)) {
5347 remove(layoutRevision);
5348 }
5349 }
5350
5351
5357 public void removeByPlid(long plid) throws SystemException {
5358 for (LayoutRevision layoutRevision : findByPlid(plid)) {
5359 remove(layoutRevision);
5360 }
5361 }
5362
5363
5370 public void removeByL_H(long layoutSetBranchId, boolean head)
5371 throws SystemException {
5372 for (LayoutRevision layoutRevision : findByL_H(layoutSetBranchId, head)) {
5373 remove(layoutRevision);
5374 }
5375 }
5376
5377
5384 public void removeByL_P(long layoutSetBranchId, long plid)
5385 throws SystemException {
5386 for (LayoutRevision layoutRevision : findByL_P(layoutSetBranchId, plid)) {
5387 remove(layoutRevision);
5388 }
5389 }
5390
5391
5398 public void removeByL_S(long layoutSetBranchId, int status)
5399 throws SystemException {
5400 for (LayoutRevision layoutRevision : findByL_S(layoutSetBranchId, status)) {
5401 remove(layoutRevision);
5402 }
5403 }
5404
5405
5412 public void removeByH_P(boolean head, long plid) throws SystemException {
5413 for (LayoutRevision layoutRevision : findByH_P(head, plid)) {
5414 remove(layoutRevision);
5415 }
5416 }
5417
5418
5425 public void removeByP_NotS(long plid, int status) throws SystemException {
5426 for (LayoutRevision layoutRevision : findByP_NotS(plid, status)) {
5427 remove(layoutRevision);
5428 }
5429 }
5430
5431
5439 public void removeByL_L_P(long layoutSetBranchId, long layoutBranchId,
5440 long plid) throws SystemException {
5441 for (LayoutRevision layoutRevision : findByL_L_P(layoutSetBranchId,
5442 layoutBranchId, plid)) {
5443 remove(layoutRevision);
5444 }
5445 }
5446
5447
5455 public void removeByL_P_P(long layoutSetBranchId,
5456 long parentLayoutRevisionId, long plid) throws SystemException {
5457 for (LayoutRevision layoutRevision : findByL_P_P(layoutSetBranchId,
5458 parentLayoutRevisionId, plid)) {
5459 remove(layoutRevision);
5460 }
5461 }
5462
5463
5472 public LayoutRevision removeByL_H_P(long layoutSetBranchId, boolean head,
5473 long plid) throws NoSuchLayoutRevisionException, SystemException {
5474 LayoutRevision layoutRevision = findByL_H_P(layoutSetBranchId, head,
5475 plid);
5476
5477 return remove(layoutRevision);
5478 }
5479
5480
5488 public void removeByL_P_S(long layoutSetBranchId, long plid, int status)
5489 throws SystemException {
5490 for (LayoutRevision layoutRevision : findByL_P_S(layoutSetBranchId,
5491 plid, status)) {
5492 remove(layoutRevision);
5493 }
5494 }
5495
5496
5501 public void removeAll() throws SystemException {
5502 for (LayoutRevision layoutRevision : findAll()) {
5503 remove(layoutRevision);
5504 }
5505 }
5506
5507
5514 public int countByLayoutSetBranchId(long layoutSetBranchId)
5515 throws SystemException {
5516 Object[] finderArgs = new Object[] { layoutSetBranchId };
5517
5518 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5519 finderArgs, this);
5520
5521 if (count == null) {
5522 StringBundler query = new StringBundler(2);
5523
5524 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5525
5526 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
5527
5528 String sql = query.toString();
5529
5530 Session session = null;
5531
5532 try {
5533 session = openSession();
5534
5535 Query q = session.createQuery(sql);
5536
5537 QueryPos qPos = QueryPos.getInstance(q);
5538
5539 qPos.add(layoutSetBranchId);
5540
5541 count = (Long)q.uniqueResult();
5542 }
5543 catch (Exception e) {
5544 throw processException(e);
5545 }
5546 finally {
5547 if (count == null) {
5548 count = Long.valueOf(0);
5549 }
5550
5551 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5552 finderArgs, count);
5553
5554 closeSession(session);
5555 }
5556 }
5557
5558 return count.intValue();
5559 }
5560
5561
5568 public int countByPlid(long plid) throws SystemException {
5569 Object[] finderArgs = new Object[] { plid };
5570
5571 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PLID,
5572 finderArgs, this);
5573
5574 if (count == null) {
5575 StringBundler query = new StringBundler(2);
5576
5577 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5578
5579 query.append(_FINDER_COLUMN_PLID_PLID_2);
5580
5581 String sql = query.toString();
5582
5583 Session session = null;
5584
5585 try {
5586 session = openSession();
5587
5588 Query q = session.createQuery(sql);
5589
5590 QueryPos qPos = QueryPos.getInstance(q);
5591
5592 qPos.add(plid);
5593
5594 count = (Long)q.uniqueResult();
5595 }
5596 catch (Exception e) {
5597 throw processException(e);
5598 }
5599 finally {
5600 if (count == null) {
5601 count = Long.valueOf(0);
5602 }
5603
5604 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PLID,
5605 finderArgs, count);
5606
5607 closeSession(session);
5608 }
5609 }
5610
5611 return count.intValue();
5612 }
5613
5614
5622 public int countByL_H(long layoutSetBranchId, boolean head)
5623 throws SystemException {
5624 Object[] finderArgs = new Object[] { layoutSetBranchId, head };
5625
5626 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_H,
5627 finderArgs, this);
5628
5629 if (count == null) {
5630 StringBundler query = new StringBundler(3);
5631
5632 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5633
5634 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
5635
5636 query.append(_FINDER_COLUMN_L_H_HEAD_2);
5637
5638 String sql = query.toString();
5639
5640 Session session = null;
5641
5642 try {
5643 session = openSession();
5644
5645 Query q = session.createQuery(sql);
5646
5647 QueryPos qPos = QueryPos.getInstance(q);
5648
5649 qPos.add(layoutSetBranchId);
5650
5651 qPos.add(head);
5652
5653 count = (Long)q.uniqueResult();
5654 }
5655 catch (Exception e) {
5656 throw processException(e);
5657 }
5658 finally {
5659 if (count == null) {
5660 count = Long.valueOf(0);
5661 }
5662
5663 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H, finderArgs,
5664 count);
5665
5666 closeSession(session);
5667 }
5668 }
5669
5670 return count.intValue();
5671 }
5672
5673
5681 public int countByL_P(long layoutSetBranchId, long plid)
5682 throws SystemException {
5683 Object[] finderArgs = new Object[] { layoutSetBranchId, plid };
5684
5685 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P,
5686 finderArgs, this);
5687
5688 if (count == null) {
5689 StringBundler query = new StringBundler(3);
5690
5691 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5692
5693 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
5694
5695 query.append(_FINDER_COLUMN_L_P_PLID_2);
5696
5697 String sql = query.toString();
5698
5699 Session session = null;
5700
5701 try {
5702 session = openSession();
5703
5704 Query q = session.createQuery(sql);
5705
5706 QueryPos qPos = QueryPos.getInstance(q);
5707
5708 qPos.add(layoutSetBranchId);
5709
5710 qPos.add(plid);
5711
5712 count = (Long)q.uniqueResult();
5713 }
5714 catch (Exception e) {
5715 throw processException(e);
5716 }
5717 finally {
5718 if (count == null) {
5719 count = Long.valueOf(0);
5720 }
5721
5722 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P, finderArgs,
5723 count);
5724
5725 closeSession(session);
5726 }
5727 }
5728
5729 return count.intValue();
5730 }
5731
5732
5740 public int countByL_S(long layoutSetBranchId, int status)
5741 throws SystemException {
5742 Object[] finderArgs = new Object[] { layoutSetBranchId, status };
5743
5744 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_S,
5745 finderArgs, this);
5746
5747 if (count == null) {
5748 StringBundler query = new StringBundler(3);
5749
5750 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5751
5752 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
5753
5754 query.append(_FINDER_COLUMN_L_S_STATUS_2);
5755
5756 String sql = query.toString();
5757
5758 Session session = null;
5759
5760 try {
5761 session = openSession();
5762
5763 Query q = session.createQuery(sql);
5764
5765 QueryPos qPos = QueryPos.getInstance(q);
5766
5767 qPos.add(layoutSetBranchId);
5768
5769 qPos.add(status);
5770
5771 count = (Long)q.uniqueResult();
5772 }
5773 catch (Exception e) {
5774 throw processException(e);
5775 }
5776 finally {
5777 if (count == null) {
5778 count = Long.valueOf(0);
5779 }
5780
5781 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_S, finderArgs,
5782 count);
5783
5784 closeSession(session);
5785 }
5786 }
5787
5788 return count.intValue();
5789 }
5790
5791
5799 public int countByH_P(boolean head, long plid) throws SystemException {
5800 Object[] finderArgs = new Object[] { head, plid };
5801
5802 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_H_P,
5803 finderArgs, this);
5804
5805 if (count == null) {
5806 StringBundler query = new StringBundler(3);
5807
5808 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5809
5810 query.append(_FINDER_COLUMN_H_P_HEAD_2);
5811
5812 query.append(_FINDER_COLUMN_H_P_PLID_2);
5813
5814 String sql = query.toString();
5815
5816 Session session = null;
5817
5818 try {
5819 session = openSession();
5820
5821 Query q = session.createQuery(sql);
5822
5823 QueryPos qPos = QueryPos.getInstance(q);
5824
5825 qPos.add(head);
5826
5827 qPos.add(plid);
5828
5829 count = (Long)q.uniqueResult();
5830 }
5831 catch (Exception e) {
5832 throw processException(e);
5833 }
5834 finally {
5835 if (count == null) {
5836 count = Long.valueOf(0);
5837 }
5838
5839 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_H_P, finderArgs,
5840 count);
5841
5842 closeSession(session);
5843 }
5844 }
5845
5846 return count.intValue();
5847 }
5848
5849
5857 public int countByP_NotS(long plid, int status) throws SystemException {
5858 Object[] finderArgs = new Object[] { plid, status };
5859
5860 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS,
5861 finderArgs, this);
5862
5863 if (count == null) {
5864 StringBundler query = new StringBundler(3);
5865
5866 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5867
5868 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
5869
5870 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
5871
5872 String sql = query.toString();
5873
5874 Session session = null;
5875
5876 try {
5877 session = openSession();
5878
5879 Query q = session.createQuery(sql);
5880
5881 QueryPos qPos = QueryPos.getInstance(q);
5882
5883 qPos.add(plid);
5884
5885 qPos.add(status);
5886
5887 count = (Long)q.uniqueResult();
5888 }
5889 catch (Exception e) {
5890 throw processException(e);
5891 }
5892 finally {
5893 if (count == null) {
5894 count = Long.valueOf(0);
5895 }
5896
5897 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS,
5898 finderArgs, count);
5899
5900 closeSession(session);
5901 }
5902 }
5903
5904 return count.intValue();
5905 }
5906
5907
5916 public int countByL_L_P(long layoutSetBranchId, long layoutBranchId,
5917 long plid) throws SystemException {
5918 Object[] finderArgs = new Object[] {
5919 layoutSetBranchId, layoutBranchId, plid
5920 };
5921
5922 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_L_P,
5923 finderArgs, this);
5924
5925 if (count == null) {
5926 StringBundler query = new StringBundler(4);
5927
5928 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5929
5930 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
5931
5932 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
5933
5934 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
5935
5936 String sql = query.toString();
5937
5938 Session session = null;
5939
5940 try {
5941 session = openSession();
5942
5943 Query q = session.createQuery(sql);
5944
5945 QueryPos qPos = QueryPos.getInstance(q);
5946
5947 qPos.add(layoutSetBranchId);
5948
5949 qPos.add(layoutBranchId);
5950
5951 qPos.add(plid);
5952
5953 count = (Long)q.uniqueResult();
5954 }
5955 catch (Exception e) {
5956 throw processException(e);
5957 }
5958 finally {
5959 if (count == null) {
5960 count = Long.valueOf(0);
5961 }
5962
5963 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_L_P,
5964 finderArgs, count);
5965
5966 closeSession(session);
5967 }
5968 }
5969
5970 return count.intValue();
5971 }
5972
5973
5982 public int countByL_P_P(long layoutSetBranchId,
5983 long parentLayoutRevisionId, long plid) throws SystemException {
5984 Object[] finderArgs = new Object[] {
5985 layoutSetBranchId, parentLayoutRevisionId, plid
5986 };
5987
5988 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_P,
5989 finderArgs, this);
5990
5991 if (count == null) {
5992 StringBundler query = new StringBundler(4);
5993
5994 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5995
5996 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
5997
5998 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
5999
6000 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
6001
6002 String sql = query.toString();
6003
6004 Session session = null;
6005
6006 try {
6007 session = openSession();
6008
6009 Query q = session.createQuery(sql);
6010
6011 QueryPos qPos = QueryPos.getInstance(q);
6012
6013 qPos.add(layoutSetBranchId);
6014
6015 qPos.add(parentLayoutRevisionId);
6016
6017 qPos.add(plid);
6018
6019 count = (Long)q.uniqueResult();
6020 }
6021 catch (Exception e) {
6022 throw processException(e);
6023 }
6024 finally {
6025 if (count == null) {
6026 count = Long.valueOf(0);
6027 }
6028
6029 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_P,
6030 finderArgs, count);
6031
6032 closeSession(session);
6033 }
6034 }
6035
6036 return count.intValue();
6037 }
6038
6039
6048 public int countByL_H_P(long layoutSetBranchId, boolean head, long plid)
6049 throws SystemException {
6050 Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
6051
6052 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_H_P,
6053 finderArgs, this);
6054
6055 if (count == null) {
6056 StringBundler query = new StringBundler(4);
6057
6058 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6059
6060 query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
6061
6062 query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
6063
6064 query.append(_FINDER_COLUMN_L_H_P_PLID_2);
6065
6066 String sql = query.toString();
6067
6068 Session session = null;
6069
6070 try {
6071 session = openSession();
6072
6073 Query q = session.createQuery(sql);
6074
6075 QueryPos qPos = QueryPos.getInstance(q);
6076
6077 qPos.add(layoutSetBranchId);
6078
6079 qPos.add(head);
6080
6081 qPos.add(plid);
6082
6083 count = (Long)q.uniqueResult();
6084 }
6085 catch (Exception e) {
6086 throw processException(e);
6087 }
6088 finally {
6089 if (count == null) {
6090 count = Long.valueOf(0);
6091 }
6092
6093 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H_P,
6094 finderArgs, count);
6095
6096 closeSession(session);
6097 }
6098 }
6099
6100 return count.intValue();
6101 }
6102
6103
6112 public int countByL_P_S(long layoutSetBranchId, long plid, int status)
6113 throws SystemException {
6114 Object[] finderArgs = new Object[] { layoutSetBranchId, plid, status };
6115
6116 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P_S,
6117 finderArgs, this);
6118
6119 if (count == null) {
6120 StringBundler query = new StringBundler(4);
6121
6122 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
6123
6124 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
6125
6126 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
6127
6128 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
6129
6130 String sql = query.toString();
6131
6132 Session session = null;
6133
6134 try {
6135 session = openSession();
6136
6137 Query q = session.createQuery(sql);
6138
6139 QueryPos qPos = QueryPos.getInstance(q);
6140
6141 qPos.add(layoutSetBranchId);
6142
6143 qPos.add(plid);
6144
6145 qPos.add(status);
6146
6147 count = (Long)q.uniqueResult();
6148 }
6149 catch (Exception e) {
6150 throw processException(e);
6151 }
6152 finally {
6153 if (count == null) {
6154 count = Long.valueOf(0);
6155 }
6156
6157 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P_S,
6158 finderArgs, count);
6159
6160 closeSession(session);
6161 }
6162 }
6163
6164 return count.intValue();
6165 }
6166
6167
6173 public int countAll() throws SystemException {
6174 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
6175 FINDER_ARGS_EMPTY, this);
6176
6177 if (count == null) {
6178 Session session = null;
6179
6180 try {
6181 session = openSession();
6182
6183 Query q = session.createQuery(_SQL_COUNT_LAYOUTREVISION);
6184
6185 count = (Long)q.uniqueResult();
6186 }
6187 catch (Exception e) {
6188 throw processException(e);
6189 }
6190 finally {
6191 if (count == null) {
6192 count = Long.valueOf(0);
6193 }
6194
6195 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
6196 FINDER_ARGS_EMPTY, count);
6197
6198 closeSession(session);
6199 }
6200 }
6201
6202 return count.intValue();
6203 }
6204
6205
6208 public void afterPropertiesSet() {
6209 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6210 com.liferay.portal.util.PropsUtil.get(
6211 "value.object.listener.com.liferay.portal.model.LayoutRevision")));
6212
6213 if (listenerClassNames.length > 0) {
6214 try {
6215 List<ModelListener<LayoutRevision>> listenersList = new ArrayList<ModelListener<LayoutRevision>>();
6216
6217 for (String listenerClassName : listenerClassNames) {
6218 listenersList.add((ModelListener<LayoutRevision>)InstanceFactory.newInstance(
6219 listenerClassName));
6220 }
6221
6222 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6223 }
6224 catch (Exception e) {
6225 _log.error(e);
6226 }
6227 }
6228 }
6229
6230 public void destroy() {
6231 EntityCacheUtil.removeCache(LayoutRevisionImpl.class.getName());
6232 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6233 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6234 }
6235
6236 @BeanReference(type = AccountPersistence.class)
6237 protected AccountPersistence accountPersistence;
6238 @BeanReference(type = AddressPersistence.class)
6239 protected AddressPersistence addressPersistence;
6240 @BeanReference(type = BrowserTrackerPersistence.class)
6241 protected BrowserTrackerPersistence browserTrackerPersistence;
6242 @BeanReference(type = ClassNamePersistence.class)
6243 protected ClassNamePersistence classNamePersistence;
6244 @BeanReference(type = ClusterGroupPersistence.class)
6245 protected ClusterGroupPersistence clusterGroupPersistence;
6246 @BeanReference(type = CompanyPersistence.class)
6247 protected CompanyPersistence companyPersistence;
6248 @BeanReference(type = ContactPersistence.class)
6249 protected ContactPersistence contactPersistence;
6250 @BeanReference(type = CountryPersistence.class)
6251 protected CountryPersistence countryPersistence;
6252 @BeanReference(type = EmailAddressPersistence.class)
6253 protected EmailAddressPersistence emailAddressPersistence;
6254 @BeanReference(type = GroupPersistence.class)
6255 protected GroupPersistence groupPersistence;
6256 @BeanReference(type = ImagePersistence.class)
6257 protected ImagePersistence imagePersistence;
6258 @BeanReference(type = LayoutPersistence.class)
6259 protected LayoutPersistence layoutPersistence;
6260 @BeanReference(type = LayoutBranchPersistence.class)
6261 protected LayoutBranchPersistence layoutBranchPersistence;
6262 @BeanReference(type = LayoutPrototypePersistence.class)
6263 protected LayoutPrototypePersistence layoutPrototypePersistence;
6264 @BeanReference(type = LayoutRevisionPersistence.class)
6265 protected LayoutRevisionPersistence layoutRevisionPersistence;
6266 @BeanReference(type = LayoutSetPersistence.class)
6267 protected LayoutSetPersistence layoutSetPersistence;
6268 @BeanReference(type = LayoutSetBranchPersistence.class)
6269 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6270 @BeanReference(type = LayoutSetPrototypePersistence.class)
6271 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6272 @BeanReference(type = ListTypePersistence.class)
6273 protected ListTypePersistence listTypePersistence;
6274 @BeanReference(type = LockPersistence.class)
6275 protected LockPersistence lockPersistence;
6276 @BeanReference(type = MembershipRequestPersistence.class)
6277 protected MembershipRequestPersistence membershipRequestPersistence;
6278 @BeanReference(type = OrganizationPersistence.class)
6279 protected OrganizationPersistence organizationPersistence;
6280 @BeanReference(type = OrgGroupPermissionPersistence.class)
6281 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
6282 @BeanReference(type = OrgGroupRolePersistence.class)
6283 protected OrgGroupRolePersistence orgGroupRolePersistence;
6284 @BeanReference(type = OrgLaborPersistence.class)
6285 protected OrgLaborPersistence orgLaborPersistence;
6286 @BeanReference(type = PasswordPolicyPersistence.class)
6287 protected PasswordPolicyPersistence passwordPolicyPersistence;
6288 @BeanReference(type = PasswordPolicyRelPersistence.class)
6289 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6290 @BeanReference(type = PasswordTrackerPersistence.class)
6291 protected PasswordTrackerPersistence passwordTrackerPersistence;
6292 @BeanReference(type = PermissionPersistence.class)
6293 protected PermissionPersistence permissionPersistence;
6294 @BeanReference(type = PhonePersistence.class)
6295 protected PhonePersistence phonePersistence;
6296 @BeanReference(type = PluginSettingPersistence.class)
6297 protected PluginSettingPersistence pluginSettingPersistence;
6298 @BeanReference(type = PortalPreferencesPersistence.class)
6299 protected PortalPreferencesPersistence portalPreferencesPersistence;
6300 @BeanReference(type = PortletPersistence.class)
6301 protected PortletPersistence portletPersistence;
6302 @BeanReference(type = PortletItemPersistence.class)
6303 protected PortletItemPersistence portletItemPersistence;
6304 @BeanReference(type = PortletPreferencesPersistence.class)
6305 protected PortletPreferencesPersistence portletPreferencesPersistence;
6306 @BeanReference(type = RegionPersistence.class)
6307 protected RegionPersistence regionPersistence;
6308 @BeanReference(type = ReleasePersistence.class)
6309 protected ReleasePersistence releasePersistence;
6310 @BeanReference(type = RepositoryPersistence.class)
6311 protected RepositoryPersistence repositoryPersistence;
6312 @BeanReference(type = RepositoryEntryPersistence.class)
6313 protected RepositoryEntryPersistence repositoryEntryPersistence;
6314 @BeanReference(type = ResourcePersistence.class)
6315 protected ResourcePersistence resourcePersistence;
6316 @BeanReference(type = ResourceActionPersistence.class)
6317 protected ResourceActionPersistence resourceActionPersistence;
6318 @BeanReference(type = ResourceBlockPersistence.class)
6319 protected ResourceBlockPersistence resourceBlockPersistence;
6320 @BeanReference(type = ResourceBlockPermissionPersistence.class)
6321 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6322 @BeanReference(type = ResourceCodePersistence.class)
6323 protected ResourceCodePersistence resourceCodePersistence;
6324 @BeanReference(type = ResourcePermissionPersistence.class)
6325 protected ResourcePermissionPersistence resourcePermissionPersistence;
6326 @BeanReference(type = ResourceTypePermissionPersistence.class)
6327 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6328 @BeanReference(type = RolePersistence.class)
6329 protected RolePersistence rolePersistence;
6330 @BeanReference(type = ServiceComponentPersistence.class)
6331 protected ServiceComponentPersistence serviceComponentPersistence;
6332 @BeanReference(type = ShardPersistence.class)
6333 protected ShardPersistence shardPersistence;
6334 @BeanReference(type = SubscriptionPersistence.class)
6335 protected SubscriptionPersistence subscriptionPersistence;
6336 @BeanReference(type = TeamPersistence.class)
6337 protected TeamPersistence teamPersistence;
6338 @BeanReference(type = TicketPersistence.class)
6339 protected TicketPersistence ticketPersistence;
6340 @BeanReference(type = UserPersistence.class)
6341 protected UserPersistence userPersistence;
6342 @BeanReference(type = UserGroupPersistence.class)
6343 protected UserGroupPersistence userGroupPersistence;
6344 @BeanReference(type = UserGroupGroupRolePersistence.class)
6345 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6346 @BeanReference(type = UserGroupRolePersistence.class)
6347 protected UserGroupRolePersistence userGroupRolePersistence;
6348 @BeanReference(type = UserIdMapperPersistence.class)
6349 protected UserIdMapperPersistence userIdMapperPersistence;
6350 @BeanReference(type = UserNotificationEventPersistence.class)
6351 protected UserNotificationEventPersistence userNotificationEventPersistence;
6352 @BeanReference(type = UserTrackerPersistence.class)
6353 protected UserTrackerPersistence userTrackerPersistence;
6354 @BeanReference(type = UserTrackerPathPersistence.class)
6355 protected UserTrackerPathPersistence userTrackerPathPersistence;
6356 @BeanReference(type = VirtualHostPersistence.class)
6357 protected VirtualHostPersistence virtualHostPersistence;
6358 @BeanReference(type = WebDAVPropsPersistence.class)
6359 protected WebDAVPropsPersistence webDAVPropsPersistence;
6360 @BeanReference(type = WebsitePersistence.class)
6361 protected WebsitePersistence websitePersistence;
6362 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6363 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6364 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6365 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6366 private static final String _SQL_SELECT_LAYOUTREVISION = "SELECT layoutRevision FROM LayoutRevision layoutRevision";
6367 private static final String _SQL_SELECT_LAYOUTREVISION_WHERE = "SELECT layoutRevision FROM LayoutRevision layoutRevision WHERE ";
6368 private static final String _SQL_COUNT_LAYOUTREVISION = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision";
6369 private static final String _SQL_COUNT_LAYOUTREVISION_WHERE = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision WHERE ";
6370 private static final String _FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2 =
6371 "layoutRevision.layoutSetBranchId = ?";
6372 private static final String _FINDER_COLUMN_PLID_PLID_2 = "layoutRevision.plid = ?";
6373 private static final String _FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6374 private static final String _FINDER_COLUMN_L_H_HEAD_2 = "layoutRevision.head = ?";
6375 private static final String _FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6376 private static final String _FINDER_COLUMN_L_P_PLID_2 = "layoutRevision.plid = ?";
6377 private static final String _FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6378 private static final String _FINDER_COLUMN_L_S_STATUS_2 = "layoutRevision.status = ?";
6379 private static final String _FINDER_COLUMN_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
6380 private static final String _FINDER_COLUMN_H_P_PLID_2 = "layoutRevision.plid = ?";
6381 private static final String _FINDER_COLUMN_P_NOTS_PLID_2 = "layoutRevision.plid = ? AND ";
6382 private static final String _FINDER_COLUMN_P_NOTS_STATUS_2 = "layoutRevision.status != ?";
6383 private static final String _FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6384 private static final String _FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2 = "layoutRevision.layoutBranchId = ? AND ";
6385 private static final String _FINDER_COLUMN_L_L_P_PLID_2 = "layoutRevision.plid = ? AND layoutRevision.status != 5";
6386 private static final String _FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6387 private static final String _FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2 = "layoutRevision.parentLayoutRevisionId = ? AND ";
6388 private static final String _FINDER_COLUMN_L_P_P_PLID_2 = "layoutRevision.plid = ?";
6389 private static final String _FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6390 private static final String _FINDER_COLUMN_L_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
6391 private static final String _FINDER_COLUMN_L_H_P_PLID_2 = "layoutRevision.plid = ?";
6392 private static final String _FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
6393 private static final String _FINDER_COLUMN_L_P_S_PLID_2 = "layoutRevision.plid = ? AND ";
6394 private static final String _FINDER_COLUMN_L_P_S_STATUS_2 = "layoutRevision.status = ?";
6395 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutRevision.";
6396 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutRevision exists with the primary key ";
6397 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutRevision exists with the key {";
6398 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6399 private static Log _log = LogFactoryUtil.getLog(LayoutRevisionPersistenceImpl.class);
6400 private static LayoutRevision _nullLayoutRevision = new LayoutRevisionImpl() {
6401 @Override
6402 public Object clone() {
6403 return this;
6404 }
6405
6406 @Override
6407 public CacheModel<LayoutRevision> toCacheModel() {
6408 return _nullLayoutRevisionCacheModel;
6409 }
6410 };
6411
6412 private static CacheModel<LayoutRevision> _nullLayoutRevisionCacheModel = new CacheModel<LayoutRevision>() {
6413 public LayoutRevision toEntityModel() {
6414 return _nullLayoutRevision;
6415 }
6416 };
6417 }