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