1
14
15 package com.liferay.portlet.journal.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.exception.SystemException;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.kernel.util.Validator;
37 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
38 import com.liferay.portal.model.ModelListener;
39 import com.liferay.portal.service.persistence.BatchSessionUtil;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import com.liferay.portlet.journal.NoSuchStructureException;
43 import com.liferay.portlet.journal.model.JournalStructure;
44 import com.liferay.portlet.journal.model.impl.JournalStructureImpl;
45 import com.liferay.portlet.journal.model.impl.JournalStructureModelImpl;
46
47 import java.io.Serializable;
48
49 import java.util.ArrayList;
50 import java.util.Collections;
51 import java.util.List;
52
53
66 public class JournalStructurePersistenceImpl extends BasePersistenceImpl<JournalStructure>
67 implements JournalStructurePersistence {
68 public static final String FINDER_CLASS_NAME_ENTITY = JournalStructureImpl.class.getName();
69 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
70 ".List";
71 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
72 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
73 FINDER_CLASS_NAME_LIST, "findByUuid",
74 new String[] { String.class.getName() });
75 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
76 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
77 FINDER_CLASS_NAME_LIST, "findByUuid",
78 new String[] {
79 String.class.getName(),
80
81 "java.lang.Integer", "java.lang.Integer",
82 "com.liferay.portal.kernel.util.OrderByComparator"
83 });
84 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
85 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
86 FINDER_CLASS_NAME_LIST, "countByUuid",
87 new String[] { String.class.getName() });
88 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
89 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
90 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
91 new String[] { String.class.getName(), Long.class.getName() });
92 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
93 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
94 FINDER_CLASS_NAME_LIST, "countByUUID_G",
95 new String[] { String.class.getName(), Long.class.getName() });
96 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
97 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
98 FINDER_CLASS_NAME_LIST, "findByGroupId",
99 new String[] { Long.class.getName() });
100 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
101 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
102 FINDER_CLASS_NAME_LIST, "findByGroupId",
103 new String[] {
104 Long.class.getName(),
105
106 "java.lang.Integer", "java.lang.Integer",
107 "com.liferay.portal.kernel.util.OrderByComparator"
108 });
109 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
110 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
111 FINDER_CLASS_NAME_LIST, "countByGroupId",
112 new String[] { Long.class.getName() });
113 public static final FinderPath FINDER_PATH_FIND_BY_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
114 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
115 FINDER_CLASS_NAME_LIST, "findByStructureId",
116 new String[] { String.class.getName() });
117 public static final FinderPath FINDER_PATH_FIND_BY_OBC_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
118 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
119 FINDER_CLASS_NAME_LIST, "findByStructureId",
120 new String[] {
121 String.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_COUNT_BY_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
127 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
128 FINDER_CLASS_NAME_LIST, "countByStructureId",
129 new String[] { String.class.getName() });
130 public static final FinderPath FINDER_PATH_FETCH_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
131 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
132 FINDER_CLASS_NAME_ENTITY, "fetchByG_S",
133 new String[] { Long.class.getName(), String.class.getName() });
134 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
135 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
136 FINDER_CLASS_NAME_LIST, "countByG_S",
137 new String[] { Long.class.getName(), String.class.getName() });
138 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
139 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
140 FINDER_CLASS_NAME_LIST, "findByG_P",
141 new String[] { Long.class.getName(), String.class.getName() });
142 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
143 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
144 FINDER_CLASS_NAME_LIST, "findByG_P",
145 new String[] {
146 Long.class.getName(), String.class.getName(),
147
148 "java.lang.Integer", "java.lang.Integer",
149 "com.liferay.portal.kernel.util.OrderByComparator"
150 });
151 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
152 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
153 FINDER_CLASS_NAME_LIST, "countByG_P",
154 new String[] { Long.class.getName(), String.class.getName() });
155 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
156 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
157 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
158 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
159 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
160 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
161
162 public void cacheResult(JournalStructure journalStructure) {
163 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
164 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
165 journalStructure);
166
167 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
168 new Object[] {
169 journalStructure.getUuid(),
170 new Long(journalStructure.getGroupId())
171 }, journalStructure);
172
173 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
174 new Object[] {
175 new Long(journalStructure.getGroupId()),
176
177 journalStructure.getStructureId()
178 }, journalStructure);
179 }
180
181 public void cacheResult(List<JournalStructure> journalStructures) {
182 for (JournalStructure journalStructure : journalStructures) {
183 if (EntityCacheUtil.getResult(
184 JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
185 JournalStructureImpl.class,
186 journalStructure.getPrimaryKey(), this) == null) {
187 cacheResult(journalStructure);
188 }
189 }
190 }
191
192 public void clearCache() {
193 CacheRegistry.clear(JournalStructureImpl.class.getName());
194 EntityCacheUtil.clearCache(JournalStructureImpl.class.getName());
195 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
197 }
198
199 public JournalStructure create(long id) {
200 JournalStructure journalStructure = new JournalStructureImpl();
201
202 journalStructure.setNew(true);
203 journalStructure.setPrimaryKey(id);
204
205 String uuid = PortalUUIDUtil.generate();
206
207 journalStructure.setUuid(uuid);
208
209 return journalStructure;
210 }
211
212 public JournalStructure remove(Serializable primaryKey)
213 throws NoSuchModelException, SystemException {
214 return remove(((Long)primaryKey).longValue());
215 }
216
217 public JournalStructure remove(long id)
218 throws NoSuchStructureException, SystemException {
219 Session session = null;
220
221 try {
222 session = openSession();
223
224 JournalStructure journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
225 new Long(id));
226
227 if (journalStructure == null) {
228 if (_log.isWarnEnabled()) {
229 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
230 }
231
232 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
233 id);
234 }
235
236 return remove(journalStructure);
237 }
238 catch (NoSuchStructureException nsee) {
239 throw nsee;
240 }
241 catch (Exception e) {
242 throw processException(e);
243 }
244 finally {
245 closeSession(session);
246 }
247 }
248
249 public JournalStructure remove(JournalStructure journalStructure)
250 throws SystemException {
251 for (ModelListener<JournalStructure> listener : listeners) {
252 listener.onBeforeRemove(journalStructure);
253 }
254
255 journalStructure = removeImpl(journalStructure);
256
257 for (ModelListener<JournalStructure> listener : listeners) {
258 listener.onAfterRemove(journalStructure);
259 }
260
261 return journalStructure;
262 }
263
264 protected JournalStructure removeImpl(JournalStructure journalStructure)
265 throws SystemException {
266 journalStructure = toUnwrappedModel(journalStructure);
267
268 Session session = null;
269
270 try {
271 session = openSession();
272
273 if (journalStructure.isCachedModel() ||
274 BatchSessionUtil.isEnabled()) {
275 Object staleObject = session.get(JournalStructureImpl.class,
276 journalStructure.getPrimaryKeyObj());
277
278 if (staleObject != null) {
279 session.evict(staleObject);
280 }
281 }
282
283 session.delete(journalStructure);
284
285 session.flush();
286 }
287 catch (Exception e) {
288 throw processException(e);
289 }
290 finally {
291 closeSession(session);
292 }
293
294 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
295
296 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
297
298 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
299 new Object[] {
300 journalStructureModelImpl.getOriginalUuid(),
301 new Long(journalStructureModelImpl.getOriginalGroupId())
302 });
303
304 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
305 new Object[] {
306 new Long(journalStructureModelImpl.getOriginalGroupId()),
307
308 journalStructureModelImpl.getOriginalStructureId()
309 });
310
311 EntityCacheUtil.removeResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
312 JournalStructureImpl.class, journalStructure.getPrimaryKey());
313
314 return journalStructure;
315 }
316
317 public JournalStructure updateImpl(
318 com.liferay.portlet.journal.model.JournalStructure journalStructure,
319 boolean merge) throws SystemException {
320 journalStructure = toUnwrappedModel(journalStructure);
321
322 boolean isNew = journalStructure.isNew();
323
324 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
325
326 if (Validator.isNull(journalStructure.getUuid())) {
327 String uuid = PortalUUIDUtil.generate();
328
329 journalStructure.setUuid(uuid);
330 }
331
332 Session session = null;
333
334 try {
335 session = openSession();
336
337 BatchSessionUtil.update(session, journalStructure, merge);
338
339 journalStructure.setNew(false);
340 }
341 catch (Exception e) {
342 throw processException(e);
343 }
344 finally {
345 closeSession(session);
346 }
347
348 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
349
350 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
351 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
352 journalStructure);
353
354 if (!isNew &&
355 (!Validator.equals(journalStructure.getUuid(),
356 journalStructureModelImpl.getOriginalUuid()) ||
357 (journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()))) {
358 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
359 new Object[] {
360 journalStructureModelImpl.getOriginalUuid(),
361 new Long(journalStructureModelImpl.getOriginalGroupId())
362 });
363 }
364
365 if (isNew ||
366 (!Validator.equals(journalStructure.getUuid(),
367 journalStructureModelImpl.getOriginalUuid()) ||
368 (journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()))) {
369 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
370 new Object[] {
371 journalStructure.getUuid(),
372 new Long(journalStructure.getGroupId())
373 }, journalStructure);
374 }
375
376 if (!isNew &&
377 ((journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()) ||
378 !Validator.equals(journalStructure.getStructureId(),
379 journalStructureModelImpl.getOriginalStructureId()))) {
380 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
381 new Object[] {
382 new Long(journalStructureModelImpl.getOriginalGroupId()),
383
384 journalStructureModelImpl.getOriginalStructureId()
385 });
386 }
387
388 if (isNew ||
389 ((journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()) ||
390 !Validator.equals(journalStructure.getStructureId(),
391 journalStructureModelImpl.getOriginalStructureId()))) {
392 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
393 new Object[] {
394 new Long(journalStructure.getGroupId()),
395
396 journalStructure.getStructureId()
397 }, journalStructure);
398 }
399
400 return journalStructure;
401 }
402
403 protected JournalStructure toUnwrappedModel(
404 JournalStructure journalStructure) {
405 if (journalStructure instanceof JournalStructureImpl) {
406 return journalStructure;
407 }
408
409 JournalStructureImpl journalStructureImpl = new JournalStructureImpl();
410
411 journalStructureImpl.setNew(journalStructure.isNew());
412 journalStructureImpl.setPrimaryKey(journalStructure.getPrimaryKey());
413
414 journalStructureImpl.setUuid(journalStructure.getUuid());
415 journalStructureImpl.setId(journalStructure.getId());
416 journalStructureImpl.setGroupId(journalStructure.getGroupId());
417 journalStructureImpl.setCompanyId(journalStructure.getCompanyId());
418 journalStructureImpl.setUserId(journalStructure.getUserId());
419 journalStructureImpl.setUserName(journalStructure.getUserName());
420 journalStructureImpl.setCreateDate(journalStructure.getCreateDate());
421 journalStructureImpl.setModifiedDate(journalStructure.getModifiedDate());
422 journalStructureImpl.setStructureId(journalStructure.getStructureId());
423 journalStructureImpl.setParentStructureId(journalStructure.getParentStructureId());
424 journalStructureImpl.setName(journalStructure.getName());
425 journalStructureImpl.setDescription(journalStructure.getDescription());
426 journalStructureImpl.setXsd(journalStructure.getXsd());
427
428 return journalStructureImpl;
429 }
430
431 public JournalStructure findByPrimaryKey(Serializable primaryKey)
432 throws NoSuchModelException, SystemException {
433 return findByPrimaryKey(((Long)primaryKey).longValue());
434 }
435
436 public JournalStructure findByPrimaryKey(long id)
437 throws NoSuchStructureException, SystemException {
438 JournalStructure journalStructure = fetchByPrimaryKey(id);
439
440 if (journalStructure == null) {
441 if (_log.isWarnEnabled()) {
442 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
443 }
444
445 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
446 id);
447 }
448
449 return journalStructure;
450 }
451
452 public JournalStructure fetchByPrimaryKey(Serializable primaryKey)
453 throws SystemException {
454 return fetchByPrimaryKey(((Long)primaryKey).longValue());
455 }
456
457 public JournalStructure fetchByPrimaryKey(long id)
458 throws SystemException {
459 JournalStructure journalStructure = (JournalStructure)EntityCacheUtil.getResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
460 JournalStructureImpl.class, id, this);
461
462 if (journalStructure == null) {
463 Session session = null;
464
465 try {
466 session = openSession();
467
468 journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
469 new Long(id));
470 }
471 catch (Exception e) {
472 throw processException(e);
473 }
474 finally {
475 if (journalStructure != null) {
476 cacheResult(journalStructure);
477 }
478
479 closeSession(session);
480 }
481 }
482
483 return journalStructure;
484 }
485
486 public List<JournalStructure> findByUuid(String uuid)
487 throws SystemException {
488 Object[] finderArgs = new Object[] { uuid };
489
490 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
491 finderArgs, this);
492
493 if (list == null) {
494 Session session = null;
495
496 try {
497 session = openSession();
498
499 StringBundler query = new StringBundler(3);
500
501 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
502
503 if (uuid == null) {
504 query.append(_FINDER_COLUMN_UUID_UUID_1);
505 }
506 else {
507 if (uuid.equals(StringPool.BLANK)) {
508 query.append(_FINDER_COLUMN_UUID_UUID_3);
509 }
510 else {
511 query.append(_FINDER_COLUMN_UUID_UUID_2);
512 }
513 }
514
515 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
516
517 String sql = query.toString();
518
519 Query q = session.createQuery(sql);
520
521 QueryPos qPos = QueryPos.getInstance(q);
522
523 if (uuid != null) {
524 qPos.add(uuid);
525 }
526
527 list = q.list();
528 }
529 catch (Exception e) {
530 throw processException(e);
531 }
532 finally {
533 if (list == null) {
534 list = new ArrayList<JournalStructure>();
535 }
536
537 cacheResult(list);
538
539 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
540 list);
541
542 closeSession(session);
543 }
544 }
545
546 return list;
547 }
548
549 public List<JournalStructure> findByUuid(String uuid, int start, int end)
550 throws SystemException {
551 return findByUuid(uuid, start, end, null);
552 }
553
554 public List<JournalStructure> findByUuid(String uuid, int start, int end,
555 OrderByComparator obc) throws SystemException {
556 Object[] finderArgs = new Object[] {
557 uuid,
558
559 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
560 };
561
562 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
563 finderArgs, this);
564
565 if (list == null) {
566 Session session = null;
567
568 try {
569 session = openSession();
570
571 StringBundler query = null;
572
573 if (obc != null) {
574 query = new StringBundler(3 +
575 (obc.getOrderByFields().length * 3));
576 }
577 else {
578 query = new StringBundler(3);
579 }
580
581 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
582
583 if (uuid == null) {
584 query.append(_FINDER_COLUMN_UUID_UUID_1);
585 }
586 else {
587 if (uuid.equals(StringPool.BLANK)) {
588 query.append(_FINDER_COLUMN_UUID_UUID_3);
589 }
590 else {
591 query.append(_FINDER_COLUMN_UUID_UUID_2);
592 }
593 }
594
595 if (obc != null) {
596 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
597 }
598
599 else {
600 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
601 }
602
603 String sql = query.toString();
604
605 Query q = session.createQuery(sql);
606
607 QueryPos qPos = QueryPos.getInstance(q);
608
609 if (uuid != null) {
610 qPos.add(uuid);
611 }
612
613 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
614 start, end);
615 }
616 catch (Exception e) {
617 throw processException(e);
618 }
619 finally {
620 if (list == null) {
621 list = new ArrayList<JournalStructure>();
622 }
623
624 cacheResult(list);
625
626 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
627 finderArgs, list);
628
629 closeSession(session);
630 }
631 }
632
633 return list;
634 }
635
636 public JournalStructure findByUuid_First(String uuid, OrderByComparator obc)
637 throws NoSuchStructureException, SystemException {
638 List<JournalStructure> list = findByUuid(uuid, 0, 1, obc);
639
640 if (list.isEmpty()) {
641 StringBundler msg = new StringBundler(4);
642
643 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
644
645 msg.append("uuid=");
646 msg.append(uuid);
647
648 msg.append(StringPool.CLOSE_CURLY_BRACE);
649
650 throw new NoSuchStructureException(msg.toString());
651 }
652 else {
653 return list.get(0);
654 }
655 }
656
657 public JournalStructure findByUuid_Last(String uuid, OrderByComparator obc)
658 throws NoSuchStructureException, SystemException {
659 int count = countByUuid(uuid);
660
661 List<JournalStructure> list = findByUuid(uuid, count - 1, count, obc);
662
663 if (list.isEmpty()) {
664 StringBundler msg = new StringBundler(4);
665
666 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
667
668 msg.append("uuid=");
669 msg.append(uuid);
670
671 msg.append(StringPool.CLOSE_CURLY_BRACE);
672
673 throw new NoSuchStructureException(msg.toString());
674 }
675 else {
676 return list.get(0);
677 }
678 }
679
680 public JournalStructure[] findByUuid_PrevAndNext(long id, String uuid,
681 OrderByComparator obc) throws NoSuchStructureException, SystemException {
682 JournalStructure journalStructure = findByPrimaryKey(id);
683
684 int count = countByUuid(uuid);
685
686 Session session = null;
687
688 try {
689 session = openSession();
690
691 StringBundler query = null;
692
693 if (obc != null) {
694 query = new StringBundler(3 +
695 (obc.getOrderByFields().length * 3));
696 }
697 else {
698 query = new StringBundler(3);
699 }
700
701 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
702
703 if (uuid == null) {
704 query.append(_FINDER_COLUMN_UUID_UUID_1);
705 }
706 else {
707 if (uuid.equals(StringPool.BLANK)) {
708 query.append(_FINDER_COLUMN_UUID_UUID_3);
709 }
710 else {
711 query.append(_FINDER_COLUMN_UUID_UUID_2);
712 }
713 }
714
715 if (obc != null) {
716 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
717 }
718
719 else {
720 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
721 }
722
723 String sql = query.toString();
724
725 Query q = session.createQuery(sql);
726
727 QueryPos qPos = QueryPos.getInstance(q);
728
729 if (uuid != null) {
730 qPos.add(uuid);
731 }
732
733 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
734 journalStructure);
735
736 JournalStructure[] array = new JournalStructureImpl[3];
737
738 array[0] = (JournalStructure)objArray[0];
739 array[1] = (JournalStructure)objArray[1];
740 array[2] = (JournalStructure)objArray[2];
741
742 return array;
743 }
744 catch (Exception e) {
745 throw processException(e);
746 }
747 finally {
748 closeSession(session);
749 }
750 }
751
752 public JournalStructure findByUUID_G(String uuid, long groupId)
753 throws NoSuchStructureException, SystemException {
754 JournalStructure journalStructure = fetchByUUID_G(uuid, groupId);
755
756 if (journalStructure == null) {
757 StringBundler msg = new StringBundler(6);
758
759 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
760
761 msg.append("uuid=");
762 msg.append(uuid);
763
764 msg.append(", groupId=");
765 msg.append(groupId);
766
767 msg.append(StringPool.CLOSE_CURLY_BRACE);
768
769 if (_log.isWarnEnabled()) {
770 _log.warn(msg.toString());
771 }
772
773 throw new NoSuchStructureException(msg.toString());
774 }
775
776 return journalStructure;
777 }
778
779 public JournalStructure fetchByUUID_G(String uuid, long groupId)
780 throws SystemException {
781 return fetchByUUID_G(uuid, groupId, true);
782 }
783
784 public JournalStructure fetchByUUID_G(String uuid, long groupId,
785 boolean retrieveFromCache) throws SystemException {
786 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
787
788 Object result = null;
789
790 if (retrieveFromCache) {
791 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
792 finderArgs, this);
793 }
794
795 if (result == null) {
796 Session session = null;
797
798 try {
799 session = openSession();
800
801 StringBundler query = new StringBundler(4);
802
803 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
804
805 if (uuid == null) {
806 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
807 }
808 else {
809 if (uuid.equals(StringPool.BLANK)) {
810 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
811 }
812 else {
813 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
814 }
815 }
816
817 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
818
819 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
820
821 String sql = query.toString();
822
823 Query q = session.createQuery(sql);
824
825 QueryPos qPos = QueryPos.getInstance(q);
826
827 if (uuid != null) {
828 qPos.add(uuid);
829 }
830
831 qPos.add(groupId);
832
833 List<JournalStructure> list = q.list();
834
835 result = list;
836
837 JournalStructure journalStructure = null;
838
839 if (list.isEmpty()) {
840 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
841 finderArgs, list);
842 }
843 else {
844 journalStructure = list.get(0);
845
846 cacheResult(journalStructure);
847
848 if ((journalStructure.getUuid() == null) ||
849 !journalStructure.getUuid().equals(uuid) ||
850 (journalStructure.getGroupId() != groupId)) {
851 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
852 finderArgs, journalStructure);
853 }
854 }
855
856 return journalStructure;
857 }
858 catch (Exception e) {
859 throw processException(e);
860 }
861 finally {
862 if (result == null) {
863 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
864 finderArgs, new ArrayList<JournalStructure>());
865 }
866
867 closeSession(session);
868 }
869 }
870 else {
871 if (result instanceof List<?>) {
872 return null;
873 }
874 else {
875 return (JournalStructure)result;
876 }
877 }
878 }
879
880 public List<JournalStructure> findByGroupId(long groupId)
881 throws SystemException {
882 Object[] finderArgs = new Object[] { new Long(groupId) };
883
884 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
885 finderArgs, this);
886
887 if (list == null) {
888 Session session = null;
889
890 try {
891 session = openSession();
892
893 StringBundler query = new StringBundler(3);
894
895 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
896
897 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
898
899 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
900
901 String sql = query.toString();
902
903 Query q = session.createQuery(sql);
904
905 QueryPos qPos = QueryPos.getInstance(q);
906
907 qPos.add(groupId);
908
909 list = q.list();
910 }
911 catch (Exception e) {
912 throw processException(e);
913 }
914 finally {
915 if (list == null) {
916 list = new ArrayList<JournalStructure>();
917 }
918
919 cacheResult(list);
920
921 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
922 finderArgs, list);
923
924 closeSession(session);
925 }
926 }
927
928 return list;
929 }
930
931 public List<JournalStructure> findByGroupId(long groupId, int start, int end)
932 throws SystemException {
933 return findByGroupId(groupId, start, end, null);
934 }
935
936 public List<JournalStructure> findByGroupId(long groupId, int start,
937 int end, OrderByComparator obc) throws SystemException {
938 Object[] finderArgs = new Object[] {
939 new Long(groupId),
940
941 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
942 };
943
944 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
945 finderArgs, this);
946
947 if (list == null) {
948 Session session = null;
949
950 try {
951 session = openSession();
952
953 StringBundler query = null;
954
955 if (obc != null) {
956 query = new StringBundler(3 +
957 (obc.getOrderByFields().length * 3));
958 }
959 else {
960 query = new StringBundler(3);
961 }
962
963 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
964
965 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
966
967 if (obc != null) {
968 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
969 }
970
971 else {
972 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
973 }
974
975 String sql = query.toString();
976
977 Query q = session.createQuery(sql);
978
979 QueryPos qPos = QueryPos.getInstance(q);
980
981 qPos.add(groupId);
982
983 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
984 start, end);
985 }
986 catch (Exception e) {
987 throw processException(e);
988 }
989 finally {
990 if (list == null) {
991 list = new ArrayList<JournalStructure>();
992 }
993
994 cacheResult(list);
995
996 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
997 finderArgs, list);
998
999 closeSession(session);
1000 }
1001 }
1002
1003 return list;
1004 }
1005
1006 public JournalStructure findByGroupId_First(long groupId,
1007 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1008 List<JournalStructure> list = findByGroupId(groupId, 0, 1, obc);
1009
1010 if (list.isEmpty()) {
1011 StringBundler msg = new StringBundler(4);
1012
1013 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1014
1015 msg.append("groupId=");
1016 msg.append(groupId);
1017
1018 msg.append(StringPool.CLOSE_CURLY_BRACE);
1019
1020 throw new NoSuchStructureException(msg.toString());
1021 }
1022 else {
1023 return list.get(0);
1024 }
1025 }
1026
1027 public JournalStructure findByGroupId_Last(long groupId,
1028 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1029 int count = countByGroupId(groupId);
1030
1031 List<JournalStructure> list = findByGroupId(groupId, count - 1, count,
1032 obc);
1033
1034 if (list.isEmpty()) {
1035 StringBundler msg = new StringBundler(4);
1036
1037 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1038
1039 msg.append("groupId=");
1040 msg.append(groupId);
1041
1042 msg.append(StringPool.CLOSE_CURLY_BRACE);
1043
1044 throw new NoSuchStructureException(msg.toString());
1045 }
1046 else {
1047 return list.get(0);
1048 }
1049 }
1050
1051 public JournalStructure[] findByGroupId_PrevAndNext(long id, long groupId,
1052 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1053 JournalStructure journalStructure = findByPrimaryKey(id);
1054
1055 int count = countByGroupId(groupId);
1056
1057 Session session = null;
1058
1059 try {
1060 session = openSession();
1061
1062 StringBundler query = null;
1063
1064 if (obc != null) {
1065 query = new StringBundler(3 +
1066 (obc.getOrderByFields().length * 3));
1067 }
1068 else {
1069 query = new StringBundler(3);
1070 }
1071
1072 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1073
1074 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1075
1076 if (obc != null) {
1077 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1078 }
1079
1080 else {
1081 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1082 }
1083
1084 String sql = query.toString();
1085
1086 Query q = session.createQuery(sql);
1087
1088 QueryPos qPos = QueryPos.getInstance(q);
1089
1090 qPos.add(groupId);
1091
1092 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1093 journalStructure);
1094
1095 JournalStructure[] array = new JournalStructureImpl[3];
1096
1097 array[0] = (JournalStructure)objArray[0];
1098 array[1] = (JournalStructure)objArray[1];
1099 array[2] = (JournalStructure)objArray[2];
1100
1101 return array;
1102 }
1103 catch (Exception e) {
1104 throw processException(e);
1105 }
1106 finally {
1107 closeSession(session);
1108 }
1109 }
1110
1111 public List<JournalStructure> findByStructureId(String structureId)
1112 throws SystemException {
1113 Object[] finderArgs = new Object[] { structureId };
1114
1115 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_STRUCTUREID,
1116 finderArgs, this);
1117
1118 if (list == null) {
1119 Session session = null;
1120
1121 try {
1122 session = openSession();
1123
1124 StringBundler query = new StringBundler(3);
1125
1126 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1127
1128 if (structureId == null) {
1129 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
1130 }
1131 else {
1132 if (structureId.equals(StringPool.BLANK)) {
1133 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
1134 }
1135 else {
1136 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1137 }
1138 }
1139
1140 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1141
1142 String sql = query.toString();
1143
1144 Query q = session.createQuery(sql);
1145
1146 QueryPos qPos = QueryPos.getInstance(q);
1147
1148 if (structureId != null) {
1149 qPos.add(structureId);
1150 }
1151
1152 list = q.list();
1153 }
1154 catch (Exception e) {
1155 throw processException(e);
1156 }
1157 finally {
1158 if (list == null) {
1159 list = new ArrayList<JournalStructure>();
1160 }
1161
1162 cacheResult(list);
1163
1164 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_STRUCTUREID,
1165 finderArgs, list);
1166
1167 closeSession(session);
1168 }
1169 }
1170
1171 return list;
1172 }
1173
1174 public List<JournalStructure> findByStructureId(String structureId,
1175 int start, int end) throws SystemException {
1176 return findByStructureId(structureId, start, end, null);
1177 }
1178
1179 public List<JournalStructure> findByStructureId(String structureId,
1180 int start, int end, OrderByComparator obc) throws SystemException {
1181 Object[] finderArgs = new Object[] {
1182 structureId,
1183
1184 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1185 };
1186
1187 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_STRUCTUREID,
1188 finderArgs, this);
1189
1190 if (list == null) {
1191 Session session = null;
1192
1193 try {
1194 session = openSession();
1195
1196 StringBundler query = null;
1197
1198 if (obc != null) {
1199 query = new StringBundler(3 +
1200 (obc.getOrderByFields().length * 3));
1201 }
1202 else {
1203 query = new StringBundler(3);
1204 }
1205
1206 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1207
1208 if (structureId == null) {
1209 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
1210 }
1211 else {
1212 if (structureId.equals(StringPool.BLANK)) {
1213 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
1214 }
1215 else {
1216 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1217 }
1218 }
1219
1220 if (obc != null) {
1221 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1222 }
1223
1224 else {
1225 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1226 }
1227
1228 String sql = query.toString();
1229
1230 Query q = session.createQuery(sql);
1231
1232 QueryPos qPos = QueryPos.getInstance(q);
1233
1234 if (structureId != null) {
1235 qPos.add(structureId);
1236 }
1237
1238 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1239 start, end);
1240 }
1241 catch (Exception e) {
1242 throw processException(e);
1243 }
1244 finally {
1245 if (list == null) {
1246 list = new ArrayList<JournalStructure>();
1247 }
1248
1249 cacheResult(list);
1250
1251 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_STRUCTUREID,
1252 finderArgs, list);
1253
1254 closeSession(session);
1255 }
1256 }
1257
1258 return list;
1259 }
1260
1261 public JournalStructure findByStructureId_First(String structureId,
1262 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1263 List<JournalStructure> list = findByStructureId(structureId, 0, 1, obc);
1264
1265 if (list.isEmpty()) {
1266 StringBundler msg = new StringBundler(4);
1267
1268 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1269
1270 msg.append("structureId=");
1271 msg.append(structureId);
1272
1273 msg.append(StringPool.CLOSE_CURLY_BRACE);
1274
1275 throw new NoSuchStructureException(msg.toString());
1276 }
1277 else {
1278 return list.get(0);
1279 }
1280 }
1281
1282 public JournalStructure findByStructureId_Last(String structureId,
1283 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1284 int count = countByStructureId(structureId);
1285
1286 List<JournalStructure> list = findByStructureId(structureId, count - 1,
1287 count, obc);
1288
1289 if (list.isEmpty()) {
1290 StringBundler msg = new StringBundler(4);
1291
1292 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1293
1294 msg.append("structureId=");
1295 msg.append(structureId);
1296
1297 msg.append(StringPool.CLOSE_CURLY_BRACE);
1298
1299 throw new NoSuchStructureException(msg.toString());
1300 }
1301 else {
1302 return list.get(0);
1303 }
1304 }
1305
1306 public JournalStructure[] findByStructureId_PrevAndNext(long id,
1307 String structureId, OrderByComparator obc)
1308 throws NoSuchStructureException, SystemException {
1309 JournalStructure journalStructure = findByPrimaryKey(id);
1310
1311 int count = countByStructureId(structureId);
1312
1313 Session session = null;
1314
1315 try {
1316 session = openSession();
1317
1318 StringBundler query = null;
1319
1320 if (obc != null) {
1321 query = new StringBundler(3 +
1322 (obc.getOrderByFields().length * 3));
1323 }
1324 else {
1325 query = new StringBundler(3);
1326 }
1327
1328 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1329
1330 if (structureId == null) {
1331 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
1332 }
1333 else {
1334 if (structureId.equals(StringPool.BLANK)) {
1335 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
1336 }
1337 else {
1338 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1339 }
1340 }
1341
1342 if (obc != null) {
1343 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1344 }
1345
1346 else {
1347 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1348 }
1349
1350 String sql = query.toString();
1351
1352 Query q = session.createQuery(sql);
1353
1354 QueryPos qPos = QueryPos.getInstance(q);
1355
1356 if (structureId != null) {
1357 qPos.add(structureId);
1358 }
1359
1360 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1361 journalStructure);
1362
1363 JournalStructure[] array = new JournalStructureImpl[3];
1364
1365 array[0] = (JournalStructure)objArray[0];
1366 array[1] = (JournalStructure)objArray[1];
1367 array[2] = (JournalStructure)objArray[2];
1368
1369 return array;
1370 }
1371 catch (Exception e) {
1372 throw processException(e);
1373 }
1374 finally {
1375 closeSession(session);
1376 }
1377 }
1378
1379 public JournalStructure findByG_S(long groupId, String structureId)
1380 throws NoSuchStructureException, SystemException {
1381 JournalStructure journalStructure = fetchByG_S(groupId, structureId);
1382
1383 if (journalStructure == null) {
1384 StringBundler msg = new StringBundler(6);
1385
1386 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1387
1388 msg.append("groupId=");
1389 msg.append(groupId);
1390
1391 msg.append(", structureId=");
1392 msg.append(structureId);
1393
1394 msg.append(StringPool.CLOSE_CURLY_BRACE);
1395
1396 if (_log.isWarnEnabled()) {
1397 _log.warn(msg.toString());
1398 }
1399
1400 throw new NoSuchStructureException(msg.toString());
1401 }
1402
1403 return journalStructure;
1404 }
1405
1406 public JournalStructure fetchByG_S(long groupId, String structureId)
1407 throws SystemException {
1408 return fetchByG_S(groupId, structureId, true);
1409 }
1410
1411 public JournalStructure fetchByG_S(long groupId, String structureId,
1412 boolean retrieveFromCache) throws SystemException {
1413 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
1414
1415 Object result = null;
1416
1417 if (retrieveFromCache) {
1418 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_S,
1419 finderArgs, this);
1420 }
1421
1422 if (result == null) {
1423 Session session = null;
1424
1425 try {
1426 session = openSession();
1427
1428 StringBundler query = new StringBundler(4);
1429
1430 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1431
1432 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1433
1434 if (structureId == null) {
1435 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
1436 }
1437 else {
1438 if (structureId.equals(StringPool.BLANK)) {
1439 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
1440 }
1441 else {
1442 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
1443 }
1444 }
1445
1446 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1447
1448 String sql = query.toString();
1449
1450 Query q = session.createQuery(sql);
1451
1452 QueryPos qPos = QueryPos.getInstance(q);
1453
1454 qPos.add(groupId);
1455
1456 if (structureId != null) {
1457 qPos.add(structureId);
1458 }
1459
1460 List<JournalStructure> list = q.list();
1461
1462 result = list;
1463
1464 JournalStructure journalStructure = null;
1465
1466 if (list.isEmpty()) {
1467 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
1468 finderArgs, list);
1469 }
1470 else {
1471 journalStructure = list.get(0);
1472
1473 cacheResult(journalStructure);
1474
1475 if ((journalStructure.getGroupId() != groupId) ||
1476 (journalStructure.getStructureId() == null) ||
1477 !journalStructure.getStructureId()
1478 .equals(structureId)) {
1479 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
1480 finderArgs, journalStructure);
1481 }
1482 }
1483
1484 return journalStructure;
1485 }
1486 catch (Exception e) {
1487 throw processException(e);
1488 }
1489 finally {
1490 if (result == null) {
1491 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
1492 finderArgs, new ArrayList<JournalStructure>());
1493 }
1494
1495 closeSession(session);
1496 }
1497 }
1498 else {
1499 if (result instanceof List<?>) {
1500 return null;
1501 }
1502 else {
1503 return (JournalStructure)result;
1504 }
1505 }
1506 }
1507
1508 public List<JournalStructure> findByG_P(long groupId,
1509 String parentStructureId) throws SystemException {
1510 Object[] finderArgs = new Object[] { new Long(groupId), parentStructureId };
1511
1512 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
1513 finderArgs, this);
1514
1515 if (list == null) {
1516 Session session = null;
1517
1518 try {
1519 session = openSession();
1520
1521 StringBundler query = new StringBundler(4);
1522
1523 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1524
1525 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1526
1527 if (parentStructureId == null) {
1528 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
1529 }
1530 else {
1531 if (parentStructureId.equals(StringPool.BLANK)) {
1532 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
1533 }
1534 else {
1535 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
1536 }
1537 }
1538
1539 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1540
1541 String sql = query.toString();
1542
1543 Query q = session.createQuery(sql);
1544
1545 QueryPos qPos = QueryPos.getInstance(q);
1546
1547 qPos.add(groupId);
1548
1549 if (parentStructureId != null) {
1550 qPos.add(parentStructureId);
1551 }
1552
1553 list = q.list();
1554 }
1555 catch (Exception e) {
1556 throw processException(e);
1557 }
1558 finally {
1559 if (list == null) {
1560 list = new ArrayList<JournalStructure>();
1561 }
1562
1563 cacheResult(list);
1564
1565 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1566 list);
1567
1568 closeSession(session);
1569 }
1570 }
1571
1572 return list;
1573 }
1574
1575 public List<JournalStructure> findByG_P(long groupId,
1576 String parentStructureId, int start, int end) throws SystemException {
1577 return findByG_P(groupId, parentStructureId, start, end, null);
1578 }
1579
1580 public List<JournalStructure> findByG_P(long groupId,
1581 String parentStructureId, int start, int end, OrderByComparator obc)
1582 throws SystemException {
1583 Object[] finderArgs = new Object[] {
1584 new Long(groupId),
1585
1586 parentStructureId,
1587
1588 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1589 };
1590
1591 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P,
1592 finderArgs, this);
1593
1594 if (list == null) {
1595 Session session = null;
1596
1597 try {
1598 session = openSession();
1599
1600 StringBundler query = null;
1601
1602 if (obc != null) {
1603 query = new StringBundler(4 +
1604 (obc.getOrderByFields().length * 3));
1605 }
1606 else {
1607 query = new StringBundler(4);
1608 }
1609
1610 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1611
1612 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1613
1614 if (parentStructureId == null) {
1615 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
1616 }
1617 else {
1618 if (parentStructureId.equals(StringPool.BLANK)) {
1619 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
1620 }
1621 else {
1622 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
1623 }
1624 }
1625
1626 if (obc != null) {
1627 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1628 }
1629
1630 else {
1631 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1632 }
1633
1634 String sql = query.toString();
1635
1636 Query q = session.createQuery(sql);
1637
1638 QueryPos qPos = QueryPos.getInstance(q);
1639
1640 qPos.add(groupId);
1641
1642 if (parentStructureId != null) {
1643 qPos.add(parentStructureId);
1644 }
1645
1646 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1647 start, end);
1648 }
1649 catch (Exception e) {
1650 throw processException(e);
1651 }
1652 finally {
1653 if (list == null) {
1654 list = new ArrayList<JournalStructure>();
1655 }
1656
1657 cacheResult(list);
1658
1659 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P,
1660 finderArgs, list);
1661
1662 closeSession(session);
1663 }
1664 }
1665
1666 return list;
1667 }
1668
1669 public JournalStructure findByG_P_First(long groupId,
1670 String parentStructureId, OrderByComparator obc)
1671 throws NoSuchStructureException, SystemException {
1672 List<JournalStructure> list = findByG_P(groupId, parentStructureId, 0,
1673 1, obc);
1674
1675 if (list.isEmpty()) {
1676 StringBundler msg = new StringBundler(6);
1677
1678 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1679
1680 msg.append("groupId=");
1681 msg.append(groupId);
1682
1683 msg.append(", parentStructureId=");
1684 msg.append(parentStructureId);
1685
1686 msg.append(StringPool.CLOSE_CURLY_BRACE);
1687
1688 throw new NoSuchStructureException(msg.toString());
1689 }
1690 else {
1691 return list.get(0);
1692 }
1693 }
1694
1695 public JournalStructure findByG_P_Last(long groupId,
1696 String parentStructureId, OrderByComparator obc)
1697 throws NoSuchStructureException, SystemException {
1698 int count = countByG_P(groupId, parentStructureId);
1699
1700 List<JournalStructure> list = findByG_P(groupId, parentStructureId,
1701 count - 1, count, obc);
1702
1703 if (list.isEmpty()) {
1704 StringBundler msg = new StringBundler(6);
1705
1706 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1707
1708 msg.append("groupId=");
1709 msg.append(groupId);
1710
1711 msg.append(", parentStructureId=");
1712 msg.append(parentStructureId);
1713
1714 msg.append(StringPool.CLOSE_CURLY_BRACE);
1715
1716 throw new NoSuchStructureException(msg.toString());
1717 }
1718 else {
1719 return list.get(0);
1720 }
1721 }
1722
1723 public JournalStructure[] findByG_P_PrevAndNext(long id, long groupId,
1724 String parentStructureId, OrderByComparator obc)
1725 throws NoSuchStructureException, SystemException {
1726 JournalStructure journalStructure = findByPrimaryKey(id);
1727
1728 int count = countByG_P(groupId, parentStructureId);
1729
1730 Session session = null;
1731
1732 try {
1733 session = openSession();
1734
1735 StringBundler query = null;
1736
1737 if (obc != null) {
1738 query = new StringBundler(4 +
1739 (obc.getOrderByFields().length * 3));
1740 }
1741 else {
1742 query = new StringBundler(4);
1743 }
1744
1745 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1746
1747 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1748
1749 if (parentStructureId == null) {
1750 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
1751 }
1752 else {
1753 if (parentStructureId.equals(StringPool.BLANK)) {
1754 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
1755 }
1756 else {
1757 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
1758 }
1759 }
1760
1761 if (obc != null) {
1762 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1763 }
1764
1765 else {
1766 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1767 }
1768
1769 String sql = query.toString();
1770
1771 Query q = session.createQuery(sql);
1772
1773 QueryPos qPos = QueryPos.getInstance(q);
1774
1775 qPos.add(groupId);
1776
1777 if (parentStructureId != null) {
1778 qPos.add(parentStructureId);
1779 }
1780
1781 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1782 journalStructure);
1783
1784 JournalStructure[] array = new JournalStructureImpl[3];
1785
1786 array[0] = (JournalStructure)objArray[0];
1787 array[1] = (JournalStructure)objArray[1];
1788 array[2] = (JournalStructure)objArray[2];
1789
1790 return array;
1791 }
1792 catch (Exception e) {
1793 throw processException(e);
1794 }
1795 finally {
1796 closeSession(session);
1797 }
1798 }
1799
1800 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1801 throws SystemException {
1802 Session session = null;
1803
1804 try {
1805 session = openSession();
1806
1807 dynamicQuery.compile(session);
1808
1809 return dynamicQuery.list();
1810 }
1811 catch (Exception e) {
1812 throw processException(e);
1813 }
1814 finally {
1815 closeSession(session);
1816 }
1817 }
1818
1819 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1820 int start, int end) throws SystemException {
1821 Session session = null;
1822
1823 try {
1824 session = openSession();
1825
1826 dynamicQuery.setLimit(start, end);
1827
1828 dynamicQuery.compile(session);
1829
1830 return dynamicQuery.list();
1831 }
1832 catch (Exception e) {
1833 throw processException(e);
1834 }
1835 finally {
1836 closeSession(session);
1837 }
1838 }
1839
1840 public List<JournalStructure> findAll() throws SystemException {
1841 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1842 }
1843
1844 public List<JournalStructure> findAll(int start, int end)
1845 throws SystemException {
1846 return findAll(start, end, null);
1847 }
1848
1849 public List<JournalStructure> findAll(int start, int end,
1850 OrderByComparator obc) throws SystemException {
1851 Object[] finderArgs = new Object[] {
1852 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1853 };
1854
1855 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1856 finderArgs, this);
1857
1858 if (list == null) {
1859 Session session = null;
1860
1861 try {
1862 session = openSession();
1863
1864 StringBundler query = null;
1865 String sql = null;
1866
1867 if (obc != null) {
1868 query = new StringBundler(2 +
1869 (obc.getOrderByFields().length * 3));
1870
1871 query.append(_SQL_SELECT_JOURNALSTRUCTURE);
1872
1873 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1874
1875 sql = query.toString();
1876 }
1877
1878 else {
1879 sql = _SQL_SELECT_JOURNALSTRUCTURE.concat(JournalStructureModelImpl.ORDER_BY_JPQL);
1880 }
1881
1882 Query q = session.createQuery(sql);
1883
1884 if (obc == null) {
1885 list = (List<JournalStructure>)QueryUtil.list(q,
1886 getDialect(), start, end, false);
1887
1888 Collections.sort(list);
1889 }
1890 else {
1891 list = (List<JournalStructure>)QueryUtil.list(q,
1892 getDialect(), start, end);
1893 }
1894 }
1895 catch (Exception e) {
1896 throw processException(e);
1897 }
1898 finally {
1899 if (list == null) {
1900 list = new ArrayList<JournalStructure>();
1901 }
1902
1903 cacheResult(list);
1904
1905 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1906
1907 closeSession(session);
1908 }
1909 }
1910
1911 return list;
1912 }
1913
1914 public void removeByUuid(String uuid) throws SystemException {
1915 for (JournalStructure journalStructure : findByUuid(uuid)) {
1916 remove(journalStructure);
1917 }
1918 }
1919
1920 public void removeByUUID_G(String uuid, long groupId)
1921 throws NoSuchStructureException, SystemException {
1922 JournalStructure journalStructure = findByUUID_G(uuid, groupId);
1923
1924 remove(journalStructure);
1925 }
1926
1927 public void removeByGroupId(long groupId) throws SystemException {
1928 for (JournalStructure journalStructure : findByGroupId(groupId)) {
1929 remove(journalStructure);
1930 }
1931 }
1932
1933 public void removeByStructureId(String structureId)
1934 throws SystemException {
1935 for (JournalStructure journalStructure : findByStructureId(structureId)) {
1936 remove(journalStructure);
1937 }
1938 }
1939
1940 public void removeByG_S(long groupId, String structureId)
1941 throws NoSuchStructureException, SystemException {
1942 JournalStructure journalStructure = findByG_S(groupId, structureId);
1943
1944 remove(journalStructure);
1945 }
1946
1947 public void removeByG_P(long groupId, String parentStructureId)
1948 throws SystemException {
1949 for (JournalStructure journalStructure : findByG_P(groupId,
1950 parentStructureId)) {
1951 remove(journalStructure);
1952 }
1953 }
1954
1955 public void removeAll() throws SystemException {
1956 for (JournalStructure journalStructure : findAll()) {
1957 remove(journalStructure);
1958 }
1959 }
1960
1961 public int countByUuid(String uuid) throws SystemException {
1962 Object[] finderArgs = new Object[] { uuid };
1963
1964 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1965 finderArgs, this);
1966
1967 if (count == null) {
1968 Session session = null;
1969
1970 try {
1971 session = openSession();
1972
1973 StringBundler query = new StringBundler(2);
1974
1975 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
1976
1977 if (uuid == null) {
1978 query.append(_FINDER_COLUMN_UUID_UUID_1);
1979 }
1980 else {
1981 if (uuid.equals(StringPool.BLANK)) {
1982 query.append(_FINDER_COLUMN_UUID_UUID_3);
1983 }
1984 else {
1985 query.append(_FINDER_COLUMN_UUID_UUID_2);
1986 }
1987 }
1988
1989 String sql = query.toString();
1990
1991 Query q = session.createQuery(sql);
1992
1993 QueryPos qPos = QueryPos.getInstance(q);
1994
1995 if (uuid != null) {
1996 qPos.add(uuid);
1997 }
1998
1999 count = (Long)q.uniqueResult();
2000 }
2001 catch (Exception e) {
2002 throw processException(e);
2003 }
2004 finally {
2005 if (count == null) {
2006 count = Long.valueOf(0);
2007 }
2008
2009 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2010 finderArgs, count);
2011
2012 closeSession(session);
2013 }
2014 }
2015
2016 return count.intValue();
2017 }
2018
2019 public int countByUUID_G(String uuid, long groupId)
2020 throws SystemException {
2021 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2022
2023 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2024 finderArgs, this);
2025
2026 if (count == null) {
2027 Session session = null;
2028
2029 try {
2030 session = openSession();
2031
2032 StringBundler query = new StringBundler(3);
2033
2034 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2035
2036 if (uuid == null) {
2037 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2038 }
2039 else {
2040 if (uuid.equals(StringPool.BLANK)) {
2041 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2042 }
2043 else {
2044 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2045 }
2046 }
2047
2048 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2049
2050 String sql = query.toString();
2051
2052 Query q = session.createQuery(sql);
2053
2054 QueryPos qPos = QueryPos.getInstance(q);
2055
2056 if (uuid != null) {
2057 qPos.add(uuid);
2058 }
2059
2060 qPos.add(groupId);
2061
2062 count = (Long)q.uniqueResult();
2063 }
2064 catch (Exception e) {
2065 throw processException(e);
2066 }
2067 finally {
2068 if (count == null) {
2069 count = Long.valueOf(0);
2070 }
2071
2072 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2073 finderArgs, count);
2074
2075 closeSession(session);
2076 }
2077 }
2078
2079 return count.intValue();
2080 }
2081
2082 public int countByGroupId(long groupId) throws SystemException {
2083 Object[] finderArgs = new Object[] { new Long(groupId) };
2084
2085 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2086 finderArgs, this);
2087
2088 if (count == null) {
2089 Session session = null;
2090
2091 try {
2092 session = openSession();
2093
2094 StringBundler query = new StringBundler(2);
2095
2096 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2097
2098 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2099
2100 String sql = query.toString();
2101
2102 Query q = session.createQuery(sql);
2103
2104 QueryPos qPos = QueryPos.getInstance(q);
2105
2106 qPos.add(groupId);
2107
2108 count = (Long)q.uniqueResult();
2109 }
2110 catch (Exception e) {
2111 throw processException(e);
2112 }
2113 finally {
2114 if (count == null) {
2115 count = Long.valueOf(0);
2116 }
2117
2118 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2119 finderArgs, count);
2120
2121 closeSession(session);
2122 }
2123 }
2124
2125 return count.intValue();
2126 }
2127
2128 public int countByStructureId(String structureId) throws SystemException {
2129 Object[] finderArgs = new Object[] { structureId };
2130
2131 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
2132 finderArgs, this);
2133
2134 if (count == null) {
2135 Session session = null;
2136
2137 try {
2138 session = openSession();
2139
2140 StringBundler query = new StringBundler(2);
2141
2142 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2143
2144 if (structureId == null) {
2145 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
2146 }
2147 else {
2148 if (structureId.equals(StringPool.BLANK)) {
2149 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
2150 }
2151 else {
2152 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
2153 }
2154 }
2155
2156 String sql = query.toString();
2157
2158 Query q = session.createQuery(sql);
2159
2160 QueryPos qPos = QueryPos.getInstance(q);
2161
2162 if (structureId != null) {
2163 qPos.add(structureId);
2164 }
2165
2166 count = (Long)q.uniqueResult();
2167 }
2168 catch (Exception e) {
2169 throw processException(e);
2170 }
2171 finally {
2172 if (count == null) {
2173 count = Long.valueOf(0);
2174 }
2175
2176 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
2177 finderArgs, count);
2178
2179 closeSession(session);
2180 }
2181 }
2182
2183 return count.intValue();
2184 }
2185
2186 public int countByG_S(long groupId, String structureId)
2187 throws SystemException {
2188 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
2189
2190 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
2191 finderArgs, this);
2192
2193 if (count == null) {
2194 Session session = null;
2195
2196 try {
2197 session = openSession();
2198
2199 StringBundler query = new StringBundler(3);
2200
2201 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2202
2203 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2204
2205 if (structureId == null) {
2206 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
2207 }
2208 else {
2209 if (structureId.equals(StringPool.BLANK)) {
2210 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
2211 }
2212 else {
2213 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
2214 }
2215 }
2216
2217 String sql = query.toString();
2218
2219 Query q = session.createQuery(sql);
2220
2221 QueryPos qPos = QueryPos.getInstance(q);
2222
2223 qPos.add(groupId);
2224
2225 if (structureId != null) {
2226 qPos.add(structureId);
2227 }
2228
2229 count = (Long)q.uniqueResult();
2230 }
2231 catch (Exception e) {
2232 throw processException(e);
2233 }
2234 finally {
2235 if (count == null) {
2236 count = Long.valueOf(0);
2237 }
2238
2239 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
2240 count);
2241
2242 closeSession(session);
2243 }
2244 }
2245
2246 return count.intValue();
2247 }
2248
2249 public int countByG_P(long groupId, String parentStructureId)
2250 throws SystemException {
2251 Object[] finderArgs = new Object[] { new Long(groupId), parentStructureId };
2252
2253 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2254 finderArgs, this);
2255
2256 if (count == null) {
2257 Session session = null;
2258
2259 try {
2260 session = openSession();
2261
2262 StringBundler query = new StringBundler(3);
2263
2264 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2265
2266 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2267
2268 if (parentStructureId == null) {
2269 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
2270 }
2271 else {
2272 if (parentStructureId.equals(StringPool.BLANK)) {
2273 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
2274 }
2275 else {
2276 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
2277 }
2278 }
2279
2280 String sql = query.toString();
2281
2282 Query q = session.createQuery(sql);
2283
2284 QueryPos qPos = QueryPos.getInstance(q);
2285
2286 qPos.add(groupId);
2287
2288 if (parentStructureId != null) {
2289 qPos.add(parentStructureId);
2290 }
2291
2292 count = (Long)q.uniqueResult();
2293 }
2294 catch (Exception e) {
2295 throw processException(e);
2296 }
2297 finally {
2298 if (count == null) {
2299 count = Long.valueOf(0);
2300 }
2301
2302 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2303 count);
2304
2305 closeSession(session);
2306 }
2307 }
2308
2309 return count.intValue();
2310 }
2311
2312 public int countAll() throws SystemException {
2313 Object[] finderArgs = new Object[0];
2314
2315 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2316 finderArgs, this);
2317
2318 if (count == null) {
2319 Session session = null;
2320
2321 try {
2322 session = openSession();
2323
2324 Query q = session.createQuery(_SQL_COUNT_JOURNALSTRUCTURE);
2325
2326 count = (Long)q.uniqueResult();
2327 }
2328 catch (Exception e) {
2329 throw processException(e);
2330 }
2331 finally {
2332 if (count == null) {
2333 count = Long.valueOf(0);
2334 }
2335
2336 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2337 count);
2338
2339 closeSession(session);
2340 }
2341 }
2342
2343 return count.intValue();
2344 }
2345
2346 public void afterPropertiesSet() {
2347 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2348 com.liferay.portal.util.PropsUtil.get(
2349 "value.object.listener.com.liferay.portlet.journal.model.JournalStructure")));
2350
2351 if (listenerClassNames.length > 0) {
2352 try {
2353 List<ModelListener<JournalStructure>> listenersList = new ArrayList<ModelListener<JournalStructure>>();
2354
2355 for (String listenerClassName : listenerClassNames) {
2356 listenersList.add((ModelListener<JournalStructure>)Class.forName(
2357 listenerClassName).newInstance());
2358 }
2359
2360 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2361 }
2362 catch (Exception e) {
2363 _log.error(e);
2364 }
2365 }
2366 }
2367
2368 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence")
2369 protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
2370 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence")
2371 protected com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence journalArticleImagePersistence;
2372 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence")
2373 protected com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence journalArticleResourcePersistence;
2374 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence")
2375 protected com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence journalContentSearchPersistence;
2376 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalFeedPersistence")
2377 protected com.liferay.portlet.journal.service.persistence.JournalFeedPersistence journalFeedPersistence;
2378 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalStructurePersistence")
2379 protected com.liferay.portlet.journal.service.persistence.JournalStructurePersistence journalStructurePersistence;
2380 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence")
2381 protected com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence journalTemplatePersistence;
2382 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
2383 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2384 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
2385 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2386 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
2387 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
2388 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence")
2389 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
2390 private static final String _SQL_SELECT_JOURNALSTRUCTURE = "SELECT journalStructure FROM JournalStructure journalStructure";
2391 private static final String _SQL_SELECT_JOURNALSTRUCTURE_WHERE = "SELECT journalStructure FROM JournalStructure journalStructure WHERE ";
2392 private static final String _SQL_COUNT_JOURNALSTRUCTURE = "SELECT COUNT(journalStructure) FROM JournalStructure journalStructure";
2393 private static final String _SQL_COUNT_JOURNALSTRUCTURE_WHERE = "SELECT COUNT(journalStructure) FROM JournalStructure journalStructure WHERE ";
2394 private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalStructure.uuid IS NULL";
2395 private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalStructure.uuid = ?";
2396 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalStructure.uuid IS NULL OR journalStructure.uuid = ?)";
2397 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalStructure.uuid IS NULL AND ";
2398 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalStructure.uuid = ? AND ";
2399 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalStructure.uuid IS NULL OR journalStructure.uuid = ?) AND ";
2400 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalStructure.groupId = ?";
2401 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalStructure.groupId = ?";
2402 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalStructure.structureId IS NULL";
2403 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalStructure.structureId = ?";
2404 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalStructure.structureId IS NULL OR journalStructure.structureId = ?)";
2405 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalStructure.groupId = ? AND ";
2406 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalStructure.structureId IS NULL";
2407 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalStructure.structureId = ?";
2408 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalStructure.structureId IS NULL OR journalStructure.structureId = ?)";
2409 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalStructure.groupId = ? AND ";
2410 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1 = "journalStructure.parentStructureId IS NULL";
2411 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2 = "journalStructure.parentStructureId = ?";
2412 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3 = "(journalStructure.parentStructureId IS NULL OR journalStructure.parentStructureId = ?)";
2413 private static final String _ORDER_BY_ENTITY_ALIAS = "journalStructure.";
2414 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalStructure exists with the primary key ";
2415 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalStructure exists with the key {";
2416 private static Log _log = LogFactoryUtil.getLog(JournalStructurePersistenceImpl.class);
2417}