001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042 import com.liferay.portal.service.persistence.BatchSessionUtil;
043 import com.liferay.portal.service.persistence.GroupPersistence;
044 import com.liferay.portal.service.persistence.ResourcePersistence;
045 import com.liferay.portal.service.persistence.UserPersistence;
046 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
050 import com.liferay.portlet.journal.NoSuchStructureException;
051 import com.liferay.portlet.journal.model.JournalStructure;
052 import com.liferay.portlet.journal.model.impl.JournalStructureImpl;
053 import com.liferay.portlet.journal.model.impl.JournalStructureModelImpl;
054
055 import java.io.Serializable;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.List;
060
061
073 public class JournalStructurePersistenceImpl extends BasePersistenceImpl<JournalStructure>
074 implements JournalStructurePersistence {
075
080 public static final String FINDER_CLASS_NAME_ENTITY = JournalStructureImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List1";
083 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List2";
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
086 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
087 JournalStructureImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
088 "findByUuid",
089 new String[] {
090 String.class.getName(),
091
092 "java.lang.Integer", "java.lang.Integer",
093 "com.liferay.portal.kernel.util.OrderByComparator"
094 });
095 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
096 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
097 JournalStructureImpl.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
099 new String[] { String.class.getName() },
100 JournalStructureModelImpl.UUID_COLUMN_BITMASK);
101 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
102 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
104 new String[] { String.class.getName() });
105 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
106 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
107 JournalStructureImpl.class, FINDER_CLASS_NAME_ENTITY,
108 "fetchByUUID_G",
109 new String[] { String.class.getName(), Long.class.getName() },
110 JournalStructureModelImpl.UUID_COLUMN_BITMASK |
111 JournalStructureModelImpl.GROUPID_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
113 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
115 new String[] { String.class.getName(), Long.class.getName() });
116 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
117 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
118 JournalStructureImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
119 "findByGroupId",
120 new String[] {
121 Long.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_GROUPID =
127 new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
128 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
129 JournalStructureImpl.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
131 new String[] { Long.class.getName() },
132 JournalStructureModelImpl.GROUPID_COLUMN_BITMASK);
133 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
134 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
136 new String[] { Long.class.getName() });
137 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
138 new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
139 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
140 JournalStructureImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
141 "findByStructureId",
142 new String[] {
143 String.class.getName(),
144
145 "java.lang.Integer", "java.lang.Integer",
146 "com.liferay.portal.kernel.util.OrderByComparator"
147 });
148 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
149 new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
150 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
151 JournalStructureImpl.class,
152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
153 new String[] { String.class.getName() },
154 JournalStructureModelImpl.STRUCTUREID_COLUMN_BITMASK);
155 public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
156 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
158 new String[] { String.class.getName() });
159 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTSTRUCTUREID =
160 new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
161 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
162 JournalStructureImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
163 "findByParentStructureId",
164 new String[] {
165 String.class.getName(),
166
167 "java.lang.Integer", "java.lang.Integer",
168 "com.liferay.portal.kernel.util.OrderByComparator"
169 });
170 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID =
171 new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
172 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
173 JournalStructureImpl.class,
174 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
175 "findByParentStructureId", new String[] { String.class.getName() },
176 JournalStructureModelImpl.PARENTSTRUCTUREID_COLUMN_BITMASK);
177 public static final FinderPath FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
178 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
179 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
180 "countByParentStructureId", new String[] { String.class.getName() });
181 public static final FinderPath FINDER_PATH_FETCH_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
182 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
183 JournalStructureImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_S",
184 new String[] { Long.class.getName(), String.class.getName() },
185 JournalStructureModelImpl.GROUPID_COLUMN_BITMASK |
186 JournalStructureModelImpl.STRUCTUREID_COLUMN_BITMASK);
187 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
188 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
189 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
190 new String[] { Long.class.getName(), String.class.getName() });
191 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
192 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
193 JournalStructureImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
194 "findByG_P",
195 new String[] {
196 Long.class.getName(), String.class.getName(),
197
198 "java.lang.Integer", "java.lang.Integer",
199 "com.liferay.portal.kernel.util.OrderByComparator"
200 });
201 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
202 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
203 JournalStructureImpl.class,
204 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
205 new String[] { Long.class.getName(), String.class.getName() },
206 JournalStructureModelImpl.GROUPID_COLUMN_BITMASK |
207 JournalStructureModelImpl.PARENTSTRUCTUREID_COLUMN_BITMASK);
208 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
209 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
210 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
211 new String[] { Long.class.getName(), String.class.getName() });
212 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
213 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
214 JournalStructureImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
215 "findAll", new String[0]);
216 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
217 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
218 JournalStructureImpl.class,
219 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
220 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
221 JournalStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
222 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
223
224
229 public void cacheResult(JournalStructure journalStructure) {
230 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
231 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
232 journalStructure);
233
234 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
235 new Object[] {
236 journalStructure.getUuid(),
237 Long.valueOf(journalStructure.getGroupId())
238 }, journalStructure);
239
240 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
241 new Object[] {
242 Long.valueOf(journalStructure.getGroupId()),
243
244 journalStructure.getStructureId()
245 }, journalStructure);
246
247 journalStructure.resetOriginalValues();
248 }
249
250
255 public void cacheResult(List<JournalStructure> journalStructures) {
256 for (JournalStructure journalStructure : journalStructures) {
257 if (EntityCacheUtil.getResult(
258 JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
259 JournalStructureImpl.class,
260 journalStructure.getPrimaryKey()) == null) {
261 cacheResult(journalStructure);
262 }
263 else {
264 journalStructure.resetOriginalValues();
265 }
266 }
267 }
268
269
276 @Override
277 public void clearCache() {
278 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
279 CacheRegistryUtil.clear(JournalStructureImpl.class.getName());
280 }
281
282 EntityCacheUtil.clearCache(JournalStructureImpl.class.getName());
283
284 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
285 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
286 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
287 }
288
289
296 @Override
297 public void clearCache(JournalStructure journalStructure) {
298 EntityCacheUtil.removeResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
299 JournalStructureImpl.class, journalStructure.getPrimaryKey());
300
301 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
302 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
303
304 clearUniqueFindersCache(journalStructure);
305 }
306
307 @Override
308 public void clearCache(List<JournalStructure> journalStructures) {
309 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
310 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
311
312 for (JournalStructure journalStructure : journalStructures) {
313 EntityCacheUtil.removeResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
314 JournalStructureImpl.class, journalStructure.getPrimaryKey());
315
316 clearUniqueFindersCache(journalStructure);
317 }
318 }
319
320 protected void cacheUniqueFindersCache(JournalStructure journalStructure) {
321 if (journalStructure.isNew()) {
322 Object[] args = new Object[] {
323 journalStructure.getUuid(),
324 Long.valueOf(journalStructure.getGroupId())
325 };
326
327 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
328 Long.valueOf(1));
329 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
330 journalStructure);
331
332 args = new Object[] {
333 Long.valueOf(journalStructure.getGroupId()),
334
335 journalStructure.getStructureId()
336 };
337
338 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, args,
339 Long.valueOf(1));
340 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S, args,
341 journalStructure);
342 }
343 else {
344 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
345
346 if ((journalStructureModelImpl.getColumnBitmask() &
347 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
348 Object[] args = new Object[] {
349 journalStructure.getUuid(),
350 Long.valueOf(journalStructure.getGroupId())
351 };
352
353 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
354 Long.valueOf(1));
355 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
356 journalStructure);
357 }
358
359 if ((journalStructureModelImpl.getColumnBitmask() &
360 FINDER_PATH_FETCH_BY_G_S.getColumnBitmask()) != 0) {
361 Object[] args = new Object[] {
362 Long.valueOf(journalStructure.getGroupId()),
363
364 journalStructure.getStructureId()
365 };
366
367 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, args,
368 Long.valueOf(1));
369 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S, args,
370 journalStructure);
371 }
372 }
373 }
374
375 protected void clearUniqueFindersCache(JournalStructure journalStructure) {
376 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
377
378 Object[] args = new Object[] {
379 journalStructure.getUuid(),
380 Long.valueOf(journalStructure.getGroupId())
381 };
382
383 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
384 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
385
386 if ((journalStructureModelImpl.getColumnBitmask() &
387 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
388 args = new Object[] {
389 journalStructureModelImpl.getOriginalUuid(),
390 Long.valueOf(journalStructureModelImpl.getOriginalGroupId())
391 };
392
393 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
394 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
395 }
396
397 args = new Object[] {
398 Long.valueOf(journalStructure.getGroupId()),
399
400 journalStructure.getStructureId()
401 };
402
403 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
404 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S, args);
405
406 if ((journalStructureModelImpl.getColumnBitmask() &
407 FINDER_PATH_FETCH_BY_G_S.getColumnBitmask()) != 0) {
408 args = new Object[] {
409 Long.valueOf(journalStructureModelImpl.getOriginalGroupId()),
410
411 journalStructureModelImpl.getOriginalStructureId()
412 };
413
414 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
415 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S, args);
416 }
417 }
418
419
425 public JournalStructure create(long id) {
426 JournalStructure journalStructure = new JournalStructureImpl();
427
428 journalStructure.setNew(true);
429 journalStructure.setPrimaryKey(id);
430
431 String uuid = PortalUUIDUtil.generate();
432
433 journalStructure.setUuid(uuid);
434
435 return journalStructure;
436 }
437
438
446 public JournalStructure remove(long id)
447 throws NoSuchStructureException, SystemException {
448 return remove(Long.valueOf(id));
449 }
450
451
459 @Override
460 public JournalStructure remove(Serializable primaryKey)
461 throws NoSuchStructureException, SystemException {
462 Session session = null;
463
464 try {
465 session = openSession();
466
467 JournalStructure journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
468 primaryKey);
469
470 if (journalStructure == null) {
471 if (_log.isWarnEnabled()) {
472 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
473 }
474
475 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
476 primaryKey);
477 }
478
479 return remove(journalStructure);
480 }
481 catch (NoSuchStructureException nsee) {
482 throw nsee;
483 }
484 catch (Exception e) {
485 throw processException(e);
486 }
487 finally {
488 closeSession(session);
489 }
490 }
491
492 @Override
493 protected JournalStructure removeImpl(JournalStructure journalStructure)
494 throws SystemException {
495 journalStructure = toUnwrappedModel(journalStructure);
496
497 Session session = null;
498
499 try {
500 session = openSession();
501
502 BatchSessionUtil.delete(session, journalStructure);
503 }
504 catch (Exception e) {
505 throw processException(e);
506 }
507 finally {
508 closeSession(session);
509 }
510
511 clearCache(journalStructure);
512
513 return journalStructure;
514 }
515
516 @Override
517 public JournalStructure updateImpl(
518 com.liferay.portlet.journal.model.JournalStructure journalStructure,
519 boolean merge) throws SystemException {
520 journalStructure = toUnwrappedModel(journalStructure);
521
522 boolean isNew = journalStructure.isNew();
523
524 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
525
526 if (Validator.isNull(journalStructure.getUuid())) {
527 String uuid = PortalUUIDUtil.generate();
528
529 journalStructure.setUuid(uuid);
530 }
531
532 Session session = null;
533
534 try {
535 session = openSession();
536
537 BatchSessionUtil.update(session, journalStructure, merge);
538
539 journalStructure.setNew(false);
540 }
541 catch (Exception e) {
542 throw processException(e);
543 }
544 finally {
545 closeSession(session);
546 }
547
548 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
549
550 if (isNew || !JournalStructureModelImpl.COLUMN_BITMASK_ENABLED) {
551 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
552 }
553
554 else {
555 if ((journalStructureModelImpl.getColumnBitmask() &
556 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
557 Object[] args = new Object[] {
558 journalStructureModelImpl.getOriginalUuid()
559 };
560
561 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
562 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
563 args);
564
565 args = new Object[] { journalStructureModelImpl.getUuid() };
566
567 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
568 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
569 args);
570 }
571
572 if ((journalStructureModelImpl.getColumnBitmask() &
573 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
574 Object[] args = new Object[] {
575 Long.valueOf(journalStructureModelImpl.getOriginalGroupId())
576 };
577
578 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
579 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
580 args);
581
582 args = new Object[] {
583 Long.valueOf(journalStructureModelImpl.getGroupId())
584 };
585
586 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
587 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
588 args);
589 }
590
591 if ((journalStructureModelImpl.getColumnBitmask() &
592 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
593 Object[] args = new Object[] {
594 journalStructureModelImpl.getOriginalStructureId()
595 };
596
597 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
598 args);
599 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
600 args);
601
602 args = new Object[] { journalStructureModelImpl.getStructureId() };
603
604 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
605 args);
606 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
607 args);
608 }
609
610 if ((journalStructureModelImpl.getColumnBitmask() &
611 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID.getColumnBitmask()) != 0) {
612 Object[] args = new Object[] {
613 journalStructureModelImpl.getOriginalParentStructureId()
614 };
615
616 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID,
617 args);
618 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID,
619 args);
620
621 args = new Object[] {
622 journalStructureModelImpl.getParentStructureId()
623 };
624
625 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID,
626 args);
627 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID,
628 args);
629 }
630
631 if ((journalStructureModelImpl.getColumnBitmask() &
632 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
633 Object[] args = new Object[] {
634 Long.valueOf(journalStructureModelImpl.getOriginalGroupId()),
635
636 journalStructureModelImpl.getOriginalParentStructureId()
637 };
638
639 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
640 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
641 args);
642
643 args = new Object[] {
644 Long.valueOf(journalStructureModelImpl.getGroupId()),
645
646 journalStructureModelImpl.getParentStructureId()
647 };
648
649 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
650 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
651 args);
652 }
653 }
654
655 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
656 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
657 journalStructure);
658
659 clearUniqueFindersCache(journalStructure);
660 cacheUniqueFindersCache(journalStructure);
661
662 return journalStructure;
663 }
664
665 protected JournalStructure toUnwrappedModel(
666 JournalStructure journalStructure) {
667 if (journalStructure instanceof JournalStructureImpl) {
668 return journalStructure;
669 }
670
671 JournalStructureImpl journalStructureImpl = new JournalStructureImpl();
672
673 journalStructureImpl.setNew(journalStructure.isNew());
674 journalStructureImpl.setPrimaryKey(journalStructure.getPrimaryKey());
675
676 journalStructureImpl.setUuid(journalStructure.getUuid());
677 journalStructureImpl.setId(journalStructure.getId());
678 journalStructureImpl.setGroupId(journalStructure.getGroupId());
679 journalStructureImpl.setCompanyId(journalStructure.getCompanyId());
680 journalStructureImpl.setUserId(journalStructure.getUserId());
681 journalStructureImpl.setUserName(journalStructure.getUserName());
682 journalStructureImpl.setCreateDate(journalStructure.getCreateDate());
683 journalStructureImpl.setModifiedDate(journalStructure.getModifiedDate());
684 journalStructureImpl.setStructureId(journalStructure.getStructureId());
685 journalStructureImpl.setParentStructureId(journalStructure.getParentStructureId());
686 journalStructureImpl.setName(journalStructure.getName());
687 journalStructureImpl.setDescription(journalStructure.getDescription());
688 journalStructureImpl.setXsd(journalStructure.getXsd());
689
690 return journalStructureImpl;
691 }
692
693
701 @Override
702 public JournalStructure findByPrimaryKey(Serializable primaryKey)
703 throws NoSuchModelException, SystemException {
704 return findByPrimaryKey(((Long)primaryKey).longValue());
705 }
706
707
715 public JournalStructure findByPrimaryKey(long id)
716 throws NoSuchStructureException, SystemException {
717 JournalStructure journalStructure = fetchByPrimaryKey(id);
718
719 if (journalStructure == null) {
720 if (_log.isWarnEnabled()) {
721 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
722 }
723
724 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
725 id);
726 }
727
728 return journalStructure;
729 }
730
731
738 @Override
739 public JournalStructure fetchByPrimaryKey(Serializable primaryKey)
740 throws SystemException {
741 return fetchByPrimaryKey(((Long)primaryKey).longValue());
742 }
743
744
751 public JournalStructure fetchByPrimaryKey(long id)
752 throws SystemException {
753 JournalStructure journalStructure = (JournalStructure)EntityCacheUtil.getResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
754 JournalStructureImpl.class, id);
755
756 if (journalStructure == _nullJournalStructure) {
757 return null;
758 }
759
760 if (journalStructure == null) {
761 Session session = null;
762
763 boolean hasException = false;
764
765 try {
766 session = openSession();
767
768 journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
769 Long.valueOf(id));
770 }
771 catch (Exception e) {
772 hasException = true;
773
774 throw processException(e);
775 }
776 finally {
777 if (journalStructure != null) {
778 cacheResult(journalStructure);
779 }
780 else if (!hasException) {
781 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
782 JournalStructureImpl.class, id, _nullJournalStructure);
783 }
784
785 closeSession(session);
786 }
787 }
788
789 return journalStructure;
790 }
791
792
799 public List<JournalStructure> findByUuid(String uuid)
800 throws SystemException {
801 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
802 }
803
804
817 public List<JournalStructure> findByUuid(String uuid, int start, int end)
818 throws SystemException {
819 return findByUuid(uuid, start, end, null);
820 }
821
822
836 public List<JournalStructure> findByUuid(String uuid, int start, int end,
837 OrderByComparator orderByComparator) throws SystemException {
838 FinderPath finderPath = null;
839 Object[] finderArgs = null;
840
841 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
842 (orderByComparator == null)) {
843 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
844 finderArgs = new Object[] { uuid };
845 }
846 else {
847 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
848 finderArgs = new Object[] { uuid, start, end, orderByComparator };
849 }
850
851 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(finderPath,
852 finderArgs, this);
853
854 if ((list != null) && !list.isEmpty()) {
855 for (JournalStructure journalStructure : list) {
856 if (!Validator.equals(uuid, journalStructure.getUuid())) {
857 list = null;
858
859 break;
860 }
861 }
862 }
863
864 if (list == null) {
865 StringBundler query = null;
866
867 if (orderByComparator != null) {
868 query = new StringBundler(3 +
869 (orderByComparator.getOrderByFields().length * 3));
870 }
871 else {
872 query = new StringBundler(3);
873 }
874
875 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
876
877 if (uuid == null) {
878 query.append(_FINDER_COLUMN_UUID_UUID_1);
879 }
880 else {
881 if (uuid.equals(StringPool.BLANK)) {
882 query.append(_FINDER_COLUMN_UUID_UUID_3);
883 }
884 else {
885 query.append(_FINDER_COLUMN_UUID_UUID_2);
886 }
887 }
888
889 if (orderByComparator != null) {
890 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
891 orderByComparator);
892 }
893
894 else {
895 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
896 }
897
898 String sql = query.toString();
899
900 Session session = null;
901
902 try {
903 session = openSession();
904
905 Query q = session.createQuery(sql);
906
907 QueryPos qPos = QueryPos.getInstance(q);
908
909 if (uuid != null) {
910 qPos.add(uuid);
911 }
912
913 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
914 start, end);
915 }
916 catch (Exception e) {
917 throw processException(e);
918 }
919 finally {
920 if (list == null) {
921 FinderCacheUtil.removeResult(finderPath, finderArgs);
922 }
923 else {
924 cacheResult(list);
925
926 FinderCacheUtil.putResult(finderPath, finderArgs, list);
927 }
928
929 closeSession(session);
930 }
931 }
932
933 return list;
934 }
935
936
945 public JournalStructure findByUuid_First(String uuid,
946 OrderByComparator orderByComparator)
947 throws NoSuchStructureException, SystemException {
948 JournalStructure journalStructure = fetchByUuid_First(uuid,
949 orderByComparator);
950
951 if (journalStructure != null) {
952 return journalStructure;
953 }
954
955 StringBundler msg = new StringBundler(4);
956
957 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
958
959 msg.append("uuid=");
960 msg.append(uuid);
961
962 msg.append(StringPool.CLOSE_CURLY_BRACE);
963
964 throw new NoSuchStructureException(msg.toString());
965 }
966
967
975 public JournalStructure fetchByUuid_First(String uuid,
976 OrderByComparator orderByComparator) throws SystemException {
977 List<JournalStructure> list = findByUuid(uuid, 0, 1, orderByComparator);
978
979 if (!list.isEmpty()) {
980 return list.get(0);
981 }
982
983 return null;
984 }
985
986
995 public JournalStructure findByUuid_Last(String uuid,
996 OrderByComparator orderByComparator)
997 throws NoSuchStructureException, SystemException {
998 JournalStructure journalStructure = fetchByUuid_Last(uuid,
999 orderByComparator);
1000
1001 if (journalStructure != null) {
1002 return journalStructure;
1003 }
1004
1005 StringBundler msg = new StringBundler(4);
1006
1007 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1008
1009 msg.append("uuid=");
1010 msg.append(uuid);
1011
1012 msg.append(StringPool.CLOSE_CURLY_BRACE);
1013
1014 throw new NoSuchStructureException(msg.toString());
1015 }
1016
1017
1025 public JournalStructure fetchByUuid_Last(String uuid,
1026 OrderByComparator orderByComparator) throws SystemException {
1027 int count = countByUuid(uuid);
1028
1029 List<JournalStructure> list = findByUuid(uuid, count - 1, count,
1030 orderByComparator);
1031
1032 if (!list.isEmpty()) {
1033 return list.get(0);
1034 }
1035
1036 return null;
1037 }
1038
1039
1049 public JournalStructure[] findByUuid_PrevAndNext(long id, String uuid,
1050 OrderByComparator orderByComparator)
1051 throws NoSuchStructureException, SystemException {
1052 JournalStructure journalStructure = findByPrimaryKey(id);
1053
1054 Session session = null;
1055
1056 try {
1057 session = openSession();
1058
1059 JournalStructure[] array = new JournalStructureImpl[3];
1060
1061 array[0] = getByUuid_PrevAndNext(session, journalStructure, uuid,
1062 orderByComparator, true);
1063
1064 array[1] = journalStructure;
1065
1066 array[2] = getByUuid_PrevAndNext(session, journalStructure, uuid,
1067 orderByComparator, false);
1068
1069 return array;
1070 }
1071 catch (Exception e) {
1072 throw processException(e);
1073 }
1074 finally {
1075 closeSession(session);
1076 }
1077 }
1078
1079 protected JournalStructure getByUuid_PrevAndNext(Session session,
1080 JournalStructure journalStructure, String uuid,
1081 OrderByComparator orderByComparator, boolean previous) {
1082 StringBundler query = null;
1083
1084 if (orderByComparator != null) {
1085 query = new StringBundler(6 +
1086 (orderByComparator.getOrderByFields().length * 6));
1087 }
1088 else {
1089 query = new StringBundler(3);
1090 }
1091
1092 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1093
1094 if (uuid == null) {
1095 query.append(_FINDER_COLUMN_UUID_UUID_1);
1096 }
1097 else {
1098 if (uuid.equals(StringPool.BLANK)) {
1099 query.append(_FINDER_COLUMN_UUID_UUID_3);
1100 }
1101 else {
1102 query.append(_FINDER_COLUMN_UUID_UUID_2);
1103 }
1104 }
1105
1106 if (orderByComparator != null) {
1107 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1108
1109 if (orderByConditionFields.length > 0) {
1110 query.append(WHERE_AND);
1111 }
1112
1113 for (int i = 0; i < orderByConditionFields.length; i++) {
1114 query.append(_ORDER_BY_ENTITY_ALIAS);
1115 query.append(orderByConditionFields[i]);
1116
1117 if ((i + 1) < orderByConditionFields.length) {
1118 if (orderByComparator.isAscending() ^ previous) {
1119 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1120 }
1121 else {
1122 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1123 }
1124 }
1125 else {
1126 if (orderByComparator.isAscending() ^ previous) {
1127 query.append(WHERE_GREATER_THAN);
1128 }
1129 else {
1130 query.append(WHERE_LESSER_THAN);
1131 }
1132 }
1133 }
1134
1135 query.append(ORDER_BY_CLAUSE);
1136
1137 String[] orderByFields = orderByComparator.getOrderByFields();
1138
1139 for (int i = 0; i < orderByFields.length; i++) {
1140 query.append(_ORDER_BY_ENTITY_ALIAS);
1141 query.append(orderByFields[i]);
1142
1143 if ((i + 1) < orderByFields.length) {
1144 if (orderByComparator.isAscending() ^ previous) {
1145 query.append(ORDER_BY_ASC_HAS_NEXT);
1146 }
1147 else {
1148 query.append(ORDER_BY_DESC_HAS_NEXT);
1149 }
1150 }
1151 else {
1152 if (orderByComparator.isAscending() ^ previous) {
1153 query.append(ORDER_BY_ASC);
1154 }
1155 else {
1156 query.append(ORDER_BY_DESC);
1157 }
1158 }
1159 }
1160 }
1161
1162 else {
1163 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1164 }
1165
1166 String sql = query.toString();
1167
1168 Query q = session.createQuery(sql);
1169
1170 q.setFirstResult(0);
1171 q.setMaxResults(2);
1172
1173 QueryPos qPos = QueryPos.getInstance(q);
1174
1175 if (uuid != null) {
1176 qPos.add(uuid);
1177 }
1178
1179 if (orderByComparator != null) {
1180 Object[] values = orderByComparator.getOrderByConditionValues(journalStructure);
1181
1182 for (Object value : values) {
1183 qPos.add(value);
1184 }
1185 }
1186
1187 List<JournalStructure> list = q.list();
1188
1189 if (list.size() == 2) {
1190 return list.get(1);
1191 }
1192 else {
1193 return null;
1194 }
1195 }
1196
1197
1206 public JournalStructure findByUUID_G(String uuid, long groupId)
1207 throws NoSuchStructureException, SystemException {
1208 JournalStructure journalStructure = fetchByUUID_G(uuid, groupId);
1209
1210 if (journalStructure == null) {
1211 StringBundler msg = new StringBundler(6);
1212
1213 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1214
1215 msg.append("uuid=");
1216 msg.append(uuid);
1217
1218 msg.append(", groupId=");
1219 msg.append(groupId);
1220
1221 msg.append(StringPool.CLOSE_CURLY_BRACE);
1222
1223 if (_log.isWarnEnabled()) {
1224 _log.warn(msg.toString());
1225 }
1226
1227 throw new NoSuchStructureException(msg.toString());
1228 }
1229
1230 return journalStructure;
1231 }
1232
1233
1241 public JournalStructure fetchByUUID_G(String uuid, long groupId)
1242 throws SystemException {
1243 return fetchByUUID_G(uuid, groupId, true);
1244 }
1245
1246
1255 public JournalStructure fetchByUUID_G(String uuid, long groupId,
1256 boolean retrieveFromCache) throws SystemException {
1257 Object[] finderArgs = new Object[] { uuid, groupId };
1258
1259 Object result = null;
1260
1261 if (retrieveFromCache) {
1262 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1263 finderArgs, this);
1264 }
1265
1266 if (result instanceof JournalStructure) {
1267 JournalStructure journalStructure = (JournalStructure)result;
1268
1269 if (!Validator.equals(uuid, journalStructure.getUuid()) ||
1270 (groupId != journalStructure.getGroupId())) {
1271 result = null;
1272 }
1273 }
1274
1275 if (result == null) {
1276 StringBundler query = new StringBundler(4);
1277
1278 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1279
1280 if (uuid == null) {
1281 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1282 }
1283 else {
1284 if (uuid.equals(StringPool.BLANK)) {
1285 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1286 }
1287 else {
1288 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1289 }
1290 }
1291
1292 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1293
1294 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1295
1296 String sql = query.toString();
1297
1298 Session session = null;
1299
1300 try {
1301 session = openSession();
1302
1303 Query q = session.createQuery(sql);
1304
1305 QueryPos qPos = QueryPos.getInstance(q);
1306
1307 if (uuid != null) {
1308 qPos.add(uuid);
1309 }
1310
1311 qPos.add(groupId);
1312
1313 List<JournalStructure> list = q.list();
1314
1315 result = list;
1316
1317 JournalStructure journalStructure = null;
1318
1319 if (list.isEmpty()) {
1320 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1321 finderArgs, list);
1322 }
1323 else {
1324 journalStructure = list.get(0);
1325
1326 cacheResult(journalStructure);
1327
1328 if ((journalStructure.getUuid() == null) ||
1329 !journalStructure.getUuid().equals(uuid) ||
1330 (journalStructure.getGroupId() != groupId)) {
1331 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1332 finderArgs, journalStructure);
1333 }
1334 }
1335
1336 return journalStructure;
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 if (result == null) {
1343 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1344 finderArgs);
1345 }
1346
1347 closeSession(session);
1348 }
1349 }
1350 else {
1351 if (result instanceof List<?>) {
1352 return null;
1353 }
1354 else {
1355 return (JournalStructure)result;
1356 }
1357 }
1358 }
1359
1360
1367 public List<JournalStructure> findByGroupId(long groupId)
1368 throws SystemException {
1369 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1370 }
1371
1372
1385 public List<JournalStructure> findByGroupId(long groupId, int start, int end)
1386 throws SystemException {
1387 return findByGroupId(groupId, start, end, null);
1388 }
1389
1390
1404 public List<JournalStructure> findByGroupId(long groupId, int start,
1405 int end, OrderByComparator orderByComparator) throws SystemException {
1406 FinderPath finderPath = null;
1407 Object[] finderArgs = null;
1408
1409 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1410 (orderByComparator == null)) {
1411 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1412 finderArgs = new Object[] { groupId };
1413 }
1414 else {
1415 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1416 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1417 }
1418
1419 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(finderPath,
1420 finderArgs, this);
1421
1422 if ((list != null) && !list.isEmpty()) {
1423 for (JournalStructure journalStructure : list) {
1424 if ((groupId != journalStructure.getGroupId())) {
1425 list = null;
1426
1427 break;
1428 }
1429 }
1430 }
1431
1432 if (list == null) {
1433 StringBundler query = null;
1434
1435 if (orderByComparator != null) {
1436 query = new StringBundler(3 +
1437 (orderByComparator.getOrderByFields().length * 3));
1438 }
1439 else {
1440 query = new StringBundler(3);
1441 }
1442
1443 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1444
1445 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1446
1447 if (orderByComparator != null) {
1448 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1449 orderByComparator);
1450 }
1451
1452 else {
1453 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1454 }
1455
1456 String sql = query.toString();
1457
1458 Session session = null;
1459
1460 try {
1461 session = openSession();
1462
1463 Query q = session.createQuery(sql);
1464
1465 QueryPos qPos = QueryPos.getInstance(q);
1466
1467 qPos.add(groupId);
1468
1469 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1470 start, end);
1471 }
1472 catch (Exception e) {
1473 throw processException(e);
1474 }
1475 finally {
1476 if (list == null) {
1477 FinderCacheUtil.removeResult(finderPath, finderArgs);
1478 }
1479 else {
1480 cacheResult(list);
1481
1482 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1483 }
1484
1485 closeSession(session);
1486 }
1487 }
1488
1489 return list;
1490 }
1491
1492
1501 public JournalStructure findByGroupId_First(long groupId,
1502 OrderByComparator orderByComparator)
1503 throws NoSuchStructureException, SystemException {
1504 JournalStructure journalStructure = fetchByGroupId_First(groupId,
1505 orderByComparator);
1506
1507 if (journalStructure != null) {
1508 return journalStructure;
1509 }
1510
1511 StringBundler msg = new StringBundler(4);
1512
1513 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1514
1515 msg.append("groupId=");
1516 msg.append(groupId);
1517
1518 msg.append(StringPool.CLOSE_CURLY_BRACE);
1519
1520 throw new NoSuchStructureException(msg.toString());
1521 }
1522
1523
1531 public JournalStructure fetchByGroupId_First(long groupId,
1532 OrderByComparator orderByComparator) throws SystemException {
1533 List<JournalStructure> list = findByGroupId(groupId, 0, 1,
1534 orderByComparator);
1535
1536 if (!list.isEmpty()) {
1537 return list.get(0);
1538 }
1539
1540 return null;
1541 }
1542
1543
1552 public JournalStructure findByGroupId_Last(long groupId,
1553 OrderByComparator orderByComparator)
1554 throws NoSuchStructureException, SystemException {
1555 JournalStructure journalStructure = fetchByGroupId_Last(groupId,
1556 orderByComparator);
1557
1558 if (journalStructure != null) {
1559 return journalStructure;
1560 }
1561
1562 StringBundler msg = new StringBundler(4);
1563
1564 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1565
1566 msg.append("groupId=");
1567 msg.append(groupId);
1568
1569 msg.append(StringPool.CLOSE_CURLY_BRACE);
1570
1571 throw new NoSuchStructureException(msg.toString());
1572 }
1573
1574
1582 public JournalStructure fetchByGroupId_Last(long groupId,
1583 OrderByComparator orderByComparator) throws SystemException {
1584 int count = countByGroupId(groupId);
1585
1586 List<JournalStructure> list = findByGroupId(groupId, count - 1, count,
1587 orderByComparator);
1588
1589 if (!list.isEmpty()) {
1590 return list.get(0);
1591 }
1592
1593 return null;
1594 }
1595
1596
1606 public JournalStructure[] findByGroupId_PrevAndNext(long id, long groupId,
1607 OrderByComparator orderByComparator)
1608 throws NoSuchStructureException, SystemException {
1609 JournalStructure journalStructure = findByPrimaryKey(id);
1610
1611 Session session = null;
1612
1613 try {
1614 session = openSession();
1615
1616 JournalStructure[] array = new JournalStructureImpl[3];
1617
1618 array[0] = getByGroupId_PrevAndNext(session, journalStructure,
1619 groupId, orderByComparator, true);
1620
1621 array[1] = journalStructure;
1622
1623 array[2] = getByGroupId_PrevAndNext(session, journalStructure,
1624 groupId, orderByComparator, false);
1625
1626 return array;
1627 }
1628 catch (Exception e) {
1629 throw processException(e);
1630 }
1631 finally {
1632 closeSession(session);
1633 }
1634 }
1635
1636 protected JournalStructure getByGroupId_PrevAndNext(Session session,
1637 JournalStructure journalStructure, long groupId,
1638 OrderByComparator orderByComparator, boolean previous) {
1639 StringBundler query = null;
1640
1641 if (orderByComparator != null) {
1642 query = new StringBundler(6 +
1643 (orderByComparator.getOrderByFields().length * 6));
1644 }
1645 else {
1646 query = new StringBundler(3);
1647 }
1648
1649 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1650
1651 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1652
1653 if (orderByComparator != null) {
1654 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1655
1656 if (orderByConditionFields.length > 0) {
1657 query.append(WHERE_AND);
1658 }
1659
1660 for (int i = 0; i < orderByConditionFields.length; i++) {
1661 query.append(_ORDER_BY_ENTITY_ALIAS);
1662 query.append(orderByConditionFields[i]);
1663
1664 if ((i + 1) < orderByConditionFields.length) {
1665 if (orderByComparator.isAscending() ^ previous) {
1666 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1667 }
1668 else {
1669 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1670 }
1671 }
1672 else {
1673 if (orderByComparator.isAscending() ^ previous) {
1674 query.append(WHERE_GREATER_THAN);
1675 }
1676 else {
1677 query.append(WHERE_LESSER_THAN);
1678 }
1679 }
1680 }
1681
1682 query.append(ORDER_BY_CLAUSE);
1683
1684 String[] orderByFields = orderByComparator.getOrderByFields();
1685
1686 for (int i = 0; i < orderByFields.length; i++) {
1687 query.append(_ORDER_BY_ENTITY_ALIAS);
1688 query.append(orderByFields[i]);
1689
1690 if ((i + 1) < orderByFields.length) {
1691 if (orderByComparator.isAscending() ^ previous) {
1692 query.append(ORDER_BY_ASC_HAS_NEXT);
1693 }
1694 else {
1695 query.append(ORDER_BY_DESC_HAS_NEXT);
1696 }
1697 }
1698 else {
1699 if (orderByComparator.isAscending() ^ previous) {
1700 query.append(ORDER_BY_ASC);
1701 }
1702 else {
1703 query.append(ORDER_BY_DESC);
1704 }
1705 }
1706 }
1707 }
1708
1709 else {
1710 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1711 }
1712
1713 String sql = query.toString();
1714
1715 Query q = session.createQuery(sql);
1716
1717 q.setFirstResult(0);
1718 q.setMaxResults(2);
1719
1720 QueryPos qPos = QueryPos.getInstance(q);
1721
1722 qPos.add(groupId);
1723
1724 if (orderByComparator != null) {
1725 Object[] values = orderByComparator.getOrderByConditionValues(journalStructure);
1726
1727 for (Object value : values) {
1728 qPos.add(value);
1729 }
1730 }
1731
1732 List<JournalStructure> list = q.list();
1733
1734 if (list.size() == 2) {
1735 return list.get(1);
1736 }
1737 else {
1738 return null;
1739 }
1740 }
1741
1742
1749 public List<JournalStructure> filterFindByGroupId(long groupId)
1750 throws SystemException {
1751 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1752 QueryUtil.ALL_POS, null);
1753 }
1754
1755
1768 public List<JournalStructure> filterFindByGroupId(long groupId, int start,
1769 int end) throws SystemException {
1770 return filterFindByGroupId(groupId, start, end, null);
1771 }
1772
1773
1787 public List<JournalStructure> filterFindByGroupId(long groupId, int start,
1788 int end, OrderByComparator orderByComparator) throws SystemException {
1789 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1790 return findByGroupId(groupId, start, end, orderByComparator);
1791 }
1792
1793 StringBundler query = null;
1794
1795 if (orderByComparator != null) {
1796 query = new StringBundler(3 +
1797 (orderByComparator.getOrderByFields().length * 3));
1798 }
1799 else {
1800 query = new StringBundler(3);
1801 }
1802
1803 if (getDB().isSupportsInlineDistinct()) {
1804 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1805 }
1806 else {
1807 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
1808 }
1809
1810 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1811
1812 if (!getDB().isSupportsInlineDistinct()) {
1813 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
1814 }
1815
1816 if (orderByComparator != null) {
1817 if (getDB().isSupportsInlineDistinct()) {
1818 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1819 orderByComparator);
1820 }
1821 else {
1822 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1823 orderByComparator);
1824 }
1825 }
1826
1827 else {
1828 if (getDB().isSupportsInlineDistinct()) {
1829 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1830 }
1831 else {
1832 query.append(JournalStructureModelImpl.ORDER_BY_SQL);
1833 }
1834 }
1835
1836 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1837 JournalStructure.class.getName(),
1838 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1839
1840 Session session = null;
1841
1842 try {
1843 session = openSession();
1844
1845 SQLQuery q = session.createSQLQuery(sql);
1846
1847 if (getDB().isSupportsInlineDistinct()) {
1848 q.addEntity(_FILTER_ENTITY_ALIAS, JournalStructureImpl.class);
1849 }
1850 else {
1851 q.addEntity(_FILTER_ENTITY_TABLE, JournalStructureImpl.class);
1852 }
1853
1854 QueryPos qPos = QueryPos.getInstance(q);
1855
1856 qPos.add(groupId);
1857
1858 return (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1859 start, end);
1860 }
1861 catch (Exception e) {
1862 throw processException(e);
1863 }
1864 finally {
1865 closeSession(session);
1866 }
1867 }
1868
1869
1879 public JournalStructure[] filterFindByGroupId_PrevAndNext(long id,
1880 long groupId, OrderByComparator orderByComparator)
1881 throws NoSuchStructureException, SystemException {
1882 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1883 return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
1884 }
1885
1886 JournalStructure journalStructure = findByPrimaryKey(id);
1887
1888 Session session = null;
1889
1890 try {
1891 session = openSession();
1892
1893 JournalStructure[] array = new JournalStructureImpl[3];
1894
1895 array[0] = filterGetByGroupId_PrevAndNext(session,
1896 journalStructure, groupId, orderByComparator, true);
1897
1898 array[1] = journalStructure;
1899
1900 array[2] = filterGetByGroupId_PrevAndNext(session,
1901 journalStructure, groupId, orderByComparator, false);
1902
1903 return array;
1904 }
1905 catch (Exception e) {
1906 throw processException(e);
1907 }
1908 finally {
1909 closeSession(session);
1910 }
1911 }
1912
1913 protected JournalStructure filterGetByGroupId_PrevAndNext(Session session,
1914 JournalStructure journalStructure, long groupId,
1915 OrderByComparator orderByComparator, boolean previous) {
1916 StringBundler query = null;
1917
1918 if (orderByComparator != null) {
1919 query = new StringBundler(6 +
1920 (orderByComparator.getOrderByFields().length * 6));
1921 }
1922 else {
1923 query = new StringBundler(3);
1924 }
1925
1926 if (getDB().isSupportsInlineDistinct()) {
1927 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1928 }
1929 else {
1930 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
1931 }
1932
1933 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1934
1935 if (!getDB().isSupportsInlineDistinct()) {
1936 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
1937 }
1938
1939 if (orderByComparator != null) {
1940 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1941
1942 if (orderByConditionFields.length > 0) {
1943 query.append(WHERE_AND);
1944 }
1945
1946 for (int i = 0; i < orderByConditionFields.length; i++) {
1947 if (getDB().isSupportsInlineDistinct()) {
1948 query.append(_ORDER_BY_ENTITY_ALIAS);
1949 }
1950 else {
1951 query.append(_ORDER_BY_ENTITY_TABLE);
1952 }
1953
1954 query.append(orderByConditionFields[i]);
1955
1956 if ((i + 1) < orderByConditionFields.length) {
1957 if (orderByComparator.isAscending() ^ previous) {
1958 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1959 }
1960 else {
1961 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1962 }
1963 }
1964 else {
1965 if (orderByComparator.isAscending() ^ previous) {
1966 query.append(WHERE_GREATER_THAN);
1967 }
1968 else {
1969 query.append(WHERE_LESSER_THAN);
1970 }
1971 }
1972 }
1973
1974 query.append(ORDER_BY_CLAUSE);
1975
1976 String[] orderByFields = orderByComparator.getOrderByFields();
1977
1978 for (int i = 0; i < orderByFields.length; i++) {
1979 if (getDB().isSupportsInlineDistinct()) {
1980 query.append(_ORDER_BY_ENTITY_ALIAS);
1981 }
1982 else {
1983 query.append(_ORDER_BY_ENTITY_TABLE);
1984 }
1985
1986 query.append(orderByFields[i]);
1987
1988 if ((i + 1) < orderByFields.length) {
1989 if (orderByComparator.isAscending() ^ previous) {
1990 query.append(ORDER_BY_ASC_HAS_NEXT);
1991 }
1992 else {
1993 query.append(ORDER_BY_DESC_HAS_NEXT);
1994 }
1995 }
1996 else {
1997 if (orderByComparator.isAscending() ^ previous) {
1998 query.append(ORDER_BY_ASC);
1999 }
2000 else {
2001 query.append(ORDER_BY_DESC);
2002 }
2003 }
2004 }
2005 }
2006
2007 else {
2008 if (getDB().isSupportsInlineDistinct()) {
2009 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2010 }
2011 else {
2012 query.append(JournalStructureModelImpl.ORDER_BY_SQL);
2013 }
2014 }
2015
2016 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2017 JournalStructure.class.getName(),
2018 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2019
2020 SQLQuery q = session.createSQLQuery(sql);
2021
2022 q.setFirstResult(0);
2023 q.setMaxResults(2);
2024
2025 if (getDB().isSupportsInlineDistinct()) {
2026 q.addEntity(_FILTER_ENTITY_ALIAS, JournalStructureImpl.class);
2027 }
2028 else {
2029 q.addEntity(_FILTER_ENTITY_TABLE, JournalStructureImpl.class);
2030 }
2031
2032 QueryPos qPos = QueryPos.getInstance(q);
2033
2034 qPos.add(groupId);
2035
2036 if (orderByComparator != null) {
2037 Object[] values = orderByComparator.getOrderByConditionValues(journalStructure);
2038
2039 for (Object value : values) {
2040 qPos.add(value);
2041 }
2042 }
2043
2044 List<JournalStructure> list = q.list();
2045
2046 if (list.size() == 2) {
2047 return list.get(1);
2048 }
2049 else {
2050 return null;
2051 }
2052 }
2053
2054
2061 public List<JournalStructure> findByStructureId(String structureId)
2062 throws SystemException {
2063 return findByStructureId(structureId, QueryUtil.ALL_POS,
2064 QueryUtil.ALL_POS, null);
2065 }
2066
2067
2080 public List<JournalStructure> findByStructureId(String structureId,
2081 int start, int end) throws SystemException {
2082 return findByStructureId(structureId, start, end, null);
2083 }
2084
2085
2099 public List<JournalStructure> findByStructureId(String structureId,
2100 int start, int end, OrderByComparator orderByComparator)
2101 throws SystemException {
2102 FinderPath finderPath = null;
2103 Object[] finderArgs = null;
2104
2105 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2106 (orderByComparator == null)) {
2107 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
2108 finderArgs = new Object[] { structureId };
2109 }
2110 else {
2111 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
2112 finderArgs = new Object[] { structureId, start, end, orderByComparator };
2113 }
2114
2115 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(finderPath,
2116 finderArgs, this);
2117
2118 if ((list != null) && !list.isEmpty()) {
2119 for (JournalStructure journalStructure : list) {
2120 if (!Validator.equals(structureId,
2121 journalStructure.getStructureId())) {
2122 list = null;
2123
2124 break;
2125 }
2126 }
2127 }
2128
2129 if (list == null) {
2130 StringBundler query = null;
2131
2132 if (orderByComparator != null) {
2133 query = new StringBundler(3 +
2134 (orderByComparator.getOrderByFields().length * 3));
2135 }
2136 else {
2137 query = new StringBundler(3);
2138 }
2139
2140 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2141
2142 if (structureId == null) {
2143 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
2144 }
2145 else {
2146 if (structureId.equals(StringPool.BLANK)) {
2147 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
2148 }
2149 else {
2150 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
2151 }
2152 }
2153
2154 if (orderByComparator != null) {
2155 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2156 orderByComparator);
2157 }
2158
2159 else {
2160 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2161 }
2162
2163 String sql = query.toString();
2164
2165 Session session = null;
2166
2167 try {
2168 session = openSession();
2169
2170 Query q = session.createQuery(sql);
2171
2172 QueryPos qPos = QueryPos.getInstance(q);
2173
2174 if (structureId != null) {
2175 qPos.add(structureId);
2176 }
2177
2178 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
2179 start, end);
2180 }
2181 catch (Exception e) {
2182 throw processException(e);
2183 }
2184 finally {
2185 if (list == null) {
2186 FinderCacheUtil.removeResult(finderPath, finderArgs);
2187 }
2188 else {
2189 cacheResult(list);
2190
2191 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2192 }
2193
2194 closeSession(session);
2195 }
2196 }
2197
2198 return list;
2199 }
2200
2201
2210 public JournalStructure findByStructureId_First(String structureId,
2211 OrderByComparator orderByComparator)
2212 throws NoSuchStructureException, SystemException {
2213 JournalStructure journalStructure = fetchByStructureId_First(structureId,
2214 orderByComparator);
2215
2216 if (journalStructure != null) {
2217 return journalStructure;
2218 }
2219
2220 StringBundler msg = new StringBundler(4);
2221
2222 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2223
2224 msg.append("structureId=");
2225 msg.append(structureId);
2226
2227 msg.append(StringPool.CLOSE_CURLY_BRACE);
2228
2229 throw new NoSuchStructureException(msg.toString());
2230 }
2231
2232
2240 public JournalStructure fetchByStructureId_First(String structureId,
2241 OrderByComparator orderByComparator) throws SystemException {
2242 List<JournalStructure> list = findByStructureId(structureId, 0, 1,
2243 orderByComparator);
2244
2245 if (!list.isEmpty()) {
2246 return list.get(0);
2247 }
2248
2249 return null;
2250 }
2251
2252
2261 public JournalStructure findByStructureId_Last(String structureId,
2262 OrderByComparator orderByComparator)
2263 throws NoSuchStructureException, SystemException {
2264 JournalStructure journalStructure = fetchByStructureId_Last(structureId,
2265 orderByComparator);
2266
2267 if (journalStructure != null) {
2268 return journalStructure;
2269 }
2270
2271 StringBundler msg = new StringBundler(4);
2272
2273 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2274
2275 msg.append("structureId=");
2276 msg.append(structureId);
2277
2278 msg.append(StringPool.CLOSE_CURLY_BRACE);
2279
2280 throw new NoSuchStructureException(msg.toString());
2281 }
2282
2283
2291 public JournalStructure fetchByStructureId_Last(String structureId,
2292 OrderByComparator orderByComparator) throws SystemException {
2293 int count = countByStructureId(structureId);
2294
2295 List<JournalStructure> list = findByStructureId(structureId, count - 1,
2296 count, orderByComparator);
2297
2298 if (!list.isEmpty()) {
2299 return list.get(0);
2300 }
2301
2302 return null;
2303 }
2304
2305
2315 public JournalStructure[] findByStructureId_PrevAndNext(long id,
2316 String structureId, OrderByComparator orderByComparator)
2317 throws NoSuchStructureException, SystemException {
2318 JournalStructure journalStructure = findByPrimaryKey(id);
2319
2320 Session session = null;
2321
2322 try {
2323 session = openSession();
2324
2325 JournalStructure[] array = new JournalStructureImpl[3];
2326
2327 array[0] = getByStructureId_PrevAndNext(session, journalStructure,
2328 structureId, orderByComparator, true);
2329
2330 array[1] = journalStructure;
2331
2332 array[2] = getByStructureId_PrevAndNext(session, journalStructure,
2333 structureId, orderByComparator, false);
2334
2335 return array;
2336 }
2337 catch (Exception e) {
2338 throw processException(e);
2339 }
2340 finally {
2341 closeSession(session);
2342 }
2343 }
2344
2345 protected JournalStructure getByStructureId_PrevAndNext(Session session,
2346 JournalStructure journalStructure, String structureId,
2347 OrderByComparator orderByComparator, boolean previous) {
2348 StringBundler query = null;
2349
2350 if (orderByComparator != null) {
2351 query = new StringBundler(6 +
2352 (orderByComparator.getOrderByFields().length * 6));
2353 }
2354 else {
2355 query = new StringBundler(3);
2356 }
2357
2358 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2359
2360 if (structureId == null) {
2361 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
2362 }
2363 else {
2364 if (structureId.equals(StringPool.BLANK)) {
2365 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
2366 }
2367 else {
2368 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
2369 }
2370 }
2371
2372 if (orderByComparator != null) {
2373 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2374
2375 if (orderByConditionFields.length > 0) {
2376 query.append(WHERE_AND);
2377 }
2378
2379 for (int i = 0; i < orderByConditionFields.length; i++) {
2380 query.append(_ORDER_BY_ENTITY_ALIAS);
2381 query.append(orderByConditionFields[i]);
2382
2383 if ((i + 1) < orderByConditionFields.length) {
2384 if (orderByComparator.isAscending() ^ previous) {
2385 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2386 }
2387 else {
2388 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2389 }
2390 }
2391 else {
2392 if (orderByComparator.isAscending() ^ previous) {
2393 query.append(WHERE_GREATER_THAN);
2394 }
2395 else {
2396 query.append(WHERE_LESSER_THAN);
2397 }
2398 }
2399 }
2400
2401 query.append(ORDER_BY_CLAUSE);
2402
2403 String[] orderByFields = orderByComparator.getOrderByFields();
2404
2405 for (int i = 0; i < orderByFields.length; i++) {
2406 query.append(_ORDER_BY_ENTITY_ALIAS);
2407 query.append(orderByFields[i]);
2408
2409 if ((i + 1) < orderByFields.length) {
2410 if (orderByComparator.isAscending() ^ previous) {
2411 query.append(ORDER_BY_ASC_HAS_NEXT);
2412 }
2413 else {
2414 query.append(ORDER_BY_DESC_HAS_NEXT);
2415 }
2416 }
2417 else {
2418 if (orderByComparator.isAscending() ^ previous) {
2419 query.append(ORDER_BY_ASC);
2420 }
2421 else {
2422 query.append(ORDER_BY_DESC);
2423 }
2424 }
2425 }
2426 }
2427
2428 else {
2429 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2430 }
2431
2432 String sql = query.toString();
2433
2434 Query q = session.createQuery(sql);
2435
2436 q.setFirstResult(0);
2437 q.setMaxResults(2);
2438
2439 QueryPos qPos = QueryPos.getInstance(q);
2440
2441 if (structureId != null) {
2442 qPos.add(structureId);
2443 }
2444
2445 if (orderByComparator != null) {
2446 Object[] values = orderByComparator.getOrderByConditionValues(journalStructure);
2447
2448 for (Object value : values) {
2449 qPos.add(value);
2450 }
2451 }
2452
2453 List<JournalStructure> list = q.list();
2454
2455 if (list.size() == 2) {
2456 return list.get(1);
2457 }
2458 else {
2459 return null;
2460 }
2461 }
2462
2463
2470 public List<JournalStructure> findByParentStructureId(
2471 String parentStructureId) throws SystemException {
2472 return findByParentStructureId(parentStructureId, QueryUtil.ALL_POS,
2473 QueryUtil.ALL_POS, null);
2474 }
2475
2476
2489 public List<JournalStructure> findByParentStructureId(
2490 String parentStructureId, int start, int end) throws SystemException {
2491 return findByParentStructureId(parentStructureId, start, end, null);
2492 }
2493
2494
2508 public List<JournalStructure> findByParentStructureId(
2509 String parentStructureId, int start, int end,
2510 OrderByComparator orderByComparator) throws SystemException {
2511 FinderPath finderPath = null;
2512 Object[] finderArgs = null;
2513
2514 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2515 (orderByComparator == null)) {
2516 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTSTRUCTUREID;
2517 finderArgs = new Object[] { parentStructureId };
2518 }
2519 else {
2520 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTSTRUCTUREID;
2521 finderArgs = new Object[] {
2522 parentStructureId,
2523
2524 start, end, orderByComparator
2525 };
2526 }
2527
2528 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(finderPath,
2529 finderArgs, this);
2530
2531 if ((list != null) && !list.isEmpty()) {
2532 for (JournalStructure journalStructure : list) {
2533 if (!Validator.equals(parentStructureId,
2534 journalStructure.getParentStructureId())) {
2535 list = null;
2536
2537 break;
2538 }
2539 }
2540 }
2541
2542 if (list == null) {
2543 StringBundler query = null;
2544
2545 if (orderByComparator != null) {
2546 query = new StringBundler(3 +
2547 (orderByComparator.getOrderByFields().length * 3));
2548 }
2549 else {
2550 query = new StringBundler(3);
2551 }
2552
2553 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2554
2555 if (parentStructureId == null) {
2556 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_1);
2557 }
2558 else {
2559 if (parentStructureId.equals(StringPool.BLANK)) {
2560 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_3);
2561 }
2562 else {
2563 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2);
2564 }
2565 }
2566
2567 if (orderByComparator != null) {
2568 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2569 orderByComparator);
2570 }
2571
2572 else {
2573 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2574 }
2575
2576 String sql = query.toString();
2577
2578 Session session = null;
2579
2580 try {
2581 session = openSession();
2582
2583 Query q = session.createQuery(sql);
2584
2585 QueryPos qPos = QueryPos.getInstance(q);
2586
2587 if (parentStructureId != null) {
2588 qPos.add(parentStructureId);
2589 }
2590
2591 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
2592 start, end);
2593 }
2594 catch (Exception e) {
2595 throw processException(e);
2596 }
2597 finally {
2598 if (list == null) {
2599 FinderCacheUtil.removeResult(finderPath, finderArgs);
2600 }
2601 else {
2602 cacheResult(list);
2603
2604 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2605 }
2606
2607 closeSession(session);
2608 }
2609 }
2610
2611 return list;
2612 }
2613
2614
2623 public JournalStructure findByParentStructureId_First(
2624 String parentStructureId, OrderByComparator orderByComparator)
2625 throws NoSuchStructureException, SystemException {
2626 JournalStructure journalStructure = fetchByParentStructureId_First(parentStructureId,
2627 orderByComparator);
2628
2629 if (journalStructure != null) {
2630 return journalStructure;
2631 }
2632
2633 StringBundler msg = new StringBundler(4);
2634
2635 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2636
2637 msg.append("parentStructureId=");
2638 msg.append(parentStructureId);
2639
2640 msg.append(StringPool.CLOSE_CURLY_BRACE);
2641
2642 throw new NoSuchStructureException(msg.toString());
2643 }
2644
2645
2653 public JournalStructure fetchByParentStructureId_First(
2654 String parentStructureId, OrderByComparator orderByComparator)
2655 throws SystemException {
2656 List<JournalStructure> list = findByParentStructureId(parentStructureId,
2657 0, 1, orderByComparator);
2658
2659 if (!list.isEmpty()) {
2660 return list.get(0);
2661 }
2662
2663 return null;
2664 }
2665
2666
2675 public JournalStructure findByParentStructureId_Last(
2676 String parentStructureId, OrderByComparator orderByComparator)
2677 throws NoSuchStructureException, SystemException {
2678 JournalStructure journalStructure = fetchByParentStructureId_Last(parentStructureId,
2679 orderByComparator);
2680
2681 if (journalStructure != null) {
2682 return journalStructure;
2683 }
2684
2685 StringBundler msg = new StringBundler(4);
2686
2687 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2688
2689 msg.append("parentStructureId=");
2690 msg.append(parentStructureId);
2691
2692 msg.append(StringPool.CLOSE_CURLY_BRACE);
2693
2694 throw new NoSuchStructureException(msg.toString());
2695 }
2696
2697
2705 public JournalStructure fetchByParentStructureId_Last(
2706 String parentStructureId, OrderByComparator orderByComparator)
2707 throws SystemException {
2708 int count = countByParentStructureId(parentStructureId);
2709
2710 List<JournalStructure> list = findByParentStructureId(parentStructureId,
2711 count - 1, count, orderByComparator);
2712
2713 if (!list.isEmpty()) {
2714 return list.get(0);
2715 }
2716
2717 return null;
2718 }
2719
2720
2730 public JournalStructure[] findByParentStructureId_PrevAndNext(long id,
2731 String parentStructureId, OrderByComparator orderByComparator)
2732 throws NoSuchStructureException, SystemException {
2733 JournalStructure journalStructure = findByPrimaryKey(id);
2734
2735 Session session = null;
2736
2737 try {
2738 session = openSession();
2739
2740 JournalStructure[] array = new JournalStructureImpl[3];
2741
2742 array[0] = getByParentStructureId_PrevAndNext(session,
2743 journalStructure, parentStructureId, orderByComparator, true);
2744
2745 array[1] = journalStructure;
2746
2747 array[2] = getByParentStructureId_PrevAndNext(session,
2748 journalStructure, parentStructureId, orderByComparator,
2749 false);
2750
2751 return array;
2752 }
2753 catch (Exception e) {
2754 throw processException(e);
2755 }
2756 finally {
2757 closeSession(session);
2758 }
2759 }
2760
2761 protected JournalStructure getByParentStructureId_PrevAndNext(
2762 Session session, JournalStructure journalStructure,
2763 String parentStructureId, OrderByComparator orderByComparator,
2764 boolean previous) {
2765 StringBundler query = null;
2766
2767 if (orderByComparator != null) {
2768 query = new StringBundler(6 +
2769 (orderByComparator.getOrderByFields().length * 6));
2770 }
2771 else {
2772 query = new StringBundler(3);
2773 }
2774
2775 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2776
2777 if (parentStructureId == null) {
2778 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_1);
2779 }
2780 else {
2781 if (parentStructureId.equals(StringPool.BLANK)) {
2782 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_3);
2783 }
2784 else {
2785 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2);
2786 }
2787 }
2788
2789 if (orderByComparator != null) {
2790 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2791
2792 if (orderByConditionFields.length > 0) {
2793 query.append(WHERE_AND);
2794 }
2795
2796 for (int i = 0; i < orderByConditionFields.length; i++) {
2797 query.append(_ORDER_BY_ENTITY_ALIAS);
2798 query.append(orderByConditionFields[i]);
2799
2800 if ((i + 1) < orderByConditionFields.length) {
2801 if (orderByComparator.isAscending() ^ previous) {
2802 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2803 }
2804 else {
2805 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2806 }
2807 }
2808 else {
2809 if (orderByComparator.isAscending() ^ previous) {
2810 query.append(WHERE_GREATER_THAN);
2811 }
2812 else {
2813 query.append(WHERE_LESSER_THAN);
2814 }
2815 }
2816 }
2817
2818 query.append(ORDER_BY_CLAUSE);
2819
2820 String[] orderByFields = orderByComparator.getOrderByFields();
2821
2822 for (int i = 0; i < orderByFields.length; i++) {
2823 query.append(_ORDER_BY_ENTITY_ALIAS);
2824 query.append(orderByFields[i]);
2825
2826 if ((i + 1) < orderByFields.length) {
2827 if (orderByComparator.isAscending() ^ previous) {
2828 query.append(ORDER_BY_ASC_HAS_NEXT);
2829 }
2830 else {
2831 query.append(ORDER_BY_DESC_HAS_NEXT);
2832 }
2833 }
2834 else {
2835 if (orderByComparator.isAscending() ^ previous) {
2836 query.append(ORDER_BY_ASC);
2837 }
2838 else {
2839 query.append(ORDER_BY_DESC);
2840 }
2841 }
2842 }
2843 }
2844
2845 else {
2846 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2847 }
2848
2849 String sql = query.toString();
2850
2851 Query q = session.createQuery(sql);
2852
2853 q.setFirstResult(0);
2854 q.setMaxResults(2);
2855
2856 QueryPos qPos = QueryPos.getInstance(q);
2857
2858 if (parentStructureId != null) {
2859 qPos.add(parentStructureId);
2860 }
2861
2862 if (orderByComparator != null) {
2863 Object[] values = orderByComparator.getOrderByConditionValues(journalStructure);
2864
2865 for (Object value : values) {
2866 qPos.add(value);
2867 }
2868 }
2869
2870 List<JournalStructure> list = q.list();
2871
2872 if (list.size() == 2) {
2873 return list.get(1);
2874 }
2875 else {
2876 return null;
2877 }
2878 }
2879
2880
2889 public JournalStructure findByG_S(long groupId, String structureId)
2890 throws NoSuchStructureException, SystemException {
2891 JournalStructure journalStructure = fetchByG_S(groupId, structureId);
2892
2893 if (journalStructure == null) {
2894 StringBundler msg = new StringBundler(6);
2895
2896 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2897
2898 msg.append("groupId=");
2899 msg.append(groupId);
2900
2901 msg.append(", structureId=");
2902 msg.append(structureId);
2903
2904 msg.append(StringPool.CLOSE_CURLY_BRACE);
2905
2906 if (_log.isWarnEnabled()) {
2907 _log.warn(msg.toString());
2908 }
2909
2910 throw new NoSuchStructureException(msg.toString());
2911 }
2912
2913 return journalStructure;
2914 }
2915
2916
2924 public JournalStructure fetchByG_S(long groupId, String structureId)
2925 throws SystemException {
2926 return fetchByG_S(groupId, structureId, true);
2927 }
2928
2929
2938 public JournalStructure fetchByG_S(long groupId, String structureId,
2939 boolean retrieveFromCache) throws SystemException {
2940 Object[] finderArgs = new Object[] { groupId, structureId };
2941
2942 Object result = null;
2943
2944 if (retrieveFromCache) {
2945 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_S,
2946 finderArgs, this);
2947 }
2948
2949 if (result instanceof JournalStructure) {
2950 JournalStructure journalStructure = (JournalStructure)result;
2951
2952 if ((groupId != journalStructure.getGroupId()) ||
2953 !Validator.equals(structureId,
2954 journalStructure.getStructureId())) {
2955 result = null;
2956 }
2957 }
2958
2959 if (result == null) {
2960 StringBundler query = new StringBundler(4);
2961
2962 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2963
2964 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2965
2966 if (structureId == null) {
2967 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
2968 }
2969 else {
2970 if (structureId.equals(StringPool.BLANK)) {
2971 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
2972 }
2973 else {
2974 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
2975 }
2976 }
2977
2978 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2979
2980 String sql = query.toString();
2981
2982 Session session = null;
2983
2984 try {
2985 session = openSession();
2986
2987 Query q = session.createQuery(sql);
2988
2989 QueryPos qPos = QueryPos.getInstance(q);
2990
2991 qPos.add(groupId);
2992
2993 if (structureId != null) {
2994 qPos.add(structureId);
2995 }
2996
2997 List<JournalStructure> list = q.list();
2998
2999 result = list;
3000
3001 JournalStructure journalStructure = null;
3002
3003 if (list.isEmpty()) {
3004 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
3005 finderArgs, list);
3006 }
3007 else {
3008 journalStructure = list.get(0);
3009
3010 cacheResult(journalStructure);
3011
3012 if ((journalStructure.getGroupId() != groupId) ||
3013 (journalStructure.getStructureId() == null) ||
3014 !journalStructure.getStructureId()
3015 .equals(structureId)) {
3016 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
3017 finderArgs, journalStructure);
3018 }
3019 }
3020
3021 return journalStructure;
3022 }
3023 catch (Exception e) {
3024 throw processException(e);
3025 }
3026 finally {
3027 if (result == null) {
3028 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
3029 finderArgs);
3030 }
3031
3032 closeSession(session);
3033 }
3034 }
3035 else {
3036 if (result instanceof List<?>) {
3037 return null;
3038 }
3039 else {
3040 return (JournalStructure)result;
3041 }
3042 }
3043 }
3044
3045
3053 public List<JournalStructure> findByG_P(long groupId,
3054 String parentStructureId) throws SystemException {
3055 return findByG_P(groupId, parentStructureId, QueryUtil.ALL_POS,
3056 QueryUtil.ALL_POS, null);
3057 }
3058
3059
3073 public List<JournalStructure> findByG_P(long groupId,
3074 String parentStructureId, int start, int end) throws SystemException {
3075 return findByG_P(groupId, parentStructureId, start, end, null);
3076 }
3077
3078
3093 public List<JournalStructure> findByG_P(long groupId,
3094 String parentStructureId, int start, int end,
3095 OrderByComparator orderByComparator) throws SystemException {
3096 FinderPath finderPath = null;
3097 Object[] finderArgs = null;
3098
3099 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3100 (orderByComparator == null)) {
3101 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
3102 finderArgs = new Object[] { groupId, parentStructureId };
3103 }
3104 else {
3105 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
3106 finderArgs = new Object[] {
3107 groupId, parentStructureId,
3108
3109 start, end, orderByComparator
3110 };
3111 }
3112
3113 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(finderPath,
3114 finderArgs, this);
3115
3116 if ((list != null) && !list.isEmpty()) {
3117 for (JournalStructure journalStructure : list) {
3118 if ((groupId != journalStructure.getGroupId()) ||
3119 !Validator.equals(parentStructureId,
3120 journalStructure.getParentStructureId())) {
3121 list = null;
3122
3123 break;
3124 }
3125 }
3126 }
3127
3128 if (list == null) {
3129 StringBundler query = null;
3130
3131 if (orderByComparator != null) {
3132 query = new StringBundler(4 +
3133 (orderByComparator.getOrderByFields().length * 3));
3134 }
3135 else {
3136 query = new StringBundler(4);
3137 }
3138
3139 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
3140
3141 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3142
3143 if (parentStructureId == null) {
3144 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
3145 }
3146 else {
3147 if (parentStructureId.equals(StringPool.BLANK)) {
3148 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
3149 }
3150 else {
3151 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
3152 }
3153 }
3154
3155 if (orderByComparator != null) {
3156 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3157 orderByComparator);
3158 }
3159
3160 else {
3161 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
3162 }
3163
3164 String sql = query.toString();
3165
3166 Session session = null;
3167
3168 try {
3169 session = openSession();
3170
3171 Query q = session.createQuery(sql);
3172
3173 QueryPos qPos = QueryPos.getInstance(q);
3174
3175 qPos.add(groupId);
3176
3177 if (parentStructureId != null) {
3178 qPos.add(parentStructureId);
3179 }
3180
3181 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
3182 start, end);
3183 }
3184 catch (Exception e) {
3185 throw processException(e);
3186 }
3187 finally {
3188 if (list == null) {
3189 FinderCacheUtil.removeResult(finderPath, finderArgs);
3190 }
3191 else {
3192 cacheResult(list);
3193
3194 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3195 }
3196
3197 closeSession(session);
3198 }
3199 }
3200
3201 return list;
3202 }
3203
3204
3214 public JournalStructure findByG_P_First(long groupId,
3215 String parentStructureId, OrderByComparator orderByComparator)
3216 throws NoSuchStructureException, SystemException {
3217 JournalStructure journalStructure = fetchByG_P_First(groupId,
3218 parentStructureId, orderByComparator);
3219
3220 if (journalStructure != null) {
3221 return journalStructure;
3222 }
3223
3224 StringBundler msg = new StringBundler(6);
3225
3226 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3227
3228 msg.append("groupId=");
3229 msg.append(groupId);
3230
3231 msg.append(", parentStructureId=");
3232 msg.append(parentStructureId);
3233
3234 msg.append(StringPool.CLOSE_CURLY_BRACE);
3235
3236 throw new NoSuchStructureException(msg.toString());
3237 }
3238
3239
3248 public JournalStructure fetchByG_P_First(long groupId,
3249 String parentStructureId, OrderByComparator orderByComparator)
3250 throws SystemException {
3251 List<JournalStructure> list = findByG_P(groupId, parentStructureId, 0,
3252 1, orderByComparator);
3253
3254 if (!list.isEmpty()) {
3255 return list.get(0);
3256 }
3257
3258 return null;
3259 }
3260
3261
3271 public JournalStructure findByG_P_Last(long groupId,
3272 String parentStructureId, OrderByComparator orderByComparator)
3273 throws NoSuchStructureException, SystemException {
3274 JournalStructure journalStructure = fetchByG_P_Last(groupId,
3275 parentStructureId, orderByComparator);
3276
3277 if (journalStructure != null) {
3278 return journalStructure;
3279 }
3280
3281 StringBundler msg = new StringBundler(6);
3282
3283 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3284
3285 msg.append("groupId=");
3286 msg.append(groupId);
3287
3288 msg.append(", parentStructureId=");
3289 msg.append(parentStructureId);
3290
3291 msg.append(StringPool.CLOSE_CURLY_BRACE);
3292
3293 throw new NoSuchStructureException(msg.toString());
3294 }
3295
3296
3305 public JournalStructure fetchByG_P_Last(long groupId,
3306 String parentStructureId, OrderByComparator orderByComparator)
3307 throws SystemException {
3308 int count = countByG_P(groupId, parentStructureId);
3309
3310 List<JournalStructure> list = findByG_P(groupId, parentStructureId,
3311 count - 1, count, orderByComparator);
3312
3313 if (!list.isEmpty()) {
3314 return list.get(0);
3315 }
3316
3317 return null;
3318 }
3319
3320
3331 public JournalStructure[] findByG_P_PrevAndNext(long id, long groupId,
3332 String parentStructureId, OrderByComparator orderByComparator)
3333 throws NoSuchStructureException, SystemException {
3334 JournalStructure journalStructure = findByPrimaryKey(id);
3335
3336 Session session = null;
3337
3338 try {
3339 session = openSession();
3340
3341 JournalStructure[] array = new JournalStructureImpl[3];
3342
3343 array[0] = getByG_P_PrevAndNext(session, journalStructure, groupId,
3344 parentStructureId, orderByComparator, true);
3345
3346 array[1] = journalStructure;
3347
3348 array[2] = getByG_P_PrevAndNext(session, journalStructure, groupId,
3349 parentStructureId, orderByComparator, false);
3350
3351 return array;
3352 }
3353 catch (Exception e) {
3354 throw processException(e);
3355 }
3356 finally {
3357 closeSession(session);
3358 }
3359 }
3360
3361 protected JournalStructure getByG_P_PrevAndNext(Session session,
3362 JournalStructure journalStructure, long groupId,
3363 String parentStructureId, OrderByComparator orderByComparator,
3364 boolean previous) {
3365 StringBundler query = null;
3366
3367 if (orderByComparator != null) {
3368 query = new StringBundler(6 +
3369 (orderByComparator.getOrderByFields().length * 6));
3370 }
3371 else {
3372 query = new StringBundler(3);
3373 }
3374
3375 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
3376
3377 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3378
3379 if (parentStructureId == null) {
3380 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
3381 }
3382 else {
3383 if (parentStructureId.equals(StringPool.BLANK)) {
3384 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
3385 }
3386 else {
3387 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
3388 }
3389 }
3390
3391 if (orderByComparator != null) {
3392 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3393
3394 if (orderByConditionFields.length > 0) {
3395 query.append(WHERE_AND);
3396 }
3397
3398 for (int i = 0; i < orderByConditionFields.length; i++) {
3399 query.append(_ORDER_BY_ENTITY_ALIAS);
3400 query.append(orderByConditionFields[i]);
3401
3402 if ((i + 1) < orderByConditionFields.length) {
3403 if (orderByComparator.isAscending() ^ previous) {
3404 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3405 }
3406 else {
3407 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3408 }
3409 }
3410 else {
3411 if (orderByComparator.isAscending() ^ previous) {
3412 query.append(WHERE_GREATER_THAN);
3413 }
3414 else {
3415 query.append(WHERE_LESSER_THAN);
3416 }
3417 }
3418 }
3419
3420 query.append(ORDER_BY_CLAUSE);
3421
3422 String[] orderByFields = orderByComparator.getOrderByFields();
3423
3424 for (int i = 0; i < orderByFields.length; i++) {
3425 query.append(_ORDER_BY_ENTITY_ALIAS);
3426 query.append(orderByFields[i]);
3427
3428 if ((i + 1) < orderByFields.length) {
3429 if (orderByComparator.isAscending() ^ previous) {
3430 query.append(ORDER_BY_ASC_HAS_NEXT);
3431 }
3432 else {
3433 query.append(ORDER_BY_DESC_HAS_NEXT);
3434 }
3435 }
3436 else {
3437 if (orderByComparator.isAscending() ^ previous) {
3438 query.append(ORDER_BY_ASC);
3439 }
3440 else {
3441 query.append(ORDER_BY_DESC);
3442 }
3443 }
3444 }
3445 }
3446
3447 else {
3448 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
3449 }
3450
3451 String sql = query.toString();
3452
3453 Query q = session.createQuery(sql);
3454
3455 q.setFirstResult(0);
3456 q.setMaxResults(2);
3457
3458 QueryPos qPos = QueryPos.getInstance(q);
3459
3460 qPos.add(groupId);
3461
3462 if (parentStructureId != null) {
3463 qPos.add(parentStructureId);
3464 }
3465
3466 if (orderByComparator != null) {
3467 Object[] values = orderByComparator.getOrderByConditionValues(journalStructure);
3468
3469 for (Object value : values) {
3470 qPos.add(value);
3471 }
3472 }
3473
3474 List<JournalStructure> list = q.list();
3475
3476 if (list.size() == 2) {
3477 return list.get(1);
3478 }
3479 else {
3480 return null;
3481 }
3482 }
3483
3484
3492 public List<JournalStructure> filterFindByG_P(long groupId,
3493 String parentStructureId) throws SystemException {
3494 return filterFindByG_P(groupId, parentStructureId, QueryUtil.ALL_POS,
3495 QueryUtil.ALL_POS, null);
3496 }
3497
3498
3512 public List<JournalStructure> filterFindByG_P(long groupId,
3513 String parentStructureId, int start, int end) throws SystemException {
3514 return filterFindByG_P(groupId, parentStructureId, start, end, null);
3515 }
3516
3517
3532 public List<JournalStructure> filterFindByG_P(long groupId,
3533 String parentStructureId, int start, int end,
3534 OrderByComparator orderByComparator) throws SystemException {
3535 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3536 return findByG_P(groupId, parentStructureId, start, end,
3537 orderByComparator);
3538 }
3539
3540 StringBundler query = null;
3541
3542 if (orderByComparator != null) {
3543 query = new StringBundler(4 +
3544 (orderByComparator.getOrderByFields().length * 3));
3545 }
3546 else {
3547 query = new StringBundler(4);
3548 }
3549
3550 if (getDB().isSupportsInlineDistinct()) {
3551 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
3552 }
3553 else {
3554 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
3555 }
3556
3557 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3558
3559 if (parentStructureId == null) {
3560 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
3561 }
3562 else {
3563 if (parentStructureId.equals(StringPool.BLANK)) {
3564 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
3565 }
3566 else {
3567 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
3568 }
3569 }
3570
3571 if (!getDB().isSupportsInlineDistinct()) {
3572 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
3573 }
3574
3575 if (orderByComparator != null) {
3576 if (getDB().isSupportsInlineDistinct()) {
3577 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3578 orderByComparator);
3579 }
3580 else {
3581 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3582 orderByComparator);
3583 }
3584 }
3585
3586 else {
3587 if (getDB().isSupportsInlineDistinct()) {
3588 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
3589 }
3590 else {
3591 query.append(JournalStructureModelImpl.ORDER_BY_SQL);
3592 }
3593 }
3594
3595 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3596 JournalStructure.class.getName(),
3597 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3598
3599 Session session = null;
3600
3601 try {
3602 session = openSession();
3603
3604 SQLQuery q = session.createSQLQuery(sql);
3605
3606 if (getDB().isSupportsInlineDistinct()) {
3607 q.addEntity(_FILTER_ENTITY_ALIAS, JournalStructureImpl.class);
3608 }
3609 else {
3610 q.addEntity(_FILTER_ENTITY_TABLE, JournalStructureImpl.class);
3611 }
3612
3613 QueryPos qPos = QueryPos.getInstance(q);
3614
3615 qPos.add(groupId);
3616
3617 if (parentStructureId != null) {
3618 qPos.add(parentStructureId);
3619 }
3620
3621 return (List<JournalStructure>)QueryUtil.list(q, getDialect(),
3622 start, end);
3623 }
3624 catch (Exception e) {
3625 throw processException(e);
3626 }
3627 finally {
3628 closeSession(session);
3629 }
3630 }
3631
3632
3643 public JournalStructure[] filterFindByG_P_PrevAndNext(long id,
3644 long groupId, String parentStructureId,
3645 OrderByComparator orderByComparator)
3646 throws NoSuchStructureException, SystemException {
3647 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3648 return findByG_P_PrevAndNext(id, groupId, parentStructureId,
3649 orderByComparator);
3650 }
3651
3652 JournalStructure journalStructure = findByPrimaryKey(id);
3653
3654 Session session = null;
3655
3656 try {
3657 session = openSession();
3658
3659 JournalStructure[] array = new JournalStructureImpl[3];
3660
3661 array[0] = filterGetByG_P_PrevAndNext(session, journalStructure,
3662 groupId, parentStructureId, orderByComparator, true);
3663
3664 array[1] = journalStructure;
3665
3666 array[2] = filterGetByG_P_PrevAndNext(session, journalStructure,
3667 groupId, parentStructureId, orderByComparator, false);
3668
3669 return array;
3670 }
3671 catch (Exception e) {
3672 throw processException(e);
3673 }
3674 finally {
3675 closeSession(session);
3676 }
3677 }
3678
3679 protected JournalStructure filterGetByG_P_PrevAndNext(Session session,
3680 JournalStructure journalStructure, long groupId,
3681 String parentStructureId, OrderByComparator orderByComparator,
3682 boolean previous) {
3683 StringBundler query = null;
3684
3685 if (orderByComparator != null) {
3686 query = new StringBundler(6 +
3687 (orderByComparator.getOrderByFields().length * 6));
3688 }
3689 else {
3690 query = new StringBundler(3);
3691 }
3692
3693 if (getDB().isSupportsInlineDistinct()) {
3694 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
3695 }
3696 else {
3697 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
3698 }
3699
3700 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3701
3702 if (parentStructureId == null) {
3703 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
3704 }
3705 else {
3706 if (parentStructureId.equals(StringPool.BLANK)) {
3707 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
3708 }
3709 else {
3710 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
3711 }
3712 }
3713
3714 if (!getDB().isSupportsInlineDistinct()) {
3715 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
3716 }
3717
3718 if (orderByComparator != null) {
3719 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3720
3721 if (orderByConditionFields.length > 0) {
3722 query.append(WHERE_AND);
3723 }
3724
3725 for (int i = 0; i < orderByConditionFields.length; i++) {
3726 if (getDB().isSupportsInlineDistinct()) {
3727 query.append(_ORDER_BY_ENTITY_ALIAS);
3728 }
3729 else {
3730 query.append(_ORDER_BY_ENTITY_TABLE);
3731 }
3732
3733 query.append(orderByConditionFields[i]);
3734
3735 if ((i + 1) < orderByConditionFields.length) {
3736 if (orderByComparator.isAscending() ^ previous) {
3737 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3738 }
3739 else {
3740 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3741 }
3742 }
3743 else {
3744 if (orderByComparator.isAscending() ^ previous) {
3745 query.append(WHERE_GREATER_THAN);
3746 }
3747 else {
3748 query.append(WHERE_LESSER_THAN);
3749 }
3750 }
3751 }
3752
3753 query.append(ORDER_BY_CLAUSE);
3754
3755 String[] orderByFields = orderByComparator.getOrderByFields();
3756
3757 for (int i = 0; i < orderByFields.length; i++) {
3758 if (getDB().isSupportsInlineDistinct()) {
3759 query.append(_ORDER_BY_ENTITY_ALIAS);
3760 }
3761 else {
3762 query.append(_ORDER_BY_ENTITY_TABLE);
3763 }
3764
3765 query.append(orderByFields[i]);
3766
3767 if ((i + 1) < orderByFields.length) {
3768 if (orderByComparator.isAscending() ^ previous) {
3769 query.append(ORDER_BY_ASC_HAS_NEXT);
3770 }
3771 else {
3772 query.append(ORDER_BY_DESC_HAS_NEXT);
3773 }
3774 }
3775 else {
3776 if (orderByComparator.isAscending() ^ previous) {
3777 query.append(ORDER_BY_ASC);
3778 }
3779 else {
3780 query.append(ORDER_BY_DESC);
3781 }
3782 }
3783 }
3784 }
3785
3786 else {
3787 if (getDB().isSupportsInlineDistinct()) {
3788 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
3789 }
3790 else {
3791 query.append(JournalStructureModelImpl.ORDER_BY_SQL);
3792 }
3793 }
3794
3795 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3796 JournalStructure.class.getName(),
3797 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3798
3799 SQLQuery q = session.createSQLQuery(sql);
3800
3801 q.setFirstResult(0);
3802 q.setMaxResults(2);
3803
3804 if (getDB().isSupportsInlineDistinct()) {
3805 q.addEntity(_FILTER_ENTITY_ALIAS, JournalStructureImpl.class);
3806 }
3807 else {
3808 q.addEntity(_FILTER_ENTITY_TABLE, JournalStructureImpl.class);
3809 }
3810
3811 QueryPos qPos = QueryPos.getInstance(q);
3812
3813 qPos.add(groupId);
3814
3815 if (parentStructureId != null) {
3816 qPos.add(parentStructureId);
3817 }
3818
3819 if (orderByComparator != null) {
3820 Object[] values = orderByComparator.getOrderByConditionValues(journalStructure);
3821
3822 for (Object value : values) {
3823 qPos.add(value);
3824 }
3825 }
3826
3827 List<JournalStructure> list = q.list();
3828
3829 if (list.size() == 2) {
3830 return list.get(1);
3831 }
3832 else {
3833 return null;
3834 }
3835 }
3836
3837
3843 public List<JournalStructure> findAll() throws SystemException {
3844 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3845 }
3846
3847
3859 public List<JournalStructure> findAll(int start, int end)
3860 throws SystemException {
3861 return findAll(start, end, null);
3862 }
3863
3864
3877 public List<JournalStructure> findAll(int start, int end,
3878 OrderByComparator orderByComparator) throws SystemException {
3879 FinderPath finderPath = null;
3880 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3881
3882 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3883 (orderByComparator == null)) {
3884 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3885 finderArgs = FINDER_ARGS_EMPTY;
3886 }
3887 else {
3888 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3889 finderArgs = new Object[] { start, end, orderByComparator };
3890 }
3891
3892 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(finderPath,
3893 finderArgs, this);
3894
3895 if (list == null) {
3896 StringBundler query = null;
3897 String sql = null;
3898
3899 if (orderByComparator != null) {
3900 query = new StringBundler(2 +
3901 (orderByComparator.getOrderByFields().length * 3));
3902
3903 query.append(_SQL_SELECT_JOURNALSTRUCTURE);
3904
3905 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3906 orderByComparator);
3907
3908 sql = query.toString();
3909 }
3910 else {
3911 sql = _SQL_SELECT_JOURNALSTRUCTURE.concat(JournalStructureModelImpl.ORDER_BY_JPQL);
3912 }
3913
3914 Session session = null;
3915
3916 try {
3917 session = openSession();
3918
3919 Query q = session.createQuery(sql);
3920
3921 if (orderByComparator == null) {
3922 list = (List<JournalStructure>)QueryUtil.list(q,
3923 getDialect(), start, end, false);
3924
3925 Collections.sort(list);
3926 }
3927 else {
3928 list = (List<JournalStructure>)QueryUtil.list(q,
3929 getDialect(), start, end);
3930 }
3931 }
3932 catch (Exception e) {
3933 throw processException(e);
3934 }
3935 finally {
3936 if (list == null) {
3937 FinderCacheUtil.removeResult(finderPath, finderArgs);
3938 }
3939 else {
3940 cacheResult(list);
3941
3942 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3943 }
3944
3945 closeSession(session);
3946 }
3947 }
3948
3949 return list;
3950 }
3951
3952
3958 public void removeByUuid(String uuid) throws SystemException {
3959 for (JournalStructure journalStructure : findByUuid(uuid)) {
3960 remove(journalStructure);
3961 }
3962 }
3963
3964
3972 public JournalStructure removeByUUID_G(String uuid, long groupId)
3973 throws NoSuchStructureException, SystemException {
3974 JournalStructure journalStructure = findByUUID_G(uuid, groupId);
3975
3976 return remove(journalStructure);
3977 }
3978
3979
3985 public void removeByGroupId(long groupId) throws SystemException {
3986 for (JournalStructure journalStructure : findByGroupId(groupId)) {
3987 remove(journalStructure);
3988 }
3989 }
3990
3991
3997 public void removeByStructureId(String structureId)
3998 throws SystemException {
3999 for (JournalStructure journalStructure : findByStructureId(structureId)) {
4000 remove(journalStructure);
4001 }
4002 }
4003
4004
4010 public void removeByParentStructureId(String parentStructureId)
4011 throws SystemException {
4012 for (JournalStructure journalStructure : findByParentStructureId(
4013 parentStructureId)) {
4014 remove(journalStructure);
4015 }
4016 }
4017
4018
4026 public JournalStructure removeByG_S(long groupId, String structureId)
4027 throws NoSuchStructureException, SystemException {
4028 JournalStructure journalStructure = findByG_S(groupId, structureId);
4029
4030 return remove(journalStructure);
4031 }
4032
4033
4040 public void removeByG_P(long groupId, String parentStructureId)
4041 throws SystemException {
4042 for (JournalStructure journalStructure : findByG_P(groupId,
4043 parentStructureId)) {
4044 remove(journalStructure);
4045 }
4046 }
4047
4048
4053 public void removeAll() throws SystemException {
4054 for (JournalStructure journalStructure : findAll()) {
4055 remove(journalStructure);
4056 }
4057 }
4058
4059
4066 public int countByUuid(String uuid) throws SystemException {
4067 Object[] finderArgs = new Object[] { uuid };
4068
4069 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4070 finderArgs, this);
4071
4072 if (count == null) {
4073 StringBundler query = new StringBundler(2);
4074
4075 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4076
4077 if (uuid == null) {
4078 query.append(_FINDER_COLUMN_UUID_UUID_1);
4079 }
4080 else {
4081 if (uuid.equals(StringPool.BLANK)) {
4082 query.append(_FINDER_COLUMN_UUID_UUID_3);
4083 }
4084 else {
4085 query.append(_FINDER_COLUMN_UUID_UUID_2);
4086 }
4087 }
4088
4089 String sql = query.toString();
4090
4091 Session session = null;
4092
4093 try {
4094 session = openSession();
4095
4096 Query q = session.createQuery(sql);
4097
4098 QueryPos qPos = QueryPos.getInstance(q);
4099
4100 if (uuid != null) {
4101 qPos.add(uuid);
4102 }
4103
4104 count = (Long)q.uniqueResult();
4105 }
4106 catch (Exception e) {
4107 throw processException(e);
4108 }
4109 finally {
4110 if (count == null) {
4111 count = Long.valueOf(0);
4112 }
4113
4114 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4115 finderArgs, count);
4116
4117 closeSession(session);
4118 }
4119 }
4120
4121 return count.intValue();
4122 }
4123
4124
4132 public int countByUUID_G(String uuid, long groupId)
4133 throws SystemException {
4134 Object[] finderArgs = new Object[] { uuid, groupId };
4135
4136 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4137 finderArgs, this);
4138
4139 if (count == null) {
4140 StringBundler query = new StringBundler(3);
4141
4142 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4143
4144 if (uuid == null) {
4145 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4146 }
4147 else {
4148 if (uuid.equals(StringPool.BLANK)) {
4149 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4150 }
4151 else {
4152 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4153 }
4154 }
4155
4156 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4157
4158 String sql = query.toString();
4159
4160 Session session = null;
4161
4162 try {
4163 session = openSession();
4164
4165 Query q = session.createQuery(sql);
4166
4167 QueryPos qPos = QueryPos.getInstance(q);
4168
4169 if (uuid != null) {
4170 qPos.add(uuid);
4171 }
4172
4173 qPos.add(groupId);
4174
4175 count = (Long)q.uniqueResult();
4176 }
4177 catch (Exception e) {
4178 throw processException(e);
4179 }
4180 finally {
4181 if (count == null) {
4182 count = Long.valueOf(0);
4183 }
4184
4185 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4186 finderArgs, count);
4187
4188 closeSession(session);
4189 }
4190 }
4191
4192 return count.intValue();
4193 }
4194
4195
4202 public int countByGroupId(long groupId) throws SystemException {
4203 Object[] finderArgs = new Object[] { groupId };
4204
4205 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4206 finderArgs, this);
4207
4208 if (count == null) {
4209 StringBundler query = new StringBundler(2);
4210
4211 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4212
4213 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4214
4215 String sql = query.toString();
4216
4217 Session session = null;
4218
4219 try {
4220 session = openSession();
4221
4222 Query q = session.createQuery(sql);
4223
4224 QueryPos qPos = QueryPos.getInstance(q);
4225
4226 qPos.add(groupId);
4227
4228 count = (Long)q.uniqueResult();
4229 }
4230 catch (Exception e) {
4231 throw processException(e);
4232 }
4233 finally {
4234 if (count == null) {
4235 count = Long.valueOf(0);
4236 }
4237
4238 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4239 finderArgs, count);
4240
4241 closeSession(session);
4242 }
4243 }
4244
4245 return count.intValue();
4246 }
4247
4248
4255 public int filterCountByGroupId(long groupId) throws SystemException {
4256 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4257 return countByGroupId(groupId);
4258 }
4259
4260 StringBundler query = new StringBundler(2);
4261
4262 query.append(_FILTER_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4263
4264 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4265
4266 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4267 JournalStructure.class.getName(),
4268 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4269
4270 Session session = null;
4271
4272 try {
4273 session = openSession();
4274
4275 SQLQuery q = session.createSQLQuery(sql);
4276
4277 q.addScalar(COUNT_COLUMN_NAME,
4278 com.liferay.portal.kernel.dao.orm.Type.LONG);
4279
4280 QueryPos qPos = QueryPos.getInstance(q);
4281
4282 qPos.add(groupId);
4283
4284 Long count = (Long)q.uniqueResult();
4285
4286 return count.intValue();
4287 }
4288 catch (Exception e) {
4289 throw processException(e);
4290 }
4291 finally {
4292 closeSession(session);
4293 }
4294 }
4295
4296
4303 public int countByStructureId(String structureId) throws SystemException {
4304 Object[] finderArgs = new Object[] { structureId };
4305
4306 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
4307 finderArgs, this);
4308
4309 if (count == null) {
4310 StringBundler query = new StringBundler(2);
4311
4312 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4313
4314 if (structureId == null) {
4315 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4316 }
4317 else {
4318 if (structureId.equals(StringPool.BLANK)) {
4319 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4320 }
4321 else {
4322 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4323 }
4324 }
4325
4326 String sql = query.toString();
4327
4328 Session session = null;
4329
4330 try {
4331 session = openSession();
4332
4333 Query q = session.createQuery(sql);
4334
4335 QueryPos qPos = QueryPos.getInstance(q);
4336
4337 if (structureId != null) {
4338 qPos.add(structureId);
4339 }
4340
4341 count = (Long)q.uniqueResult();
4342 }
4343 catch (Exception e) {
4344 throw processException(e);
4345 }
4346 finally {
4347 if (count == null) {
4348 count = Long.valueOf(0);
4349 }
4350
4351 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
4352 finderArgs, count);
4353
4354 closeSession(session);
4355 }
4356 }
4357
4358 return count.intValue();
4359 }
4360
4361
4368 public int countByParentStructureId(String parentStructureId)
4369 throws SystemException {
4370 Object[] finderArgs = new Object[] { parentStructureId };
4371
4372 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID,
4373 finderArgs, this);
4374
4375 if (count == null) {
4376 StringBundler query = new StringBundler(2);
4377
4378 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4379
4380 if (parentStructureId == null) {
4381 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_1);
4382 }
4383 else {
4384 if (parentStructureId.equals(StringPool.BLANK)) {
4385 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_3);
4386 }
4387 else {
4388 query.append(_FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2);
4389 }
4390 }
4391
4392 String sql = query.toString();
4393
4394 Session session = null;
4395
4396 try {
4397 session = openSession();
4398
4399 Query q = session.createQuery(sql);
4400
4401 QueryPos qPos = QueryPos.getInstance(q);
4402
4403 if (parentStructureId != null) {
4404 qPos.add(parentStructureId);
4405 }
4406
4407 count = (Long)q.uniqueResult();
4408 }
4409 catch (Exception e) {
4410 throw processException(e);
4411 }
4412 finally {
4413 if (count == null) {
4414 count = Long.valueOf(0);
4415 }
4416
4417 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTSTRUCTUREID,
4418 finderArgs, count);
4419
4420 closeSession(session);
4421 }
4422 }
4423
4424 return count.intValue();
4425 }
4426
4427
4435 public int countByG_S(long groupId, String structureId)
4436 throws SystemException {
4437 Object[] finderArgs = new Object[] { groupId, structureId };
4438
4439 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
4440 finderArgs, this);
4441
4442 if (count == null) {
4443 StringBundler query = new StringBundler(3);
4444
4445 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4446
4447 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4448
4449 if (structureId == null) {
4450 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
4451 }
4452 else {
4453 if (structureId.equals(StringPool.BLANK)) {
4454 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
4455 }
4456 else {
4457 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
4458 }
4459 }
4460
4461 String sql = query.toString();
4462
4463 Session session = null;
4464
4465 try {
4466 session = openSession();
4467
4468 Query q = session.createQuery(sql);
4469
4470 QueryPos qPos = QueryPos.getInstance(q);
4471
4472 qPos.add(groupId);
4473
4474 if (structureId != null) {
4475 qPos.add(structureId);
4476 }
4477
4478 count = (Long)q.uniqueResult();
4479 }
4480 catch (Exception e) {
4481 throw processException(e);
4482 }
4483 finally {
4484 if (count == null) {
4485 count = Long.valueOf(0);
4486 }
4487
4488 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
4489 count);
4490
4491 closeSession(session);
4492 }
4493 }
4494
4495 return count.intValue();
4496 }
4497
4498
4506 public int countByG_P(long groupId, String parentStructureId)
4507 throws SystemException {
4508 Object[] finderArgs = new Object[] { groupId, parentStructureId };
4509
4510 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
4511 finderArgs, this);
4512
4513 if (count == null) {
4514 StringBundler query = new StringBundler(3);
4515
4516 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4517
4518 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4519
4520 if (parentStructureId == null) {
4521 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
4522 }
4523 else {
4524 if (parentStructureId.equals(StringPool.BLANK)) {
4525 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
4526 }
4527 else {
4528 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
4529 }
4530 }
4531
4532 String sql = query.toString();
4533
4534 Session session = null;
4535
4536 try {
4537 session = openSession();
4538
4539 Query q = session.createQuery(sql);
4540
4541 QueryPos qPos = QueryPos.getInstance(q);
4542
4543 qPos.add(groupId);
4544
4545 if (parentStructureId != null) {
4546 qPos.add(parentStructureId);
4547 }
4548
4549 count = (Long)q.uniqueResult();
4550 }
4551 catch (Exception e) {
4552 throw processException(e);
4553 }
4554 finally {
4555 if (count == null) {
4556 count = Long.valueOf(0);
4557 }
4558
4559 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
4560 count);
4561
4562 closeSession(session);
4563 }
4564 }
4565
4566 return count.intValue();
4567 }
4568
4569
4577 public int filterCountByG_P(long groupId, String parentStructureId)
4578 throws SystemException {
4579 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4580 return countByG_P(groupId, parentStructureId);
4581 }
4582
4583 StringBundler query = new StringBundler(3);
4584
4585 query.append(_FILTER_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
4586
4587 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4588
4589 if (parentStructureId == null) {
4590 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
4591 }
4592 else {
4593 if (parentStructureId.equals(StringPool.BLANK)) {
4594 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
4595 }
4596 else {
4597 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
4598 }
4599 }
4600
4601 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4602 JournalStructure.class.getName(),
4603 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4604
4605 Session session = null;
4606
4607 try {
4608 session = openSession();
4609
4610 SQLQuery q = session.createSQLQuery(sql);
4611
4612 q.addScalar(COUNT_COLUMN_NAME,
4613 com.liferay.portal.kernel.dao.orm.Type.LONG);
4614
4615 QueryPos qPos = QueryPos.getInstance(q);
4616
4617 qPos.add(groupId);
4618
4619 if (parentStructureId != null) {
4620 qPos.add(parentStructureId);
4621 }
4622
4623 Long count = (Long)q.uniqueResult();
4624
4625 return count.intValue();
4626 }
4627 catch (Exception e) {
4628 throw processException(e);
4629 }
4630 finally {
4631 closeSession(session);
4632 }
4633 }
4634
4635
4641 public int countAll() throws SystemException {
4642 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4643 FINDER_ARGS_EMPTY, this);
4644
4645 if (count == null) {
4646 Session session = null;
4647
4648 try {
4649 session = openSession();
4650
4651 Query q = session.createQuery(_SQL_COUNT_JOURNALSTRUCTURE);
4652
4653 count = (Long)q.uniqueResult();
4654 }
4655 catch (Exception e) {
4656 throw processException(e);
4657 }
4658 finally {
4659 if (count == null) {
4660 count = Long.valueOf(0);
4661 }
4662
4663 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4664 FINDER_ARGS_EMPTY, count);
4665
4666 closeSession(session);
4667 }
4668 }
4669
4670 return count.intValue();
4671 }
4672
4673
4676 public void afterPropertiesSet() {
4677 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4678 com.liferay.portal.util.PropsUtil.get(
4679 "value.object.listener.com.liferay.portlet.journal.model.JournalStructure")));
4680
4681 if (listenerClassNames.length > 0) {
4682 try {
4683 List<ModelListener<JournalStructure>> listenersList = new ArrayList<ModelListener<JournalStructure>>();
4684
4685 for (String listenerClassName : listenerClassNames) {
4686 Class<?> clazz = getClass();
4687
4688 listenersList.add((ModelListener<JournalStructure>)InstanceFactory.newInstance(
4689 clazz.getClassLoader(), listenerClassName));
4690 }
4691
4692 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4693 }
4694 catch (Exception e) {
4695 _log.error(e);
4696 }
4697 }
4698 }
4699
4700 public void destroy() {
4701 EntityCacheUtil.removeCache(JournalStructureImpl.class.getName());
4702 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4703 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4704 }
4705
4706 @BeanReference(type = JournalArticlePersistence.class)
4707 protected JournalArticlePersistence journalArticlePersistence;
4708 @BeanReference(type = JournalArticleImagePersistence.class)
4709 protected JournalArticleImagePersistence journalArticleImagePersistence;
4710 @BeanReference(type = JournalArticleResourcePersistence.class)
4711 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
4712 @BeanReference(type = JournalContentSearchPersistence.class)
4713 protected JournalContentSearchPersistence journalContentSearchPersistence;
4714 @BeanReference(type = JournalFeedPersistence.class)
4715 protected JournalFeedPersistence journalFeedPersistence;
4716 @BeanReference(type = JournalStructurePersistence.class)
4717 protected JournalStructurePersistence journalStructurePersistence;
4718 @BeanReference(type = JournalTemplatePersistence.class)
4719 protected JournalTemplatePersistence journalTemplatePersistence;
4720 @BeanReference(type = GroupPersistence.class)
4721 protected GroupPersistence groupPersistence;
4722 @BeanReference(type = ResourcePersistence.class)
4723 protected ResourcePersistence resourcePersistence;
4724 @BeanReference(type = UserPersistence.class)
4725 protected UserPersistence userPersistence;
4726 @BeanReference(type = WebDAVPropsPersistence.class)
4727 protected WebDAVPropsPersistence webDAVPropsPersistence;
4728 @BeanReference(type = ExpandoValuePersistence.class)
4729 protected ExpandoValuePersistence expandoValuePersistence;
4730 private static final String _SQL_SELECT_JOURNALSTRUCTURE = "SELECT journalStructure FROM JournalStructure journalStructure";
4731 private static final String _SQL_SELECT_JOURNALSTRUCTURE_WHERE = "SELECT journalStructure FROM JournalStructure journalStructure WHERE ";
4732 private static final String _SQL_COUNT_JOURNALSTRUCTURE = "SELECT COUNT(journalStructure) FROM JournalStructure journalStructure";
4733 private static final String _SQL_COUNT_JOURNALSTRUCTURE_WHERE = "SELECT COUNT(journalStructure) FROM JournalStructure journalStructure WHERE ";
4734 private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalStructure.uuid IS NULL";
4735 private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalStructure.uuid = ?";
4736 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalStructure.uuid IS NULL OR journalStructure.uuid = ?)";
4737 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalStructure.uuid IS NULL AND ";
4738 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalStructure.uuid = ? AND ";
4739 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalStructure.uuid IS NULL OR journalStructure.uuid = ?) AND ";
4740 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalStructure.groupId = ?";
4741 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalStructure.groupId = ?";
4742 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalStructure.structureId IS NULL";
4743 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalStructure.structureId = ?";
4744 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalStructure.structureId IS NULL OR journalStructure.structureId = ?)";
4745 private static final String _FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_1 =
4746 "journalStructure.parentStructureId IS NULL";
4747 private static final String _FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_2 =
4748 "journalStructure.parentStructureId = ?";
4749 private static final String _FINDER_COLUMN_PARENTSTRUCTUREID_PARENTSTRUCTUREID_3 =
4750 "(journalStructure.parentStructureId IS NULL OR journalStructure.parentStructureId = ?)";
4751 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalStructure.groupId = ? AND ";
4752 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalStructure.structureId IS NULL";
4753 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalStructure.structureId = ?";
4754 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalStructure.structureId IS NULL OR journalStructure.structureId = ?)";
4755 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalStructure.groupId = ? AND ";
4756 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1 = "journalStructure.parentStructureId IS NULL";
4757 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2 = "journalStructure.parentStructureId = ?";
4758 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3 = "(journalStructure.parentStructureId IS NULL OR journalStructure.parentStructureId = ?)";
4759 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalStructure.id_";
4760 private static final String _FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE = "SELECT DISTINCT {journalStructure.*} FROM JournalStructure journalStructure WHERE ";
4761 private static final String _FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1 =
4762 "SELECT {JournalStructure.*} FROM (SELECT DISTINCT journalStructure.id_ FROM JournalStructure journalStructure WHERE ";
4763 private static final String _FILTER_SQL_SELECT_JOURNALSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2 =
4764 ") TEMP_TABLE INNER JOIN JournalStructure ON TEMP_TABLE.id_ = JournalStructure.id_";
4765 private static final String _FILTER_SQL_COUNT_JOURNALSTRUCTURE_WHERE = "SELECT COUNT(DISTINCT journalStructure.id_) AS COUNT_VALUE FROM JournalStructure journalStructure WHERE ";
4766 private static final String _FILTER_ENTITY_ALIAS = "journalStructure";
4767 private static final String _FILTER_ENTITY_TABLE = "JournalStructure";
4768 private static final String _ORDER_BY_ENTITY_ALIAS = "journalStructure.";
4769 private static final String _ORDER_BY_ENTITY_TABLE = "JournalStructure.";
4770 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalStructure exists with the primary key ";
4771 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalStructure exists with the key {";
4772 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4773 private static Log _log = LogFactoryUtil.getLog(JournalStructurePersistenceImpl.class);
4774 private static JournalStructure _nullJournalStructure = new JournalStructureImpl() {
4775 @Override
4776 public Object clone() {
4777 return this;
4778 }
4779
4780 @Override
4781 public CacheModel<JournalStructure> toCacheModel() {
4782 return _nullJournalStructureCacheModel;
4783 }
4784 };
4785
4786 private static CacheModel<JournalStructure> _nullJournalStructureCacheModel = new CacheModel<JournalStructure>() {
4787 public JournalStructure toEntityModel() {
4788 return _nullJournalStructure;
4789 }
4790 };
4791 }