1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.journal.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
22  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderPath;
25  import com.liferay.portal.kernel.dao.orm.Query;
26  import com.liferay.portal.kernel.dao.orm.QueryPos;
27  import com.liferay.portal.kernel.dao.orm.QueryUtil;
28  import com.liferay.portal.kernel.dao.orm.Session;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.kernel.util.Validator;
37  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
38  import com.liferay.portal.model.ModelListener;
39  import com.liferay.portal.service.persistence.BatchSessionUtil;
40  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41  
42  import com.liferay.portlet.journal.NoSuchArticleException;
43  import com.liferay.portlet.journal.model.JournalArticle;
44  import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
45  import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
46  
47  import java.io.Serializable;
48  
49  import java.util.ArrayList;
50  import java.util.Collections;
51  import java.util.List;
52  
53  /**
54   * <a href="JournalArticlePersistenceImpl.java.html"><b><i>View Source</i></b></a>
55   *
56   * <p>
57   * ServiceBuilder generated this class. Modifications in this class will be
58   * overwritten the next time is generated.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       JournalArticlePersistence
63   * @see       JournalArticleUtil
64   * @generated
65   */
66  public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
67      implements JournalArticlePersistence {
68      public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
69      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
70          ".List";
71      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
72              JournalArticleModelImpl.FINDER_CACHE_ENABLED,
73              FINDER_CLASS_NAME_LIST, "findByUuid",
74              new String[] { String.class.getName() });
75      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
76              JournalArticleModelImpl.FINDER_CACHE_ENABLED,
77              FINDER_CLASS_NAME_LIST, "findByUuid",
78              new String[] {
79                  String.class.getName(),
80                  
81              "java.lang.Integer", "java.lang.Integer",
82                  "com.liferay.portal.kernel.util.OrderByComparator"
83              });
84      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
85              JournalArticleModelImpl.FINDER_CACHE_ENABLED,
86              FINDER_CLASS_NAME_LIST, "countByUuid",
87              new String[] { String.class.getName() });
88      public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
89              JournalArticleModelImpl.FINDER_CACHE_ENABLED,
90              FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
91              new String[] { String.class.getName(), Long.class.getName() });
92      public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
93              JournalArticleModelImpl.FINDER_CACHE_ENABLED,
94              FINDER_CLASS_NAME_LIST, "countByUUID_G",
95              new String[] { String.class.getName(), Long.class.getName() });
96      public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
97              JournalArticleModelImpl.FINDER_CACHE_ENABLED,
98              FINDER_CLASS_NAME_LIST, "findByGroupId",
99              new String[] { Long.class.getName() });
100     public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
101             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
102             FINDER_CLASS_NAME_LIST, "findByGroupId",
103             new String[] {
104                 Long.class.getName(),
105                 
106             "java.lang.Integer", "java.lang.Integer",
107                 "com.liferay.portal.kernel.util.OrderByComparator"
108             });
109     public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
110             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
111             FINDER_CLASS_NAME_LIST, "countByGroupId",
112             new String[] { Long.class.getName() });
113     public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
114             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
115             FINDER_CLASS_NAME_LIST, "findByCompanyId",
116             new String[] { Long.class.getName() });
117     public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
118             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
119             FINDER_CLASS_NAME_LIST, "findByCompanyId",
120             new String[] {
121                 Long.class.getName(),
122                 
123             "java.lang.Integer", "java.lang.Integer",
124                 "com.liferay.portal.kernel.util.OrderByComparator"
125             });
126     public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
127             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
128             FINDER_CLASS_NAME_LIST, "countByCompanyId",
129             new String[] { Long.class.getName() });
130     public static final FinderPath FINDER_PATH_FIND_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
131             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
132             FINDER_CLASS_NAME_LIST, "findBySmallImageId",
133             new String[] { Long.class.getName() });
134     public static final FinderPath FINDER_PATH_FIND_BY_OBC_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
135             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
136             FINDER_CLASS_NAME_LIST, "findBySmallImageId",
137             new String[] {
138                 Long.class.getName(),
139                 
140             "java.lang.Integer", "java.lang.Integer",
141                 "com.liferay.portal.kernel.util.OrderByComparator"
142             });
143     public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
144             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
145             FINDER_CLASS_NAME_LIST, "countBySmallImageId",
146             new String[] { Long.class.getName() });
147     public static final FinderPath FINDER_PATH_FIND_BY_R_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
148             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
149             FINDER_CLASS_NAME_LIST, "findByR_A",
150             new String[] { Long.class.getName(), Boolean.class.getName() });
151     public static final FinderPath FINDER_PATH_FIND_BY_OBC_R_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
152             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
153             FINDER_CLASS_NAME_LIST, "findByR_A",
154             new String[] {
155                 Long.class.getName(), Boolean.class.getName(),
156                 
157             "java.lang.Integer", "java.lang.Integer",
158                 "com.liferay.portal.kernel.util.OrderByComparator"
159             });
160     public static final FinderPath FINDER_PATH_COUNT_BY_R_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
161             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
162             FINDER_CLASS_NAME_LIST, "countByR_A",
163             new String[] { Long.class.getName(), Boolean.class.getName() });
164     public static final FinderPath FINDER_PATH_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
165             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
166             FINDER_CLASS_NAME_LIST, "findByG_A",
167             new String[] { Long.class.getName(), String.class.getName() });
168     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
169             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
170             FINDER_CLASS_NAME_LIST, "findByG_A",
171             new String[] {
172                 Long.class.getName(), String.class.getName(),
173                 
174             "java.lang.Integer", "java.lang.Integer",
175                 "com.liferay.portal.kernel.util.OrderByComparator"
176             });
177     public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
178             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
179             FINDER_CLASS_NAME_LIST, "countByG_A",
180             new String[] { Long.class.getName(), String.class.getName() });
181     public static final FinderPath FINDER_PATH_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
182             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
183             FINDER_CLASS_NAME_LIST, "findByG_S",
184             new String[] { Long.class.getName(), String.class.getName() });
185     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
186             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
187             FINDER_CLASS_NAME_LIST, "findByG_S",
188             new String[] {
189                 Long.class.getName(), String.class.getName(),
190                 
191             "java.lang.Integer", "java.lang.Integer",
192                 "com.liferay.portal.kernel.util.OrderByComparator"
193             });
194     public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
195             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
196             FINDER_CLASS_NAME_LIST, "countByG_S",
197             new String[] { Long.class.getName(), String.class.getName() });
198     public static final FinderPath FINDER_PATH_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
199             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
200             FINDER_CLASS_NAME_LIST, "findByG_T",
201             new String[] { Long.class.getName(), String.class.getName() });
202     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
203             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
204             FINDER_CLASS_NAME_LIST, "findByG_T",
205             new String[] {
206                 Long.class.getName(), String.class.getName(),
207                 
208             "java.lang.Integer", "java.lang.Integer",
209                 "com.liferay.portal.kernel.util.OrderByComparator"
210             });
211     public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
212             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
213             FINDER_CLASS_NAME_LIST, "countByG_T",
214             new String[] { Long.class.getName(), String.class.getName() });
215     public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
216             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
217             FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
218             new String[] {
219                 Long.class.getName(), String.class.getName(),
220                 Double.class.getName()
221             });
222     public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
223             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
224             FINDER_CLASS_NAME_LIST, "countByG_A_V",
225             new String[] {
226                 Long.class.getName(), String.class.getName(),
227                 Double.class.getName()
228             });
229     public static final FinderPath FINDER_PATH_FIND_BY_G_A_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
230             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
231             FINDER_CLASS_NAME_LIST, "findByG_A_A",
232             new String[] {
233                 Long.class.getName(), String.class.getName(),
234                 Boolean.class.getName()
235             });
236     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_A_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
237             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
238             FINDER_CLASS_NAME_LIST, "findByG_A_A",
239             new String[] {
240                 Long.class.getName(), String.class.getName(),
241                 Boolean.class.getName(),
242                 
243             "java.lang.Integer", "java.lang.Integer",
244                 "com.liferay.portal.kernel.util.OrderByComparator"
245             });
246     public static final FinderPath FINDER_PATH_COUNT_BY_G_A_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
247             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
248             FINDER_CLASS_NAME_LIST, "countByG_A_A",
249             new String[] {
250                 Long.class.getName(), String.class.getName(),
251                 Boolean.class.getName()
252             });
253     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
254             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
255             FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
256     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
257             JournalArticleModelImpl.FINDER_CACHE_ENABLED,
258             FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
259 
260     public void cacheResult(JournalArticle journalArticle) {
261         EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
262             JournalArticleImpl.class, journalArticle.getPrimaryKey(),
263             journalArticle);
264 
265         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
266             new Object[] {
267                 journalArticle.getUuid(), new Long(journalArticle.getGroupId())
268             }, journalArticle);
269 
270         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
271             new Object[] {
272                 new Long(journalArticle.getGroupId()),
273                 
274             journalArticle.getArticleId(),
275                 new Double(journalArticle.getVersion())
276             }, journalArticle);
277     }
278 
279     public void cacheResult(List<JournalArticle> journalArticles) {
280         for (JournalArticle journalArticle : journalArticles) {
281             if (EntityCacheUtil.getResult(
282                         JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
283                         JournalArticleImpl.class,
284                         journalArticle.getPrimaryKey(), this) == null) {
285                 cacheResult(journalArticle);
286             }
287         }
288     }
289 
290     public void clearCache() {
291         CacheRegistry.clear(JournalArticleImpl.class.getName());
292         EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
293         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
294         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
295     }
296 
297     public JournalArticle create(long id) {
298         JournalArticle journalArticle = new JournalArticleImpl();
299 
300         journalArticle.setNew(true);
301         journalArticle.setPrimaryKey(id);
302 
303         String uuid = PortalUUIDUtil.generate();
304 
305         journalArticle.setUuid(uuid);
306 
307         return journalArticle;
308     }
309 
310     public JournalArticle remove(Serializable primaryKey)
311         throws NoSuchModelException, SystemException {
312         return remove(((Long)primaryKey).longValue());
313     }
314 
315     public JournalArticle remove(long id)
316         throws NoSuchArticleException, SystemException {
317         Session session = null;
318 
319         try {
320             session = openSession();
321 
322             JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
323                     new Long(id));
324 
325             if (journalArticle == null) {
326                 if (_log.isWarnEnabled()) {
327                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
328                 }
329 
330                 throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
331                     id);
332             }
333 
334             return remove(journalArticle);
335         }
336         catch (NoSuchArticleException nsee) {
337             throw nsee;
338         }
339         catch (Exception e) {
340             throw processException(e);
341         }
342         finally {
343             closeSession(session);
344         }
345     }
346 
347     public JournalArticle remove(JournalArticle journalArticle)
348         throws SystemException {
349         for (ModelListener<JournalArticle> listener : listeners) {
350             listener.onBeforeRemove(journalArticle);
351         }
352 
353         journalArticle = removeImpl(journalArticle);
354 
355         for (ModelListener<JournalArticle> listener : listeners) {
356             listener.onAfterRemove(journalArticle);
357         }
358 
359         return journalArticle;
360     }
361 
362     protected JournalArticle removeImpl(JournalArticle journalArticle)
363         throws SystemException {
364         journalArticle = toUnwrappedModel(journalArticle);
365 
366         Session session = null;
367 
368         try {
369             session = openSession();
370 
371             if (journalArticle.isCachedModel() || BatchSessionUtil.isEnabled()) {
372                 Object staleObject = session.get(JournalArticleImpl.class,
373                         journalArticle.getPrimaryKeyObj());
374 
375                 if (staleObject != null) {
376                     session.evict(staleObject);
377                 }
378             }
379 
380             session.delete(journalArticle);
381 
382             session.flush();
383         }
384         catch (Exception e) {
385             throw processException(e);
386         }
387         finally {
388             closeSession(session);
389         }
390 
391         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
392 
393         JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
394 
395         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
396             new Object[] {
397                 journalArticleModelImpl.getOriginalUuid(),
398                 new Long(journalArticleModelImpl.getOriginalGroupId())
399             });
400 
401         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
402             new Object[] {
403                 new Long(journalArticleModelImpl.getOriginalGroupId()),
404                 
405             journalArticleModelImpl.getOriginalArticleId(),
406                 new Double(journalArticleModelImpl.getOriginalVersion())
407             });
408 
409         EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
410             JournalArticleImpl.class, journalArticle.getPrimaryKey());
411 
412         return journalArticle;
413     }
414 
415     /**
416      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
417      */
418     public JournalArticle update(JournalArticle journalArticle)
419         throws SystemException {
420         if (_log.isWarnEnabled()) {
421             _log.warn(
422                 "Using the deprecated update(JournalArticle journalArticle) method. Use update(JournalArticle journalArticle, boolean merge) instead.");
423         }
424 
425         return update(journalArticle, false);
426     }
427 
428     public JournalArticle updateImpl(
429         com.liferay.portlet.journal.model.JournalArticle journalArticle,
430         boolean merge) throws SystemException {
431         journalArticle = toUnwrappedModel(journalArticle);
432 
433         boolean isNew = journalArticle.isNew();
434 
435         JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
436 
437         if (Validator.isNull(journalArticle.getUuid())) {
438             String uuid = PortalUUIDUtil.generate();
439 
440             journalArticle.setUuid(uuid);
441         }
442 
443         Session session = null;
444 
445         try {
446             session = openSession();
447 
448             BatchSessionUtil.update(session, journalArticle, merge);
449 
450             journalArticle.setNew(false);
451         }
452         catch (Exception e) {
453             throw processException(e);
454         }
455         finally {
456             closeSession(session);
457         }
458 
459         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
460 
461         EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
462             JournalArticleImpl.class, journalArticle.getPrimaryKey(),
463             journalArticle);
464 
465         if (!isNew &&
466                 (!Validator.equals(journalArticle.getUuid(),
467                     journalArticleModelImpl.getOriginalUuid()) ||
468                 (journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()))) {
469             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
470                 new Object[] {
471                     journalArticleModelImpl.getOriginalUuid(),
472                     new Long(journalArticleModelImpl.getOriginalGroupId())
473                 });
474         }
475 
476         if (isNew ||
477                 (!Validator.equals(journalArticle.getUuid(),
478                     journalArticleModelImpl.getOriginalUuid()) ||
479                 (journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()))) {
480             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
481                 new Object[] {
482                     journalArticle.getUuid(),
483                     new Long(journalArticle.getGroupId())
484                 }, journalArticle);
485         }
486 
487         if (!isNew &&
488                 ((journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()) ||
489                 !Validator.equals(journalArticle.getArticleId(),
490                     journalArticleModelImpl.getOriginalArticleId()) ||
491                 (journalArticle.getVersion() != journalArticleModelImpl.getOriginalVersion()))) {
492             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
493                 new Object[] {
494                     new Long(journalArticleModelImpl.getOriginalGroupId()),
495                     
496                 journalArticleModelImpl.getOriginalArticleId(),
497                     new Double(journalArticleModelImpl.getOriginalVersion())
498                 });
499         }
500 
501         if (isNew ||
502                 ((journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()) ||
503                 !Validator.equals(journalArticle.getArticleId(),
504                     journalArticleModelImpl.getOriginalArticleId()) ||
505                 (journalArticle.getVersion() != journalArticleModelImpl.getOriginalVersion()))) {
506             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
507                 new Object[] {
508                     new Long(journalArticle.getGroupId()),
509                     
510                 journalArticle.getArticleId(),
511                     new Double(journalArticle.getVersion())
512                 }, journalArticle);
513         }
514 
515         return journalArticle;
516     }
517 
518     protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
519         if (journalArticle instanceof JournalArticleImpl) {
520             return journalArticle;
521         }
522 
523         JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
524 
525         journalArticleImpl.setNew(journalArticle.isNew());
526         journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
527 
528         journalArticleImpl.setUuid(journalArticle.getUuid());
529         journalArticleImpl.setId(journalArticle.getId());
530         journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
531         journalArticleImpl.setGroupId(journalArticle.getGroupId());
532         journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
533         journalArticleImpl.setUserId(journalArticle.getUserId());
534         journalArticleImpl.setUserName(journalArticle.getUserName());
535         journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
536         journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
537         journalArticleImpl.setArticleId(journalArticle.getArticleId());
538         journalArticleImpl.setVersion(journalArticle.getVersion());
539         journalArticleImpl.setTitle(journalArticle.getTitle());
540         journalArticleImpl.setDescription(journalArticle.getDescription());
541         journalArticleImpl.setContent(journalArticle.getContent());
542         journalArticleImpl.setType(journalArticle.getType());
543         journalArticleImpl.setStructureId(journalArticle.getStructureId());
544         journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
545         journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
546         journalArticleImpl.setApproved(journalArticle.isApproved());
547         journalArticleImpl.setApprovedByUserId(journalArticle.getApprovedByUserId());
548         journalArticleImpl.setApprovedByUserName(journalArticle.getApprovedByUserName());
549         journalArticleImpl.setApprovedDate(journalArticle.getApprovedDate());
550         journalArticleImpl.setExpired(journalArticle.isExpired());
551         journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
552         journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
553         journalArticleImpl.setIndexable(journalArticle.isIndexable());
554         journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
555         journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
556         journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
557 
558         return journalArticleImpl;
559     }
560 
561     public JournalArticle findByPrimaryKey(Serializable primaryKey)
562         throws NoSuchModelException, SystemException {
563         return findByPrimaryKey(((Long)primaryKey).longValue());
564     }
565 
566     public JournalArticle findByPrimaryKey(long id)
567         throws NoSuchArticleException, SystemException {
568         JournalArticle journalArticle = fetchByPrimaryKey(id);
569 
570         if (journalArticle == null) {
571             if (_log.isWarnEnabled()) {
572                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
573             }
574 
575             throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
576                 id);
577         }
578 
579         return journalArticle;
580     }
581 
582     public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
583         throws SystemException {
584         return fetchByPrimaryKey(((Long)primaryKey).longValue());
585     }
586 
587     public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
588         JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
589                 JournalArticleImpl.class, id, this);
590 
591         if (journalArticle == null) {
592             Session session = null;
593 
594             try {
595                 session = openSession();
596 
597                 journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
598                         new Long(id));
599             }
600             catch (Exception e) {
601                 throw processException(e);
602             }
603             finally {
604                 if (journalArticle != null) {
605                     cacheResult(journalArticle);
606                 }
607 
608                 closeSession(session);
609             }
610         }
611 
612         return journalArticle;
613     }
614 
615     public List<JournalArticle> findByUuid(String uuid)
616         throws SystemException {
617         Object[] finderArgs = new Object[] { uuid };
618 
619         List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
620                 finderArgs, this);
621 
622         if (list == null) {
623             Session session = null;
624 
625             try {
626                 session = openSession();
627 
628                 StringBundler query = new StringBundler(3);
629 
630                 query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
631 
632                 if (uuid == null) {
633                     query.append(_FINDER_COLUMN_UUID_UUID_1);
634                 }
635                 else {
636                     if (uuid.equals(StringPool.BLANK)) {
637                         query.append(_FINDER_COLUMN_UUID_UUID_3);
638                     }
639                     else {
640                         query.append(_FINDER_COLUMN_UUID_UUID_2);
641                     }
642                 }
643 
644                 query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
645 
646                 String sql = query.toString();
647 
648                 Query q = session.createQuery(sql);
649 
650                 QueryPos qPos = QueryPos.getInstance(q);
651 
652                 if (uuid != null) {
653                     qPos.add(uuid);
654                 }
655 
656                 list = q.list();
657             }
658             catch (Exception e) {
659                 throw processException(e);
660             }
661             finally {
662                 if (list == null) {
663                     list = new ArrayList<JournalArticle>();
664                 }
665 
666                 cacheResult(list);
667 
668                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
669                     list);
670 
671                 closeSession(session);
672             }
673         }
674 
675         return list;
676     }
677 
678     public List<JournalArticle> findByUuid(String uuid, int start, int end)
679         throws SystemException {
680         return findByUuid(uuid, start, end, null);
681     }
682 
683     public List<JournalArticle> findByUuid(String uuid, int start, int end,
684         OrderByComparator obc) throws SystemException {
685         Object[] finderArgs = new Object[] {
686                 uuid,
687                 
688                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
689             };
690 
691         List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
692                 finderArgs, this);
693 
694         if (list == null) {
695             Session session = null;
696 
697             try {
698                 session = openSession();
699 
700                 StringBundler query = null;
701 
702                 if (obc != null) {
703                     query = new StringBundler(3 +
704                             (obc.getOrderByFields().length * 3));
705                 }
706                 else {
707                     query = new StringBundler(3);
708                 }
709 
710                 query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
711 
712                 if (uuid == null) {
713                     query.append(_FINDER_COLUMN_UUID_UUID_1);
714                 }
715                 else {
716                     if (uuid.equals(StringPool.BLANK)) {
717                         query.append(_FINDER_COLUMN_UUID_UUID_3);
718                     }
719                     else {
720                         query.append(_FINDER_COLUMN_UUID_UUID_2);
721                     }
722                 }
723 
724                 if (obc != null) {
725                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
726                 }
727 
728                 else {
729                     query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
730                 }
731 
732                 String sql = query.toString();
733 
734                 Query q = session.createQuery(sql);
735 
736                 QueryPos qPos = QueryPos.getInstance(q);
737 
738                 if (uuid != null) {
739                     qPos.add(uuid);
740                 }
741 
742                 list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
743                         start, end);
744             }
745             catch (Exception e) {
746                 throw processException(e);
747             }
748             finally {
749                 if (list == null) {
750                     list = new ArrayList<JournalArticle>();
751                 }
752 
753                 cacheResult(list);
754 
755                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
756                     finderArgs, list);
757 
758                 closeSession(session);
759             }
760         }
761 
762         return list;
763     }
764 
765     public JournalArticle findByUuid_First(String uuid, OrderByComparator obc)
766         throws NoSuchArticleException, SystemException {
767         List<JournalArticle> list = findByUuid(uuid, 0, 1, obc);
768 
769         if (list.isEmpty()) {
770             StringBundler msg = new StringBundler(4);
771 
772             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
773 
774             msg.append("uuid=");
775             msg.append(uuid);
776 
777             msg.append(StringPool.CLOSE_CURLY_BRACE);
778 
779             throw new NoSuchArticleException(msg.toString());
780         }
781         else {
782             return list.get(0);
783         }
784     }
785 
786     public JournalArticle findByUuid_Last(String uuid, OrderByComparator obc)
787         throws NoSuchArticleException, SystemException {
788         int count = countByUuid(uuid);
789 
790         List<JournalArticle> list = findByUuid(uuid, count - 1, count, obc);
791 
792         if (list.isEmpty()) {
793             StringBundler msg = new StringBundler(4);
794 
795             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
796 
797             msg.append("uuid=");
798             msg.append(uuid);
799 
800             msg.append(StringPool.CLOSE_CURLY_BRACE);
801 
802             throw new NoSuchArticleException(msg.toString());
803         }
804         else {
805             return list.get(0);
806         }
807     }
808 
809     public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
810         OrderByComparator obc) throws NoSuchArticleException, SystemException {
811         JournalArticle journalArticle = findByPrimaryKey(id);
812 
813         int count = countByUuid(uuid);
814 
815         Session session = null;
816 
817         try {
818             session = openSession();
819 
820             StringBundler query = null;
821 
822             if (obc != null) {
823                 query = new StringBundler(3 +
824                         (obc.getOrderByFields().length * 3));
825             }
826             else {
827                 query = new StringBundler(3);
828             }
829 
830             query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
831 
832             if (uuid == null) {
833                 query.append(_FINDER_COLUMN_UUID_UUID_1);
834             }
835             else {
836                 if (uuid.equals(StringPool.BLANK)) {
837                     query.append(_FINDER_COLUMN_UUID_UUID_3);
838                 }
839                 else {
840                     query.append(_FINDER_COLUMN_UUID_UUID_2);
841                 }
842             }
843 
844             if (obc != null) {
845                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
846             }
847 
848             else {
849                 query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
850             }
851 
852             String sql = query.toString();
853 
854             Query q = session.createQuery(sql);
855 
856             QueryPos qPos = QueryPos.getInstance(q);
857 
858             if (uuid != null) {
859                 qPos.add(uuid);
860             }
861 
862             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
863                     journalArticle);
864 
865             JournalArticle[] array = new JournalArticleImpl[3];
866 
867             array[0] = (JournalArticle)objArray[0];
868             array[1] = (JournalArticle)objArray[1];
869             array[2] = (JournalArticle)objArray[2];
870 
871             return array;
872         }
873         catch (Exception e) {
874             throw processException(e);
875         }
876         finally {
877             closeSession(session);
878         }
879     }
880 
881     public JournalArticle findByUUID_G(String uuid, long groupId)
882         throws NoSuchArticleException, SystemException {
883         JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
884 
885         if (journalArticle == null) {
886             StringBundler msg = new StringBundler(6);
887 
888             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
889 
890             msg.append("uuid=");
891             msg.append(uuid);
892 
893             msg.append(", groupId=");
894             msg.append(groupId);
895 
896             msg.append(StringPool.CLOSE_CURLY_BRACE);
897 
898             if (_log.isWarnEnabled()) {
899                 _log.warn(msg.toString());
900             }
901 
902             throw new NoSuchArticleException(msg.toString());
903         }
904 
905         return journalArticle;
906     }
907 
908     public JournalArticle fetchByUUID_G(String uuid, long groupId)
909         throws SystemException {
910         return fetchByUUID_G(uuid, groupId, true);
911     }
912 
913     public JournalArticle fetchByUUID_G(String uuid, long groupId,
914         boolean retrieveFromCache) throws SystemException {
915         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
916 
917         Object result = null;
918 
919         if (retrieveFromCache) {
920             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
921                     finderArgs, this);
922         }
923 
924         if (result == null) {
925             Session session = null;
926 
927             try {
928                 session = openSession();
929 
930                 StringBundler query = new StringBundler(4);
931 
932                 query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
933 
934                 if (uuid == null) {
935                     query.append(_FINDER_COLUMN_UUID_G_UUID_1);
936                 }
937                 else {
938                     if (uuid.equals(StringPool.BLANK)) {
939                         query.append(_FINDER_COLUMN_UUID_G_UUID_3);
940                     }
941                     else {
942                         query.append(_FINDER_COLUMN_UUID_G_UUID_2);
943                     }
944                 }
945 
946                 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
947 
948                 query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
949 
950                 String sql = query.toString();
951 
952                 Query q = session.createQuery(sql);
953 
954                 QueryPos qPos = QueryPos.getInstance(q);
955 
956                 if (uuid != null) {
957                     qPos.add(uuid);
958                 }
959 
960                 qPos.add(groupId);
961 
962                 List<JournalArticle> list = q.list();
963 
964                 result = list;
965 
966                 JournalArticle journalArticle = null;
967 
968                 if (list.isEmpty()) {
969                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
970                         finderArgs, list);
971                 }
972                 else {
973                     journalArticle = list.get(0);
974 
975                     cacheResult(journalArticle);
976 
977                     if ((journalArticle.getUuid() == null) ||
978                             !journalArticle.getUuid().equals(uuid) ||
979                             (journalArticle.getGroupId() != groupId)) {
980                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
981                             finderArgs, journalArticle);
982                     }
983                 }
984 
985                 return journalArticle;
986             }
987             catch (Exception e) {
988                 throw processException(e);
989             }
990             finally {
991                 if (result == null) {
992                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
993                         finderArgs, new ArrayList<JournalArticle>());
994                 }
995 
996                 closeSession(session);
997             }
998         }
999         else {
1000            if (result instanceof List<?>) {
1001                return null;
1002            }
1003            else {
1004                return (JournalArticle)result;
1005            }
1006        }
1007    }
1008
1009    public List<JournalArticle> findByGroupId(long groupId)
1010        throws SystemException {
1011        Object[] finderArgs = new Object[] { new Long(groupId) };
1012
1013        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1014                finderArgs, this);
1015
1016        if (list == null) {
1017            Session session = null;
1018
1019            try {
1020                session = openSession();
1021
1022                StringBundler query = new StringBundler(3);
1023
1024                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1025
1026                query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1027
1028                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1029
1030                String sql = query.toString();
1031
1032                Query q = session.createQuery(sql);
1033
1034                QueryPos qPos = QueryPos.getInstance(q);
1035
1036                qPos.add(groupId);
1037
1038                list = q.list();
1039            }
1040            catch (Exception e) {
1041                throw processException(e);
1042            }
1043            finally {
1044                if (list == null) {
1045                    list = new ArrayList<JournalArticle>();
1046                }
1047
1048                cacheResult(list);
1049
1050                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1051                    finderArgs, list);
1052
1053                closeSession(session);
1054            }
1055        }
1056
1057        return list;
1058    }
1059
1060    public List<JournalArticle> findByGroupId(long groupId, int start, int end)
1061        throws SystemException {
1062        return findByGroupId(groupId, start, end, null);
1063    }
1064
1065    public List<JournalArticle> findByGroupId(long groupId, int start, int end,
1066        OrderByComparator obc) throws SystemException {
1067        Object[] finderArgs = new Object[] {
1068                new Long(groupId),
1069                
1070                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1071            };
1072
1073        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1074                finderArgs, this);
1075
1076        if (list == null) {
1077            Session session = null;
1078
1079            try {
1080                session = openSession();
1081
1082                StringBundler query = null;
1083
1084                if (obc != null) {
1085                    query = new StringBundler(3 +
1086                            (obc.getOrderByFields().length * 3));
1087                }
1088                else {
1089                    query = new StringBundler(3);
1090                }
1091
1092                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1093
1094                query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1095
1096                if (obc != null) {
1097                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1098                }
1099
1100                else {
1101                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1102                }
1103
1104                String sql = query.toString();
1105
1106                Query q = session.createQuery(sql);
1107
1108                QueryPos qPos = QueryPos.getInstance(q);
1109
1110                qPos.add(groupId);
1111
1112                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1113                        start, end);
1114            }
1115            catch (Exception e) {
1116                throw processException(e);
1117            }
1118            finally {
1119                if (list == null) {
1120                    list = new ArrayList<JournalArticle>();
1121                }
1122
1123                cacheResult(list);
1124
1125                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1126                    finderArgs, list);
1127
1128                closeSession(session);
1129            }
1130        }
1131
1132        return list;
1133    }
1134
1135    public JournalArticle findByGroupId_First(long groupId,
1136        OrderByComparator obc) throws NoSuchArticleException, SystemException {
1137        List<JournalArticle> list = findByGroupId(groupId, 0, 1, obc);
1138
1139        if (list.isEmpty()) {
1140            StringBundler msg = new StringBundler(4);
1141
1142            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1143
1144            msg.append("groupId=");
1145            msg.append(groupId);
1146
1147            msg.append(StringPool.CLOSE_CURLY_BRACE);
1148
1149            throw new NoSuchArticleException(msg.toString());
1150        }
1151        else {
1152            return list.get(0);
1153        }
1154    }
1155
1156    public JournalArticle findByGroupId_Last(long groupId, OrderByComparator obc)
1157        throws NoSuchArticleException, SystemException {
1158        int count = countByGroupId(groupId);
1159
1160        List<JournalArticle> list = findByGroupId(groupId, count - 1, count, obc);
1161
1162        if (list.isEmpty()) {
1163            StringBundler msg = new StringBundler(4);
1164
1165            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1166
1167            msg.append("groupId=");
1168            msg.append(groupId);
1169
1170            msg.append(StringPool.CLOSE_CURLY_BRACE);
1171
1172            throw new NoSuchArticleException(msg.toString());
1173        }
1174        else {
1175            return list.get(0);
1176        }
1177    }
1178
1179    public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
1180        OrderByComparator obc) throws NoSuchArticleException, SystemException {
1181        JournalArticle journalArticle = findByPrimaryKey(id);
1182
1183        int count = countByGroupId(groupId);
1184
1185        Session session = null;
1186
1187        try {
1188            session = openSession();
1189
1190            StringBundler query = null;
1191
1192            if (obc != null) {
1193                query = new StringBundler(3 +
1194                        (obc.getOrderByFields().length * 3));
1195            }
1196            else {
1197                query = new StringBundler(3);
1198            }
1199
1200            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1201
1202            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1203
1204            if (obc != null) {
1205                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1206            }
1207
1208            else {
1209                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1210            }
1211
1212            String sql = query.toString();
1213
1214            Query q = session.createQuery(sql);
1215
1216            QueryPos qPos = QueryPos.getInstance(q);
1217
1218            qPos.add(groupId);
1219
1220            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1221                    journalArticle);
1222
1223            JournalArticle[] array = new JournalArticleImpl[3];
1224
1225            array[0] = (JournalArticle)objArray[0];
1226            array[1] = (JournalArticle)objArray[1];
1227            array[2] = (JournalArticle)objArray[2];
1228
1229            return array;
1230        }
1231        catch (Exception e) {
1232            throw processException(e);
1233        }
1234        finally {
1235            closeSession(session);
1236        }
1237    }
1238
1239    public List<JournalArticle> findByCompanyId(long companyId)
1240        throws SystemException {
1241        Object[] finderArgs = new Object[] { new Long(companyId) };
1242
1243        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1244                finderArgs, this);
1245
1246        if (list == null) {
1247            Session session = null;
1248
1249            try {
1250                session = openSession();
1251
1252                StringBundler query = new StringBundler(3);
1253
1254                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1255
1256                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1257
1258                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1259
1260                String sql = query.toString();
1261
1262                Query q = session.createQuery(sql);
1263
1264                QueryPos qPos = QueryPos.getInstance(q);
1265
1266                qPos.add(companyId);
1267
1268                list = q.list();
1269            }
1270            catch (Exception e) {
1271                throw processException(e);
1272            }
1273            finally {
1274                if (list == null) {
1275                    list = new ArrayList<JournalArticle>();
1276                }
1277
1278                cacheResult(list);
1279
1280                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1281                    finderArgs, list);
1282
1283                closeSession(session);
1284            }
1285        }
1286
1287        return list;
1288    }
1289
1290    public List<JournalArticle> findByCompanyId(long companyId, int start,
1291        int end) throws SystemException {
1292        return findByCompanyId(companyId, start, end, null);
1293    }
1294
1295    public List<JournalArticle> findByCompanyId(long companyId, int start,
1296        int end, OrderByComparator obc) throws SystemException {
1297        Object[] finderArgs = new Object[] {
1298                new Long(companyId),
1299                
1300                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1301            };
1302
1303        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1304                finderArgs, this);
1305
1306        if (list == null) {
1307            Session session = null;
1308
1309            try {
1310                session = openSession();
1311
1312                StringBundler query = null;
1313
1314                if (obc != null) {
1315                    query = new StringBundler(3 +
1316                            (obc.getOrderByFields().length * 3));
1317                }
1318                else {
1319                    query = new StringBundler(3);
1320                }
1321
1322                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1323
1324                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1325
1326                if (obc != null) {
1327                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1328                }
1329
1330                else {
1331                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1332                }
1333
1334                String sql = query.toString();
1335
1336                Query q = session.createQuery(sql);
1337
1338                QueryPos qPos = QueryPos.getInstance(q);
1339
1340                qPos.add(companyId);
1341
1342                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1343                        start, end);
1344            }
1345            catch (Exception e) {
1346                throw processException(e);
1347            }
1348            finally {
1349                if (list == null) {
1350                    list = new ArrayList<JournalArticle>();
1351                }
1352
1353                cacheResult(list);
1354
1355                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1356                    finderArgs, list);
1357
1358                closeSession(session);
1359            }
1360        }
1361
1362        return list;
1363    }
1364
1365    public JournalArticle findByCompanyId_First(long companyId,
1366        OrderByComparator obc) throws NoSuchArticleException, SystemException {
1367        List<JournalArticle> list = findByCompanyId(companyId, 0, 1, obc);
1368
1369        if (list.isEmpty()) {
1370            StringBundler msg = new StringBundler(4);
1371
1372            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1373
1374            msg.append("companyId=");
1375            msg.append(companyId);
1376
1377            msg.append(StringPool.CLOSE_CURLY_BRACE);
1378
1379            throw new NoSuchArticleException(msg.toString());
1380        }
1381        else {
1382            return list.get(0);
1383        }
1384    }
1385
1386    public JournalArticle findByCompanyId_Last(long companyId,
1387        OrderByComparator obc) throws NoSuchArticleException, SystemException {
1388        int count = countByCompanyId(companyId);
1389
1390        List<JournalArticle> list = findByCompanyId(companyId, count - 1,
1391                count, obc);
1392
1393        if (list.isEmpty()) {
1394            StringBundler msg = new StringBundler(4);
1395
1396            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1397
1398            msg.append("companyId=");
1399            msg.append(companyId);
1400
1401            msg.append(StringPool.CLOSE_CURLY_BRACE);
1402
1403            throw new NoSuchArticleException(msg.toString());
1404        }
1405        else {
1406            return list.get(0);
1407        }
1408    }
1409
1410    public JournalArticle[] findByCompanyId_PrevAndNext(long id,
1411        long companyId, OrderByComparator obc)
1412        throws NoSuchArticleException, SystemException {
1413        JournalArticle journalArticle = findByPrimaryKey(id);
1414
1415        int count = countByCompanyId(companyId);
1416
1417        Session session = null;
1418
1419        try {
1420            session = openSession();
1421
1422            StringBundler query = null;
1423
1424            if (obc != null) {
1425                query = new StringBundler(3 +
1426                        (obc.getOrderByFields().length * 3));
1427            }
1428            else {
1429                query = new StringBundler(3);
1430            }
1431
1432            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1433
1434            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1435
1436            if (obc != null) {
1437                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1438            }
1439
1440            else {
1441                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1442            }
1443
1444            String sql = query.toString();
1445
1446            Query q = session.createQuery(sql);
1447
1448            QueryPos qPos = QueryPos.getInstance(q);
1449
1450            qPos.add(companyId);
1451
1452            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1453                    journalArticle);
1454
1455            JournalArticle[] array = new JournalArticleImpl[3];
1456
1457            array[0] = (JournalArticle)objArray[0];
1458            array[1] = (JournalArticle)objArray[1];
1459            array[2] = (JournalArticle)objArray[2];
1460
1461            return array;
1462        }
1463        catch (Exception e) {
1464            throw processException(e);
1465        }
1466        finally {
1467            closeSession(session);
1468        }
1469    }
1470
1471    public List<JournalArticle> findBySmallImageId(long smallImageId)
1472        throws SystemException {
1473        Object[] finderArgs = new Object[] { new Long(smallImageId) };
1474
1475        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_SMALLIMAGEID,
1476                finderArgs, this);
1477
1478        if (list == null) {
1479            Session session = null;
1480
1481            try {
1482                session = openSession();
1483
1484                StringBundler query = new StringBundler(3);
1485
1486                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1487
1488                query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
1489
1490                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1491
1492                String sql = query.toString();
1493
1494                Query q = session.createQuery(sql);
1495
1496                QueryPos qPos = QueryPos.getInstance(q);
1497
1498                qPos.add(smallImageId);
1499
1500                list = q.list();
1501            }
1502            catch (Exception e) {
1503                throw processException(e);
1504            }
1505            finally {
1506                if (list == null) {
1507                    list = new ArrayList<JournalArticle>();
1508                }
1509
1510                cacheResult(list);
1511
1512                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_SMALLIMAGEID,
1513                    finderArgs, list);
1514
1515                closeSession(session);
1516            }
1517        }
1518
1519        return list;
1520    }
1521
1522    public List<JournalArticle> findBySmallImageId(long smallImageId,
1523        int start, int end) throws SystemException {
1524        return findBySmallImageId(smallImageId, start, end, null);
1525    }
1526
1527    public List<JournalArticle> findBySmallImageId(long smallImageId,
1528        int start, int end, OrderByComparator obc) throws SystemException {
1529        Object[] finderArgs = new Object[] {
1530                new Long(smallImageId),
1531                
1532                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1533            };
1534
1535        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_SMALLIMAGEID,
1536                finderArgs, this);
1537
1538        if (list == null) {
1539            Session session = null;
1540
1541            try {
1542                session = openSession();
1543
1544                StringBundler query = null;
1545
1546                if (obc != null) {
1547                    query = new StringBundler(3 +
1548                            (obc.getOrderByFields().length * 3));
1549                }
1550                else {
1551                    query = new StringBundler(3);
1552                }
1553
1554                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1555
1556                query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
1557
1558                if (obc != null) {
1559                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1560                }
1561
1562                else {
1563                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1564                }
1565
1566                String sql = query.toString();
1567
1568                Query q = session.createQuery(sql);
1569
1570                QueryPos qPos = QueryPos.getInstance(q);
1571
1572                qPos.add(smallImageId);
1573
1574                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1575                        start, end);
1576            }
1577            catch (Exception e) {
1578                throw processException(e);
1579            }
1580            finally {
1581                if (list == null) {
1582                    list = new ArrayList<JournalArticle>();
1583                }
1584
1585                cacheResult(list);
1586
1587                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_SMALLIMAGEID,
1588                    finderArgs, list);
1589
1590                closeSession(session);
1591            }
1592        }
1593
1594        return list;
1595    }
1596
1597    public JournalArticle findBySmallImageId_First(long smallImageId,
1598        OrderByComparator obc) throws NoSuchArticleException, SystemException {
1599        List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1, obc);
1600
1601        if (list.isEmpty()) {
1602            StringBundler msg = new StringBundler(4);
1603
1604            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1605
1606            msg.append("smallImageId=");
1607            msg.append(smallImageId);
1608
1609            msg.append(StringPool.CLOSE_CURLY_BRACE);
1610
1611            throw new NoSuchArticleException(msg.toString());
1612        }
1613        else {
1614            return list.get(0);
1615        }
1616    }
1617
1618    public JournalArticle findBySmallImageId_Last(long smallImageId,
1619        OrderByComparator obc) throws NoSuchArticleException, SystemException {
1620        int count = countBySmallImageId(smallImageId);
1621
1622        List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
1623                count, obc);
1624
1625        if (list.isEmpty()) {
1626            StringBundler msg = new StringBundler(4);
1627
1628            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1629
1630            msg.append("smallImageId=");
1631            msg.append(smallImageId);
1632
1633            msg.append(StringPool.CLOSE_CURLY_BRACE);
1634
1635            throw new NoSuchArticleException(msg.toString());
1636        }
1637        else {
1638            return list.get(0);
1639        }
1640    }
1641
1642    public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
1643        long smallImageId, OrderByComparator obc)
1644        throws NoSuchArticleException, SystemException {
1645        JournalArticle journalArticle = findByPrimaryKey(id);
1646
1647        int count = countBySmallImageId(smallImageId);
1648
1649        Session session = null;
1650
1651        try {
1652            session = openSession();
1653
1654            StringBundler query = null;
1655
1656            if (obc != null) {
1657                query = new StringBundler(3 +
1658                        (obc.getOrderByFields().length * 3));
1659            }
1660            else {
1661                query = new StringBundler(3);
1662            }
1663
1664            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1665
1666            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
1667
1668            if (obc != null) {
1669                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1670            }
1671
1672            else {
1673                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1674            }
1675
1676            String sql = query.toString();
1677
1678            Query q = session.createQuery(sql);
1679
1680            QueryPos qPos = QueryPos.getInstance(q);
1681
1682            qPos.add(smallImageId);
1683
1684            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1685                    journalArticle);
1686
1687            JournalArticle[] array = new JournalArticleImpl[3];
1688
1689            array[0] = (JournalArticle)objArray[0];
1690            array[1] = (JournalArticle)objArray[1];
1691            array[2] = (JournalArticle)objArray[2];
1692
1693            return array;
1694        }
1695        catch (Exception e) {
1696            throw processException(e);
1697        }
1698        finally {
1699            closeSession(session);
1700        }
1701    }
1702
1703    public List<JournalArticle> findByR_A(long resourcePrimKey, boolean approved)
1704        throws SystemException {
1705        Object[] finderArgs = new Object[] {
1706                new Long(resourcePrimKey), Boolean.valueOf(approved)
1707            };
1708
1709        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_A,
1710                finderArgs, this);
1711
1712        if (list == null) {
1713            Session session = null;
1714
1715            try {
1716                session = openSession();
1717
1718                StringBundler query = new StringBundler(4);
1719
1720                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1721
1722                query.append(_FINDER_COLUMN_R_A_RESOURCEPRIMKEY_2);
1723
1724                query.append(_FINDER_COLUMN_R_A_APPROVED_2);
1725
1726                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1727
1728                String sql = query.toString();
1729
1730                Query q = session.createQuery(sql);
1731
1732                QueryPos qPos = QueryPos.getInstance(q);
1733
1734                qPos.add(resourcePrimKey);
1735
1736                qPos.add(approved);
1737
1738                list = q.list();
1739            }
1740            catch (Exception e) {
1741                throw processException(e);
1742            }
1743            finally {
1744                if (list == null) {
1745                    list = new ArrayList<JournalArticle>();
1746                }
1747
1748                cacheResult(list);
1749
1750                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_A, finderArgs,
1751                    list);
1752
1753                closeSession(session);
1754            }
1755        }
1756
1757        return list;
1758    }
1759
1760    public List<JournalArticle> findByR_A(long resourcePrimKey,
1761        boolean approved, int start, int end) throws SystemException {
1762        return findByR_A(resourcePrimKey, approved, start, end, null);
1763    }
1764
1765    public List<JournalArticle> findByR_A(long resourcePrimKey,
1766        boolean approved, int start, int end, OrderByComparator obc)
1767        throws SystemException {
1768        Object[] finderArgs = new Object[] {
1769                new Long(resourcePrimKey), Boolean.valueOf(approved),
1770                
1771                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1772            };
1773
1774        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_R_A,
1775                finderArgs, this);
1776
1777        if (list == null) {
1778            Session session = null;
1779
1780            try {
1781                session = openSession();
1782
1783                StringBundler query = null;
1784
1785                if (obc != null) {
1786                    query = new StringBundler(4 +
1787                            (obc.getOrderByFields().length * 3));
1788                }
1789                else {
1790                    query = new StringBundler(4);
1791                }
1792
1793                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1794
1795                query.append(_FINDER_COLUMN_R_A_RESOURCEPRIMKEY_2);
1796
1797                query.append(_FINDER_COLUMN_R_A_APPROVED_2);
1798
1799                if (obc != null) {
1800                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1801                }
1802
1803                else {
1804                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1805                }
1806
1807                String sql = query.toString();
1808
1809                Query q = session.createQuery(sql);
1810
1811                QueryPos qPos = QueryPos.getInstance(q);
1812
1813                qPos.add(resourcePrimKey);
1814
1815                qPos.add(approved);
1816
1817                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1818                        start, end);
1819            }
1820            catch (Exception e) {
1821                throw processException(e);
1822            }
1823            finally {
1824                if (list == null) {
1825                    list = new ArrayList<JournalArticle>();
1826                }
1827
1828                cacheResult(list);
1829
1830                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_R_A,
1831                    finderArgs, list);
1832
1833                closeSession(session);
1834            }
1835        }
1836
1837        return list;
1838    }
1839
1840    public JournalArticle findByR_A_First(long resourcePrimKey,
1841        boolean approved, OrderByComparator obc)
1842        throws NoSuchArticleException, SystemException {
1843        List<JournalArticle> list = findByR_A(resourcePrimKey, approved, 0, 1,
1844                obc);
1845
1846        if (list.isEmpty()) {
1847            StringBundler msg = new StringBundler(6);
1848
1849            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1850
1851            msg.append("resourcePrimKey=");
1852            msg.append(resourcePrimKey);
1853
1854            msg.append(", approved=");
1855            msg.append(approved);
1856
1857            msg.append(StringPool.CLOSE_CURLY_BRACE);
1858
1859            throw new NoSuchArticleException(msg.toString());
1860        }
1861        else {
1862            return list.get(0);
1863        }
1864    }
1865
1866    public JournalArticle findByR_A_Last(long resourcePrimKey,
1867        boolean approved, OrderByComparator obc)
1868        throws NoSuchArticleException, SystemException {
1869        int count = countByR_A(resourcePrimKey, approved);
1870
1871        List<JournalArticle> list = findByR_A(resourcePrimKey, approved,
1872                count - 1, count, obc);
1873
1874        if (list.isEmpty()) {
1875            StringBundler msg = new StringBundler(6);
1876
1877            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1878
1879            msg.append("resourcePrimKey=");
1880            msg.append(resourcePrimKey);
1881
1882            msg.append(", approved=");
1883            msg.append(approved);
1884
1885            msg.append(StringPool.CLOSE_CURLY_BRACE);
1886
1887            throw new NoSuchArticleException(msg.toString());
1888        }
1889        else {
1890            return list.get(0);
1891        }
1892    }
1893
1894    public JournalArticle[] findByR_A_PrevAndNext(long id,
1895        long resourcePrimKey, boolean approved, OrderByComparator obc)
1896        throws NoSuchArticleException, SystemException {
1897        JournalArticle journalArticle = findByPrimaryKey(id);
1898
1899        int count = countByR_A(resourcePrimKey, approved);
1900
1901        Session session = null;
1902
1903        try {
1904            session = openSession();
1905
1906            StringBundler query = null;
1907
1908            if (obc != null) {
1909                query = new StringBundler(4 +
1910                        (obc.getOrderByFields().length * 3));
1911            }
1912            else {
1913                query = new StringBundler(4);
1914            }
1915
1916            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1917
1918            query.append(_FINDER_COLUMN_R_A_RESOURCEPRIMKEY_2);
1919
1920            query.append(_FINDER_COLUMN_R_A_APPROVED_2);
1921
1922            if (obc != null) {
1923                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1924            }
1925
1926            else {
1927                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1928            }
1929
1930            String sql = query.toString();
1931
1932            Query q = session.createQuery(sql);
1933
1934            QueryPos qPos = QueryPos.getInstance(q);
1935
1936            qPos.add(resourcePrimKey);
1937
1938            qPos.add(approved);
1939
1940            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1941                    journalArticle);
1942
1943            JournalArticle[] array = new JournalArticleImpl[3];
1944
1945            array[0] = (JournalArticle)objArray[0];
1946            array[1] = (JournalArticle)objArray[1];
1947            array[2] = (JournalArticle)objArray[2];
1948
1949            return array;
1950        }
1951        catch (Exception e) {
1952            throw processException(e);
1953        }
1954        finally {
1955            closeSession(session);
1956        }
1957    }
1958
1959    public List<JournalArticle> findByG_A(long groupId, String articleId)
1960        throws SystemException {
1961        Object[] finderArgs = new Object[] { new Long(groupId), articleId };
1962
1963        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
1964                finderArgs, this);
1965
1966        if (list == null) {
1967            Session session = null;
1968
1969            try {
1970                session = openSession();
1971
1972                StringBundler query = new StringBundler(4);
1973
1974                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1975
1976                query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1977
1978                if (articleId == null) {
1979                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1980                }
1981                else {
1982                    if (articleId.equals(StringPool.BLANK)) {
1983                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1984                    }
1985                    else {
1986                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1987                    }
1988                }
1989
1990                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1991
1992                String sql = query.toString();
1993
1994                Query q = session.createQuery(sql);
1995
1996                QueryPos qPos = QueryPos.getInstance(q);
1997
1998                qPos.add(groupId);
1999
2000                if (articleId != null) {
2001                    qPos.add(articleId);
2002                }
2003
2004                list = q.list();
2005            }
2006            catch (Exception e) {
2007                throw processException(e);
2008            }
2009            finally {
2010                if (list == null) {
2011                    list = new ArrayList<JournalArticle>();
2012                }
2013
2014                cacheResult(list);
2015
2016                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A, finderArgs,
2017                    list);
2018
2019                closeSession(session);
2020            }
2021        }
2022
2023        return list;
2024    }
2025
2026    public List<JournalArticle> findByG_A(long groupId, String articleId,
2027        int start, int end) throws SystemException {
2028        return findByG_A(groupId, articleId, start, end, null);
2029    }
2030
2031    public List<JournalArticle> findByG_A(long groupId, String articleId,
2032        int start, int end, OrderByComparator obc) throws SystemException {
2033        Object[] finderArgs = new Object[] {
2034                new Long(groupId),
2035                
2036                articleId,
2037                
2038                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2039            };
2040
2041        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_A,
2042                finderArgs, this);
2043
2044        if (list == null) {
2045            Session session = null;
2046
2047            try {
2048                session = openSession();
2049
2050                StringBundler query = null;
2051
2052                if (obc != null) {
2053                    query = new StringBundler(4 +
2054                            (obc.getOrderByFields().length * 3));
2055                }
2056                else {
2057                    query = new StringBundler(4);
2058                }
2059
2060                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2061
2062                query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2063
2064                if (articleId == null) {
2065                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2066                }
2067                else {
2068                    if (articleId.equals(StringPool.BLANK)) {
2069                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2070                    }
2071                    else {
2072                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2073                    }
2074                }
2075
2076                if (obc != null) {
2077                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2078                }
2079
2080                else {
2081                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2082                }
2083
2084                String sql = query.toString();
2085
2086                Query q = session.createQuery(sql);
2087
2088                QueryPos qPos = QueryPos.getInstance(q);
2089
2090                qPos.add(groupId);
2091
2092                if (articleId != null) {
2093                    qPos.add(articleId);
2094                }
2095
2096                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2097                        start, end);
2098            }
2099            catch (Exception e) {
2100                throw processException(e);
2101            }
2102            finally {
2103                if (list == null) {
2104                    list = new ArrayList<JournalArticle>();
2105                }
2106
2107                cacheResult(list);
2108
2109                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_A,
2110                    finderArgs, list);
2111
2112                closeSession(session);
2113            }
2114        }
2115
2116        return list;
2117    }
2118
2119    public JournalArticle findByG_A_First(long groupId, String articleId,
2120        OrderByComparator obc) throws NoSuchArticleException, SystemException {
2121        List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1, obc);
2122
2123        if (list.isEmpty()) {
2124            StringBundler msg = new StringBundler(6);
2125
2126            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2127
2128            msg.append("groupId=");
2129            msg.append(groupId);
2130
2131            msg.append(", articleId=");
2132            msg.append(articleId);
2133
2134            msg.append(StringPool.CLOSE_CURLY_BRACE);
2135
2136            throw new NoSuchArticleException(msg.toString());
2137        }
2138        else {
2139            return list.get(0);
2140        }
2141    }
2142
2143    public JournalArticle findByG_A_Last(long groupId, String articleId,
2144        OrderByComparator obc) throws NoSuchArticleException, SystemException {
2145        int count = countByG_A(groupId, articleId);
2146
2147        List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
2148                count, obc);
2149
2150        if (list.isEmpty()) {
2151            StringBundler msg = new StringBundler(6);
2152
2153            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2154
2155            msg.append("groupId=");
2156            msg.append(groupId);
2157
2158            msg.append(", articleId=");
2159            msg.append(articleId);
2160
2161            msg.append(StringPool.CLOSE_CURLY_BRACE);
2162
2163            throw new NoSuchArticleException(msg.toString());
2164        }
2165        else {
2166            return list.get(0);
2167        }
2168    }
2169
2170    public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
2171        String articleId, OrderByComparator obc)
2172        throws NoSuchArticleException, SystemException {
2173        JournalArticle journalArticle = findByPrimaryKey(id);
2174
2175        int count = countByG_A(groupId, articleId);
2176
2177        Session session = null;
2178
2179        try {
2180            session = openSession();
2181
2182            StringBundler query = null;
2183
2184            if (obc != null) {
2185                query = new StringBundler(4 +
2186                        (obc.getOrderByFields().length * 3));
2187            }
2188            else {
2189                query = new StringBundler(4);
2190            }
2191
2192            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2193
2194            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2195
2196            if (articleId == null) {
2197                query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2198            }
2199            else {
2200                if (articleId.equals(StringPool.BLANK)) {
2201                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2202                }
2203                else {
2204                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2205                }
2206            }
2207
2208            if (obc != null) {
2209                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2210            }
2211
2212            else {
2213                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2214            }
2215
2216            String sql = query.toString();
2217
2218            Query q = session.createQuery(sql);
2219
2220            QueryPos qPos = QueryPos.getInstance(q);
2221
2222            qPos.add(groupId);
2223
2224            if (articleId != null) {
2225                qPos.add(articleId);
2226            }
2227
2228            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2229                    journalArticle);
2230
2231            JournalArticle[] array = new JournalArticleImpl[3];
2232
2233            array[0] = (JournalArticle)objArray[0];
2234            array[1] = (JournalArticle)objArray[1];
2235            array[2] = (JournalArticle)objArray[2];
2236
2237            return array;
2238        }
2239        catch (Exception e) {
2240            throw processException(e);
2241        }
2242        finally {
2243            closeSession(session);
2244        }
2245    }
2246
2247    public List<JournalArticle> findByG_S(long groupId, String structureId)
2248        throws SystemException {
2249        Object[] finderArgs = new Object[] { new Long(groupId), structureId };
2250
2251        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_S,
2252                finderArgs, this);
2253
2254        if (list == null) {
2255            Session session = null;
2256
2257            try {
2258                session = openSession();
2259
2260                StringBundler query = new StringBundler(4);
2261
2262                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2263
2264                query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2265
2266                if (structureId == null) {
2267                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
2268                }
2269                else {
2270                    if (structureId.equals(StringPool.BLANK)) {
2271                        query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
2272                    }
2273                    else {
2274                        query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
2275                    }
2276                }
2277
2278                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2279
2280                String sql = query.toString();
2281
2282                Query q = session.createQuery(sql);
2283
2284                QueryPos qPos = QueryPos.getInstance(q);
2285
2286                qPos.add(groupId);
2287
2288                if (structureId != null) {
2289                    qPos.add(structureId);
2290                }
2291
2292                list = q.list();
2293            }
2294            catch (Exception e) {
2295                throw processException(e);
2296            }
2297            finally {
2298                if (list == null) {
2299                    list = new ArrayList<JournalArticle>();
2300                }
2301
2302                cacheResult(list);
2303
2304                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_S, finderArgs,
2305                    list);
2306
2307                closeSession(session);
2308            }
2309        }
2310
2311        return list;
2312    }
2313
2314    public List<JournalArticle> findByG_S(long groupId, String structureId,
2315        int start, int end) throws SystemException {
2316        return findByG_S(groupId, structureId, start, end, null);
2317    }
2318
2319    public List<JournalArticle> findByG_S(long groupId, String structureId,
2320        int start, int end, OrderByComparator obc) throws SystemException {
2321        Object[] finderArgs = new Object[] {
2322                new Long(groupId),
2323                
2324                structureId,
2325                
2326                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2327            };
2328
2329        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_S,
2330                finderArgs, this);
2331
2332        if (list == null) {
2333            Session session = null;
2334
2335            try {
2336                session = openSession();
2337
2338                StringBundler query = null;
2339
2340                if (obc != null) {
2341                    query = new StringBundler(4 +
2342                            (obc.getOrderByFields().length * 3));
2343                }
2344                else {
2345                    query = new StringBundler(4);
2346                }
2347
2348                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2349
2350                query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2351
2352                if (structureId == null) {
2353                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
2354                }
2355                else {
2356                    if (structureId.equals(StringPool.BLANK)) {
2357                        query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
2358                    }
2359                    else {
2360                        query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
2361                    }
2362                }
2363
2364                if (obc != null) {
2365                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2366                }
2367
2368                else {
2369                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2370                }
2371
2372                String sql = query.toString();
2373
2374                Query q = session.createQuery(sql);
2375
2376                QueryPos qPos = QueryPos.getInstance(q);
2377
2378                qPos.add(groupId);
2379
2380                if (structureId != null) {
2381                    qPos.add(structureId);
2382                }
2383
2384                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2385                        start, end);
2386            }
2387            catch (Exception e) {
2388                throw processException(e);
2389            }
2390            finally {
2391                if (list == null) {
2392                    list = new ArrayList<JournalArticle>();
2393                }
2394
2395                cacheResult(list);
2396
2397                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_S,
2398                    finderArgs, list);
2399
2400                closeSession(session);
2401            }
2402        }
2403
2404        return list;
2405    }
2406
2407    public JournalArticle findByG_S_First(long groupId, String structureId,
2408        OrderByComparator obc) throws NoSuchArticleException, SystemException {
2409        List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1, obc);
2410
2411        if (list.isEmpty()) {
2412            StringBundler msg = new StringBundler(6);
2413
2414            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2415
2416            msg.append("groupId=");
2417            msg.append(groupId);
2418
2419            msg.append(", structureId=");
2420            msg.append(structureId);
2421
2422            msg.append(StringPool.CLOSE_CURLY_BRACE);
2423
2424            throw new NoSuchArticleException(msg.toString());
2425        }
2426        else {
2427            return list.get(0);
2428        }
2429    }
2430
2431    public JournalArticle findByG_S_Last(long groupId, String structureId,
2432        OrderByComparator obc) throws NoSuchArticleException, SystemException {
2433        int count = countByG_S(groupId, structureId);
2434
2435        List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
2436                count, obc);
2437
2438        if (list.isEmpty()) {
2439            StringBundler msg = new StringBundler(6);
2440
2441            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2442
2443            msg.append("groupId=");
2444            msg.append(groupId);
2445
2446            msg.append(", structureId=");
2447            msg.append(structureId);
2448
2449            msg.append(StringPool.CLOSE_CURLY_BRACE);
2450
2451            throw new NoSuchArticleException(msg.toString());
2452        }
2453        else {
2454            return list.get(0);
2455        }
2456    }
2457
2458    public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
2459        String structureId, OrderByComparator obc)
2460        throws NoSuchArticleException, SystemException {
2461        JournalArticle journalArticle = findByPrimaryKey(id);
2462
2463        int count = countByG_S(groupId, structureId);
2464
2465        Session session = null;
2466
2467        try {
2468            session = openSession();
2469
2470            StringBundler query = null;
2471
2472            if (obc != null) {
2473                query = new StringBundler(4 +
2474                        (obc.getOrderByFields().length * 3));
2475            }
2476            else {
2477                query = new StringBundler(4);
2478            }
2479
2480            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2481
2482            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2483
2484            if (structureId == null) {
2485                query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
2486            }
2487            else {
2488                if (structureId.equals(StringPool.BLANK)) {
2489                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
2490                }
2491                else {
2492                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
2493                }
2494            }
2495
2496            if (obc != null) {
2497                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2498            }
2499
2500            else {
2501                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2502            }
2503
2504            String sql = query.toString();
2505
2506            Query q = session.createQuery(sql);
2507
2508            QueryPos qPos = QueryPos.getInstance(q);
2509
2510            qPos.add(groupId);
2511
2512            if (structureId != null) {
2513                qPos.add(structureId);
2514            }
2515
2516            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2517                    journalArticle);
2518
2519            JournalArticle[] array = new JournalArticleImpl[3];
2520
2521            array[0] = (JournalArticle)objArray[0];
2522            array[1] = (JournalArticle)objArray[1];
2523            array[2] = (JournalArticle)objArray[2];
2524
2525            return array;
2526        }
2527        catch (Exception e) {
2528            throw processException(e);
2529        }
2530        finally {
2531            closeSession(session);
2532        }
2533    }
2534
2535    public List<JournalArticle> findByG_T(long groupId, String templateId)
2536        throws SystemException {
2537        Object[] finderArgs = new Object[] { new Long(groupId), templateId };
2538
2539        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_T,
2540                finderArgs, this);
2541
2542        if (list == null) {
2543            Session session = null;
2544
2545            try {
2546                session = openSession();
2547
2548                StringBundler query = new StringBundler(4);
2549
2550                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2551
2552                query.append(_FINDER_COLUMN_G_T_GROUPID_2);
2553
2554                if (templateId == null) {
2555                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
2556                }
2557                else {
2558                    if (templateId.equals(StringPool.BLANK)) {
2559                        query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
2560                    }
2561                    else {
2562                        query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
2563                    }
2564                }
2565
2566                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2567
2568                String sql = query.toString();
2569
2570                Query q = session.createQuery(sql);
2571
2572                QueryPos qPos = QueryPos.getInstance(q);
2573
2574                qPos.add(groupId);
2575
2576                if (templateId != null) {
2577                    qPos.add(templateId);
2578                }
2579
2580                list = q.list();
2581            }
2582            catch (Exception e) {
2583                throw processException(e);
2584            }
2585            finally {
2586                if (list == null) {
2587                    list = new ArrayList<JournalArticle>();
2588                }
2589
2590                cacheResult(list);
2591
2592                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_T, finderArgs,
2593                    list);
2594
2595                closeSession(session);
2596            }
2597        }
2598
2599        return list;
2600    }
2601
2602    public List<JournalArticle> findByG_T(long groupId, String templateId,
2603        int start, int end) throws SystemException {
2604        return findByG_T(groupId, templateId, start, end, null);
2605    }
2606
2607    public List<JournalArticle> findByG_T(long groupId, String templateId,
2608        int start, int end, OrderByComparator obc) throws SystemException {
2609        Object[] finderArgs = new Object[] {
2610                new Long(groupId),
2611                
2612                templateId,
2613                
2614                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2615            };
2616
2617        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_T,
2618                finderArgs, this);
2619
2620        if (list == null) {
2621            Session session = null;
2622
2623            try {
2624                session = openSession();
2625
2626                StringBundler query = null;
2627
2628                if (obc != null) {
2629                    query = new StringBundler(4 +
2630                            (obc.getOrderByFields().length * 3));
2631                }
2632                else {
2633                    query = new StringBundler(4);
2634                }
2635
2636                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2637
2638                query.append(_FINDER_COLUMN_G_T_GROUPID_2);
2639
2640                if (templateId == null) {
2641                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
2642                }
2643                else {
2644                    if (templateId.equals(StringPool.BLANK)) {
2645                        query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
2646                    }
2647                    else {
2648                        query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
2649                    }
2650                }
2651
2652                if (obc != null) {
2653                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2654                }
2655
2656                else {
2657                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2658                }
2659
2660                String sql = query.toString();
2661
2662                Query q = session.createQuery(sql);
2663
2664                QueryPos qPos = QueryPos.getInstance(q);
2665
2666                qPos.add(groupId);
2667
2668                if (templateId != null) {
2669                    qPos.add(templateId);
2670                }
2671
2672                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2673                        start, end);
2674            }
2675            catch (Exception e) {
2676                throw processException(e);
2677            }
2678            finally {
2679                if (list == null) {
2680                    list = new ArrayList<JournalArticle>();
2681                }
2682
2683                cacheResult(list);
2684
2685                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_T,
2686                    finderArgs, list);
2687
2688                closeSession(session);
2689            }
2690        }
2691
2692        return list;
2693    }
2694
2695    public JournalArticle findByG_T_First(long groupId, String templateId,
2696        OrderByComparator obc) throws NoSuchArticleException, SystemException {
2697        List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1, obc);
2698
2699        if (list.isEmpty()) {
2700            StringBundler msg = new StringBundler(6);
2701
2702            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2703
2704            msg.append("groupId=");
2705            msg.append(groupId);
2706
2707            msg.append(", templateId=");
2708            msg.append(templateId);
2709
2710            msg.append(StringPool.CLOSE_CURLY_BRACE);
2711
2712            throw new NoSuchArticleException(msg.toString());
2713        }
2714        else {
2715            return list.get(0);
2716        }
2717    }
2718
2719    public JournalArticle findByG_T_Last(long groupId, String templateId,
2720        OrderByComparator obc) throws NoSuchArticleException, SystemException {
2721        int count = countByG_T(groupId, templateId);
2722
2723        List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
2724                count, obc);
2725
2726        if (list.isEmpty()) {
2727            StringBundler msg = new StringBundler(6);
2728
2729            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2730
2731            msg.append("groupId=");
2732            msg.append(groupId);
2733
2734            msg.append(", templateId=");
2735            msg.append(templateId);
2736
2737            msg.append(StringPool.CLOSE_CURLY_BRACE);
2738
2739            throw new NoSuchArticleException(msg.toString());
2740        }
2741        else {
2742            return list.get(0);
2743        }
2744    }
2745
2746    public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
2747        String templateId, OrderByComparator obc)
2748        throws NoSuchArticleException, SystemException {
2749        JournalArticle journalArticle = findByPrimaryKey(id);
2750
2751        int count = countByG_T(groupId, templateId);
2752
2753        Session session = null;
2754
2755        try {
2756            session = openSession();
2757
2758            StringBundler query = null;
2759
2760            if (obc != null) {
2761                query = new StringBundler(4 +
2762                        (obc.getOrderByFields().length * 3));
2763            }
2764            else {
2765                query = new StringBundler(4);
2766            }
2767
2768            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2769
2770            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
2771
2772            if (templateId == null) {
2773                query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
2774            }
2775            else {
2776                if (templateId.equals(StringPool.BLANK)) {
2777                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
2778                }
2779                else {
2780                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
2781                }
2782            }
2783
2784            if (obc != null) {
2785                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2786            }
2787
2788            else {
2789                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2790            }
2791
2792            String sql = query.toString();
2793
2794            Query q = session.createQuery(sql);
2795
2796            QueryPos qPos = QueryPos.getInstance(q);
2797
2798            qPos.add(groupId);
2799
2800            if (templateId != null) {
2801                qPos.add(templateId);
2802            }
2803
2804            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2805                    journalArticle);
2806
2807            JournalArticle[] array = new JournalArticleImpl[3];
2808
2809            array[0] = (JournalArticle)objArray[0];
2810            array[1] = (JournalArticle)objArray[1];
2811            array[2] = (JournalArticle)objArray[2];
2812
2813            return array;
2814        }
2815        catch (Exception e) {
2816            throw processException(e);
2817        }
2818        finally {
2819            closeSession(session);
2820        }
2821    }
2822
2823    public JournalArticle findByG_A_V(long groupId, String articleId,
2824        double version) throws NoSuchArticleException, SystemException {
2825        JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
2826
2827        if (journalArticle == null) {
2828            StringBundler msg = new StringBundler(8);
2829
2830            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2831
2832            msg.append("groupId=");
2833            msg.append(groupId);
2834
2835            msg.append(", articleId=");
2836            msg.append(articleId);
2837
2838            msg.append(", version=");
2839            msg.append(version);
2840
2841            msg.append(StringPool.CLOSE_CURLY_BRACE);
2842
2843            if (_log.isWarnEnabled()) {
2844                _log.warn(msg.toString());
2845            }
2846
2847            throw new NoSuchArticleException(msg.toString());
2848        }
2849
2850        return journalArticle;
2851    }
2852
2853    public JournalArticle fetchByG_A_V(long groupId, String articleId,
2854        double version) throws SystemException {
2855        return fetchByG_A_V(groupId, articleId, version, true);
2856    }
2857
2858    public JournalArticle fetchByG_A_V(long groupId, String articleId,
2859        double version, boolean retrieveFromCache) throws SystemException {
2860        Object[] finderArgs = new Object[] {
2861                new Long(groupId),
2862                
2863                articleId, new Double(version)
2864            };
2865
2866        Object result = null;
2867
2868        if (retrieveFromCache) {
2869            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
2870                    finderArgs, this);
2871        }
2872
2873        if (result == null) {
2874            Session session = null;
2875
2876            try {
2877                session = openSession();
2878
2879                StringBundler query = new StringBundler(5);
2880
2881                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2882
2883                query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
2884
2885                if (articleId == null) {
2886                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
2887                }
2888                else {
2889                    if (articleId.equals(StringPool.BLANK)) {
2890                        query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
2891                    }
2892                    else {
2893                        query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
2894                    }
2895                }
2896
2897                query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
2898
2899                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2900
2901                String sql = query.toString();
2902
2903                Query q = session.createQuery(sql);
2904
2905                QueryPos qPos = QueryPos.getInstance(q);
2906
2907                qPos.add(groupId);
2908
2909                if (articleId != null) {
2910                    qPos.add(articleId);
2911                }
2912
2913                qPos.add(version);
2914
2915                List<JournalArticle> list = q.list();
2916
2917                result = list;
2918
2919                JournalArticle journalArticle = null;
2920
2921                if (list.isEmpty()) {
2922                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
2923                        finderArgs, list);
2924                }
2925                else {
2926                    journalArticle = list.get(0);
2927
2928                    cacheResult(journalArticle);
2929
2930                    if ((journalArticle.getGroupId() != groupId) ||
2931                            (journalArticle.getArticleId() == null) ||
2932                            !journalArticle.getArticleId().equals(articleId) ||
2933                            (journalArticle.getVersion() != version)) {
2934                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
2935                            finderArgs, journalArticle);
2936                    }
2937                }
2938
2939                return journalArticle;
2940            }
2941            catch (Exception e) {
2942                throw processException(e);
2943            }
2944            finally {
2945                if (result == null) {
2946                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
2947                        finderArgs, new ArrayList<JournalArticle>());
2948                }
2949
2950                closeSession(session);
2951            }
2952        }
2953        else {
2954            if (result instanceof List<?>) {
2955                return null;
2956            }
2957            else {
2958                return (JournalArticle)result;
2959            }
2960        }
2961    }
2962
2963    public List<JournalArticle> findByG_A_A(long groupId, String articleId,
2964        boolean approved) throws SystemException {
2965        Object[] finderArgs = new Object[] {
2966                new Long(groupId),
2967                
2968                articleId, Boolean.valueOf(approved)
2969            };
2970
2971        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A_A,
2972                finderArgs, this);
2973
2974        if (list == null) {
2975            Session session = null;
2976
2977            try {
2978                session = openSession();
2979
2980                StringBundler query = new StringBundler(5);
2981
2982                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2983
2984                query.append(_FINDER_COLUMN_G_A_A_GROUPID_2);
2985
2986                if (articleId == null) {
2987                    query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_1);
2988                }
2989                else {
2990                    if (articleId.equals(StringPool.BLANK)) {
2991                        query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_3);
2992                    }
2993                    else {
2994                        query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_2);
2995                    }
2996                }
2997
2998                query.append(_FINDER_COLUMN_G_A_A_APPROVED_2);
2999
3000                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3001
3002                String sql = query.toString();
3003
3004                Query q = session.createQuery(sql);
3005
3006                QueryPos qPos = QueryPos.getInstance(q);
3007
3008                qPos.add(groupId);
3009
3010                if (articleId != null) {
3011                    qPos.add(articleId);
3012                }
3013
3014                qPos.add(approved);
3015
3016                list = q.list();
3017            }
3018            catch (Exception e) {
3019                throw processException(e);
3020            }
3021            finally {
3022                if (list == null) {
3023                    list = new ArrayList<JournalArticle>();
3024                }
3025
3026                cacheResult(list);
3027
3028                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A_A,
3029                    finderArgs, list);
3030
3031                closeSession(session);
3032            }
3033        }
3034
3035        return list;
3036    }
3037
3038    public List<JournalArticle> findByG_A_A(long groupId, String articleId,
3039        boolean approved, int start, int end) throws SystemException {
3040        return findByG_A_A(groupId, articleId, approved, start, end, null);
3041    }
3042
3043    public List<JournalArticle> findByG_A_A(long groupId, String articleId,
3044        boolean approved, int start, int end, OrderByComparator obc)
3045        throws SystemException {
3046        Object[] finderArgs = new Object[] {
3047                new Long(groupId),
3048                
3049                articleId, Boolean.valueOf(approved),
3050                
3051                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3052            };
3053
3054        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_A_A,
3055                finderArgs, this);
3056
3057        if (list == null) {
3058            Session session = null;
3059
3060            try {
3061                session = openSession();
3062
3063                StringBundler query = null;
3064
3065                if (obc != null) {
3066                    query = new StringBundler(5 +
3067                            (obc.getOrderByFields().length * 3));
3068                }
3069                else {
3070                    query = new StringBundler(5);
3071                }
3072
3073                query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3074
3075                query.append(_FINDER_COLUMN_G_A_A_GROUPID_2);
3076
3077                if (articleId == null) {
3078                    query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_1);
3079                }
3080                else {
3081                    if (articleId.equals(StringPool.BLANK)) {
3082                        query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_3);
3083                    }
3084                    else {
3085                        query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_2);
3086                    }
3087                }
3088
3089                query.append(_FINDER_COLUMN_G_A_A_APPROVED_2);
3090
3091                if (obc != null) {
3092                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3093                }
3094
3095                else {
3096                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3097                }
3098
3099                String sql = query.toString();
3100
3101                Query q = session.createQuery(sql);
3102
3103                QueryPos qPos = QueryPos.getInstance(q);
3104
3105                qPos.add(groupId);
3106
3107                if (articleId != null) {
3108                    qPos.add(articleId);
3109                }
3110
3111                qPos.add(approved);
3112
3113                list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3114                        start, end);
3115            }
3116            catch (Exception e) {
3117                throw processException(e);
3118            }
3119            finally {
3120                if (list == null) {
3121                    list = new ArrayList<JournalArticle>();
3122                }
3123
3124                cacheResult(list);
3125
3126                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_A_A,
3127                    finderArgs, list);
3128
3129                closeSession(session);
3130            }
3131        }
3132
3133        return list;
3134    }
3135
3136    public JournalArticle findByG_A_A_First(long groupId, String articleId,
3137        boolean approved, OrderByComparator obc)
3138        throws NoSuchArticleException, SystemException {
3139        List<JournalArticle> list = findByG_A_A(groupId, articleId, approved,
3140                0, 1, obc);
3141
3142        if (list.isEmpty()) {
3143            StringBundler msg = new StringBundler(8);
3144
3145            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3146
3147            msg.append("groupId=");
3148            msg.append(groupId);
3149
3150            msg.append(", articleId=");
3151            msg.append(articleId);
3152
3153            msg.append(", approved=");
3154            msg.append(approved);
3155
3156            msg.append(StringPool.CLOSE_CURLY_BRACE);
3157
3158            throw new NoSuchArticleException(msg.toString());
3159        }
3160        else {
3161            return list.get(0);
3162        }
3163    }
3164
3165    public JournalArticle findByG_A_A_Last(long groupId, String articleId,
3166        boolean approved, OrderByComparator obc)
3167        throws NoSuchArticleException, SystemException {
3168        int count = countByG_A_A(groupId, articleId, approved);
3169
3170        List<JournalArticle> list = findByG_A_A(groupId, articleId, approved,
3171                count - 1, count, obc);
3172
3173        if (list.isEmpty()) {
3174            StringBundler msg = new StringBundler(8);
3175
3176            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3177
3178            msg.append("groupId=");
3179            msg.append(groupId);
3180
3181            msg.append(", articleId=");
3182            msg.append(articleId);
3183
3184            msg.append(", approved=");
3185            msg.append(approved);
3186
3187            msg.append(StringPool.CLOSE_CURLY_BRACE);
3188
3189            throw new NoSuchArticleException(msg.toString());
3190        }
3191        else {
3192            return list.get(0);
3193        }
3194    }
3195
3196    public JournalArticle[] findByG_A_A_PrevAndNext(long id, long groupId,
3197        String articleId, boolean approved, OrderByComparator obc)
3198        throws NoSuchArticleException, SystemException {
3199        JournalArticle journalArticle = findByPrimaryKey(id);
3200
3201        int count = countByG_A_A(groupId, articleId, approved);
3202
3203        Session session = null;
3204
3205        try {
3206            session = openSession();
3207
3208            StringBundler query = null;
3209
3210            if (obc != null) {
3211                query = new StringBundler(5 +
3212                        (obc.getOrderByFields().length * 3));
3213            }
3214            else {
3215                query = new StringBundler(5);
3216            }
3217
3218            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3219
3220            query.append(_FINDER_COLUMN_G_A_A_GROUPID_2);
3221
3222            if (articleId == null) {
3223                query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_1);
3224            }
3225            else {
3226                if (articleId.equals(StringPool.BLANK)) {
3227                    query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_3);
3228                }
3229                else {
3230                    query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_2);
3231                }
3232            }
3233
3234            query.append(_FINDER_COLUMN_G_A_A_APPROVED_2);
3235
3236            if (obc != null) {
3237                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3238            }
3239
3240            else {
3241                query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3242            }
3243
3244            String sql = query.toString();
3245
3246            Query q = session.createQuery(sql);
3247
3248            QueryPos qPos = QueryPos.getInstance(q);
3249
3250            qPos.add(groupId);
3251
3252            if (articleId != null) {
3253                qPos.add(articleId);
3254            }
3255
3256            qPos.add(approved);
3257
3258            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
3259                    journalArticle);
3260
3261            JournalArticle[] array = new JournalArticleImpl[3];
3262
3263            array[0] = (JournalArticle)objArray[0];
3264            array[1] = (JournalArticle)objArray[1];
3265            array[2] = (JournalArticle)objArray[2];
3266
3267            return array;
3268        }
3269        catch (Exception e) {
3270            throw processException(e);
3271        }
3272        finally {
3273            closeSession(session);
3274        }
3275    }
3276
3277    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
3278        throws SystemException {
3279        Session session = null;
3280
3281        try {
3282            session = openSession();
3283
3284            dynamicQuery.compile(session);
3285
3286            return dynamicQuery.list();
3287        }
3288        catch (Exception e) {
3289            throw processException(e);
3290        }
3291        finally {
3292            closeSession(session);
3293        }
3294    }
3295
3296    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
3297        int start, int end) throws SystemException {
3298        Session session = null;
3299
3300        try {
3301            session = openSession();
3302
3303            dynamicQuery.setLimit(start, end);
3304
3305            dynamicQuery.compile(session);
3306
3307            return dynamicQuery.list();
3308        }
3309        catch (Exception e) {
3310            throw processException(e);
3311        }
3312        finally {
3313            closeSession(session);
3314        }
3315    }
3316
3317    public List<JournalArticle> findAll() throws SystemException {
3318        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3319    }
3320
3321    public List<JournalArticle> findAll(int start, int end)
3322        throws SystemException {
3323        return findAll(start, end, null);
3324    }
3325
3326    public List<JournalArticle> findAll(int start, int end,
3327        OrderByComparator obc) throws SystemException {
3328        Object[] finderArgs = new Object[] {
3329                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3330            };
3331
3332        List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3333                finderArgs, this);
3334
3335        if (list == null) {
3336            Session session = null;
3337
3338            try {
3339                session = openSession();
3340
3341                StringBundler query = null;
3342                String sql = null;
3343
3344                if (obc != null) {
3345                    query = new StringBundler(2 +
3346                            (obc.getOrderByFields().length * 3));
3347
3348                    query.append(_SQL_SELECT_JOURNALARTICLE);
3349
3350                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3351
3352                    sql = query.toString();
3353                }
3354
3355                else {
3356                    sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
3357                }
3358
3359                Query q = session.createQuery(sql);
3360
3361                if (obc == null) {
3362                    list = (List<JournalArticle>)QueryUtil.list(q,
3363                            getDialect(), start, end, false);
3364
3365                    Collections.sort(list);
3366                }
3367                else {
3368                    list = (List<JournalArticle>)QueryUtil.list(q,
3369                            getDialect(), start, end);
3370                }
3371            }
3372            catch (Exception e) {
3373                throw processException(e);
3374            }
3375            finally {
3376                if (list == null) {
3377                    list = new ArrayList<JournalArticle>();
3378                }
3379
3380                cacheResult(list);
3381
3382                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3383
3384                closeSession(session);
3385            }
3386        }
3387
3388        return list;
3389    }
3390
3391    public void removeByUuid(String uuid) throws SystemException {
3392        for (JournalArticle journalArticle : findByUuid(uuid)) {
3393            remove(journalArticle);
3394        }
3395    }
3396
3397    public void removeByUUID_G(String uuid, long groupId)
3398        throws NoSuchArticleException, SystemException {
3399        JournalArticle journalArticle = findByUUID_G(uuid, groupId);
3400
3401        remove(journalArticle);
3402    }
3403
3404    public void removeByGroupId(long groupId) throws SystemException {
3405        for (JournalArticle journalArticle : findByGroupId(groupId)) {
3406            remove(journalArticle);
3407        }
3408    }
3409
3410    public void removeByCompanyId(long companyId) throws SystemException {
3411        for (JournalArticle journalArticle : findByCompanyId(companyId)) {
3412            remove(journalArticle);
3413        }
3414    }
3415
3416    public void removeBySmallImageId(long smallImageId)
3417        throws SystemException {
3418        for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
3419            remove(journalArticle);
3420        }
3421    }
3422
3423    public void removeByR_A(long resourcePrimKey, boolean approved)
3424        throws SystemException {
3425        for (JournalArticle journalArticle : findByR_A(resourcePrimKey, approved)) {
3426            remove(journalArticle);
3427        }
3428    }
3429
3430    public void removeByG_A(long groupId, String articleId)
3431        throws SystemException {
3432        for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
3433            remove(journalArticle);
3434        }
3435    }
3436
3437    public void removeByG_S(long groupId, String structureId)
3438        throws SystemException {
3439        for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
3440            remove(journalArticle);
3441        }
3442    }
3443
3444    public void removeByG_T(long groupId, String templateId)
3445        throws SystemException {
3446        for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
3447            remove(journalArticle);
3448        }
3449    }
3450
3451    public void removeByG_A_V(long groupId, String articleId, double version)
3452        throws NoSuchArticleException, SystemException {
3453        JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
3454
3455        remove(journalArticle);
3456    }
3457
3458    public void removeByG_A_A(long groupId, String articleId, boolean approved)
3459        throws SystemException {
3460        for (JournalArticle journalArticle : findByG_A_A(groupId, articleId,
3461                approved)) {
3462            remove(journalArticle);
3463        }
3464    }
3465
3466    public void removeAll() throws SystemException {
3467        for (JournalArticle journalArticle : findAll()) {
3468            remove(journalArticle);
3469        }
3470    }
3471
3472    public int countByUuid(String uuid) throws SystemException {
3473        Object[] finderArgs = new Object[] { uuid };
3474
3475        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3476                finderArgs, this);
3477
3478        if (count == null) {
3479            Session session = null;
3480
3481            try {
3482                session = openSession();
3483
3484                StringBundler query = new StringBundler(2);
3485
3486                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3487
3488                if (uuid == null) {
3489                    query.append(_FINDER_COLUMN_UUID_UUID_1);
3490                }
3491                else {
3492                    if (uuid.equals(StringPool.BLANK)) {
3493                        query.append(_FINDER_COLUMN_UUID_UUID_3);
3494                    }
3495                    else {
3496                        query.append(_FINDER_COLUMN_UUID_UUID_2);
3497                    }
3498                }
3499
3500                String sql = query.toString();
3501
3502                Query q = session.createQuery(sql);
3503
3504                QueryPos qPos = QueryPos.getInstance(q);
3505
3506                if (uuid != null) {
3507                    qPos.add(uuid);
3508                }
3509
3510                count = (Long)q.uniqueResult();
3511            }
3512            catch (Exception e) {
3513                throw processException(e);
3514            }
3515            finally {
3516                if (count == null) {
3517                    count = Long.valueOf(0);
3518                }
3519
3520                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3521                    finderArgs, count);
3522
3523                closeSession(session);
3524            }
3525        }
3526
3527        return count.intValue();
3528    }
3529
3530    public int countByUUID_G(String uuid, long groupId)
3531        throws SystemException {
3532        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
3533
3534        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3535                finderArgs, this);
3536
3537        if (count == null) {
3538            Session session = null;
3539
3540            try {
3541                session = openSession();
3542
3543                StringBundler query = new StringBundler(3);
3544
3545                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3546
3547                if (uuid == null) {
3548                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3549                }
3550                else {
3551                    if (uuid.equals(StringPool.BLANK)) {
3552                        query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3553                    }
3554                    else {
3555                        query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3556                    }
3557                }
3558
3559                query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3560
3561                String sql = query.toString();
3562
3563                Query q = session.createQuery(sql);
3564
3565                QueryPos qPos = QueryPos.getInstance(q);
3566
3567                if (uuid != null) {
3568                    qPos.add(uuid);
3569                }
3570
3571                qPos.add(groupId);
3572
3573                count = (Long)q.uniqueResult();
3574            }
3575            catch (Exception e) {
3576                throw processException(e);
3577            }
3578            finally {
3579                if (count == null) {
3580                    count = Long.valueOf(0);
3581                }
3582
3583                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3584                    finderArgs, count);
3585
3586                closeSession(session);
3587            }
3588        }
3589
3590        return count.intValue();
3591    }
3592
3593    public int countByGroupId(long groupId) throws SystemException {
3594        Object[] finderArgs = new Object[] { new Long(groupId) };
3595
3596        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3597                finderArgs, this);
3598
3599        if (count == null) {
3600            Session session = null;
3601
3602            try {
3603                session = openSession();
3604
3605                StringBundler query = new StringBundler(2);
3606
3607                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3608
3609                query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3610
3611                String sql = query.toString();
3612
3613                Query q = session.createQuery(sql);
3614
3615                QueryPos qPos = QueryPos.getInstance(q);
3616
3617                qPos.add(groupId);
3618
3619                count = (Long)q.uniqueResult();
3620            }
3621            catch (Exception e) {
3622                throw processException(e);
3623            }
3624            finally {
3625                if (count == null) {
3626                    count = Long.valueOf(0);
3627                }
3628
3629                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
3630                    finderArgs, count);
3631
3632                closeSession(session);
3633            }
3634        }
3635
3636        return count.intValue();
3637    }
3638
3639    public int countByCompanyId(long companyId) throws SystemException {
3640        Object[] finderArgs = new Object[] { new Long(companyId) };
3641
3642        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3643                finderArgs, this);
3644
3645        if (count == null) {
3646            Session session = null;
3647
3648            try {
3649                session = openSession();
3650
3651                StringBundler query = new StringBundler(2);
3652
3653                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3654
3655                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3656
3657                String sql = query.toString();
3658
3659                Query q = session.createQuery(sql);
3660
3661                QueryPos qPos = QueryPos.getInstance(q);
3662
3663                qPos.add(companyId);
3664
3665                count = (Long)q.uniqueResult();
3666            }
3667            catch (Exception e) {
3668                throw processException(e);
3669            }
3670            finally {
3671                if (count == null) {
3672                    count = Long.valueOf(0);
3673                }
3674
3675                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3676                    finderArgs, count);
3677
3678                closeSession(session);
3679            }
3680        }
3681
3682        return count.intValue();
3683    }
3684
3685    public int countBySmallImageId(long smallImageId) throws SystemException {
3686        Object[] finderArgs = new Object[] { new Long(smallImageId) };
3687
3688        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
3689                finderArgs, this);
3690
3691        if (count == null) {
3692            Session session = null;
3693
3694            try {
3695                session = openSession();
3696
3697                StringBundler query = new StringBundler(2);
3698
3699                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3700
3701                query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
3702
3703                String sql = query.toString();
3704
3705                Query q = session.createQuery(sql);
3706
3707                QueryPos qPos = QueryPos.getInstance(q);
3708
3709                qPos.add(smallImageId);
3710
3711                count = (Long)q.uniqueResult();
3712            }
3713            catch (Exception e) {
3714                throw processException(e);
3715            }
3716            finally {
3717                if (count == null) {
3718                    count = Long.valueOf(0);
3719                }
3720
3721                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
3722                    finderArgs, count);
3723
3724                closeSession(session);
3725            }
3726        }
3727
3728        return count.intValue();
3729    }
3730
3731    public int countByR_A(long resourcePrimKey, boolean approved)
3732        throws SystemException {
3733        Object[] finderArgs = new Object[] {
3734                new Long(resourcePrimKey), Boolean.valueOf(approved)
3735            };
3736
3737        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_A,
3738                finderArgs, this);
3739
3740        if (count == null) {
3741            Session session = null;
3742
3743            try {
3744                session = openSession();
3745
3746                StringBundler query = new StringBundler(3);
3747
3748                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3749
3750                query.append(_FINDER_COLUMN_R_A_RESOURCEPRIMKEY_2);
3751
3752                query.append(_FINDER_COLUMN_R_A_APPROVED_2);
3753
3754                String sql = query.toString();
3755
3756                Query q = session.createQuery(sql);
3757
3758                QueryPos qPos = QueryPos.getInstance(q);
3759
3760                qPos.add(resourcePrimKey);
3761
3762                qPos.add(approved);
3763
3764                count = (Long)q.uniqueResult();
3765            }
3766            catch (Exception e) {
3767                throw processException(e);
3768            }
3769            finally {
3770                if (count == null) {
3771                    count = Long.valueOf(0);
3772                }
3773
3774                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_A, finderArgs,
3775                    count);
3776
3777                closeSession(session);
3778            }
3779        }
3780
3781        return count.intValue();
3782    }
3783
3784    public int countByG_A(long groupId, String articleId)
3785        throws SystemException {
3786        Object[] finderArgs = new Object[] { new Long(groupId), articleId };
3787
3788        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
3789                finderArgs, this);
3790
3791        if (count == null) {
3792            Session session = null;
3793
3794            try {
3795                session = openSession();
3796
3797                StringBundler query = new StringBundler(3);
3798
3799                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3800
3801                query.append(_FINDER_COLUMN_G_A_GROUPID_2);
3802
3803                if (articleId == null) {
3804                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
3805                }
3806                else {
3807                    if (articleId.equals(StringPool.BLANK)) {
3808                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
3809                    }
3810                    else {
3811                        query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
3812                    }
3813                }
3814
3815                String sql = query.toString();
3816
3817                Query q = session.createQuery(sql);
3818
3819                QueryPos qPos = QueryPos.getInstance(q);
3820
3821                qPos.add(groupId);
3822
3823                if (articleId != null) {
3824                    qPos.add(articleId);
3825                }
3826
3827                count = (Long)q.uniqueResult();
3828            }
3829            catch (Exception e) {
3830                throw processException(e);
3831            }
3832            finally {
3833                if (count == null) {
3834                    count = Long.valueOf(0);
3835                }
3836
3837                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
3838                    count);
3839
3840                closeSession(session);
3841            }
3842        }
3843
3844        return count.intValue();
3845    }
3846
3847    public int countByG_S(long groupId, String structureId)
3848        throws SystemException {
3849        Object[] finderArgs = new Object[] { new Long(groupId), structureId };
3850
3851        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
3852                finderArgs, this);
3853
3854        if (count == null) {
3855            Session session = null;
3856
3857            try {
3858                session = openSession();
3859
3860                StringBundler query = new StringBundler(3);
3861
3862                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3863
3864                query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3865
3866                if (structureId == null) {
3867                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
3868                }
3869                else {
3870                    if (structureId.equals(StringPool.BLANK)) {
3871                        query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
3872                    }
3873                    else {
3874                        query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
3875                    }
3876                }
3877
3878                String sql = query.toString();
3879
3880                Query q = session.createQuery(sql);
3881
3882                QueryPos qPos = QueryPos.getInstance(q);
3883
3884                qPos.add(groupId);
3885
3886                if (structureId != null) {
3887                    qPos.add(structureId);
3888                }
3889
3890                count = (Long)q.uniqueResult();
3891            }
3892            catch (Exception e) {
3893                throw processException(e);
3894            }
3895            finally {
3896                if (count == null) {
3897                    count = Long.valueOf(0);
3898                }
3899
3900                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
3901                    count);
3902
3903                closeSession(session);
3904            }
3905        }
3906
3907        return count.intValue();
3908    }
3909
3910    public int countByG_T(long groupId, String templateId)
3911        throws SystemException {
3912        Object[] finderArgs = new Object[] { new Long(groupId), templateId };
3913
3914        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
3915                finderArgs, this);
3916
3917        if (count == null) {
3918            Session session = null;
3919
3920            try {
3921                session = openSession();
3922
3923                StringBundler query = new StringBundler(3);
3924
3925                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3926
3927                query.append(_FINDER_COLUMN_G_T_GROUPID_2);
3928
3929                if (templateId == null) {
3930                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
3931                }
3932                else {
3933                    if (templateId.equals(StringPool.BLANK)) {
3934                        query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
3935                    }
3936                    else {
3937                        query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
3938                    }
3939                }
3940
3941                String sql = query.toString();
3942
3943                Query q = session.createQuery(sql);
3944
3945                QueryPos qPos = QueryPos.getInstance(q);
3946
3947                qPos.add(groupId);
3948
3949                if (templateId != null) {
3950                    qPos.add(templateId);
3951                }
3952
3953                count = (Long)q.uniqueResult();
3954            }
3955            catch (Exception e) {
3956                throw processException(e);
3957            }
3958            finally {
3959                if (count == null) {
3960                    count = Long.valueOf(0);
3961                }
3962
3963                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
3964                    count);
3965
3966                closeSession(session);
3967            }
3968        }
3969
3970        return count.intValue();
3971    }
3972
3973    public int countByG_A_V(long groupId, String articleId, double version)
3974        throws SystemException {
3975        Object[] finderArgs = new Object[] {
3976                new Long(groupId),
3977                
3978                articleId, new Double(version)
3979            };
3980
3981        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
3982                finderArgs, this);
3983
3984        if (count == null) {
3985            Session session = null;
3986
3987            try {
3988                session = openSession();
3989
3990                StringBundler query = new StringBundler(4);
3991
3992                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3993
3994                query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
3995
3996                if (articleId == null) {
3997                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
3998                }
3999                else {
4000                    if (articleId.equals(StringPool.BLANK)) {
4001                        query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
4002                    }
4003                    else {
4004                        query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
4005                    }
4006                }
4007
4008                query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
4009
4010                String sql = query.toString();
4011
4012                Query q = session.createQuery(sql);
4013
4014                QueryPos qPos = QueryPos.getInstance(q);
4015
4016                qPos.add(groupId);
4017
4018                if (articleId != null) {
4019                    qPos.add(articleId);
4020                }
4021
4022                qPos.add(version);
4023
4024                count = (Long)q.uniqueResult();
4025            }
4026            catch (Exception e) {
4027                throw processException(e);
4028            }
4029            finally {
4030                if (count == null) {
4031                    count = Long.valueOf(0);
4032                }
4033
4034                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
4035                    finderArgs, count);
4036
4037                closeSession(session);
4038            }
4039        }
4040
4041        return count.intValue();
4042    }
4043
4044    public int countByG_A_A(long groupId, String articleId, boolean approved)
4045        throws SystemException {
4046        Object[] finderArgs = new Object[] {
4047                new Long(groupId),
4048                
4049                articleId, Boolean.valueOf(approved)
4050            };
4051
4052        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_A,
4053                finderArgs, this);
4054
4055        if (count == null) {
4056            Session session = null;
4057
4058            try {
4059                session = openSession();
4060
4061                StringBundler query = new StringBundler(4);
4062
4063                query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4064
4065                query.append(_FINDER_COLUMN_G_A_A_GROUPID_2);
4066
4067                if (articleId == null) {
4068                    query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_1);
4069                }
4070                else {
4071                    if (articleId.equals(StringPool.BLANK)) {
4072                        query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_3);
4073                    }
4074                    else {
4075                        query.append(_FINDER_COLUMN_G_A_A_ARTICLEID_2);
4076                    }
4077                }
4078
4079                query.append(_FINDER_COLUMN_G_A_A_APPROVED_2);
4080
4081                String sql = query.toString();
4082
4083                Query q = session.createQuery(sql);
4084
4085                QueryPos qPos = QueryPos.getInstance(q);
4086
4087                qPos.add(groupId);
4088
4089                if (articleId != null) {
4090                    qPos.add(articleId);
4091                }
4092
4093                qPos.add(approved);
4094
4095                count = (Long)q.uniqueResult();
4096            }
4097            catch (Exception e) {
4098                throw processException(e);
4099            }
4100            finally {
4101                if (count == null) {
4102                    count = Long.valueOf(0);
4103                }
4104
4105                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_A,
4106                    finderArgs, count);
4107
4108                closeSession(session);
4109            }
4110        }
4111
4112        return count.intValue();
4113    }
4114
4115    public int countAll() throws SystemException {
4116        Object[] finderArgs = new Object[0];
4117
4118        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4119                finderArgs, this);
4120
4121        if (count == null) {
4122            Session session = null;
4123
4124            try {
4125                session = openSession();
4126
4127                Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
4128
4129                count = (Long)q.uniqueResult();
4130            }
4131            catch (Exception e) {
4132                throw processException(e);
4133            }
4134            finally {
4135                if (count == null) {
4136                    count = Long.valueOf(0);
4137                }
4138
4139                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4140                    count);
4141
4142                closeSession(session);
4143            }
4144        }
4145
4146        return count.intValue();
4147    }
4148
4149    public void afterPropertiesSet() {
4150        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4151                    com.liferay.portal.util.PropsUtil.get(
4152                        "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
4153
4154        if (listenerClassNames.length > 0) {
4155            try {
4156                List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
4157
4158                for (String listenerClassName : listenerClassNames) {
4159                    listenersList.add((ModelListener<JournalArticle>)Class.forName(
4160                            listenerClassName).newInstance());
4161                }
4162
4163                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4164            }
4165            catch (Exception e) {
4166                _log.error(e);
4167            }
4168        }
4169    }
4170
4171    @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence")
4172    protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
4173    @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence")
4174    protected com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence journalArticleImagePersistence;
4175    @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence")
4176    protected com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence journalArticleResourcePersistence;
4177    @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence")
4178    protected com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence journalContentSearchPersistence;
4179    @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalFeedPersistence")
4180    protected com.liferay.portlet.journal.service.persistence.JournalFeedPersistence journalFeedPersistence;
4181    @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalStructurePersistence")
4182    protected com.liferay.portlet.journal.service.persistence.JournalStructurePersistence journalStructurePersistence;
4183    @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence")
4184    protected com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence journalTemplatePersistence;
4185    @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
4186    protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
4187    @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
4188    protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
4189    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
4190    protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
4191    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
4192    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
4193    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
4194    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
4195    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence")
4196    protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
4197    @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence")
4198    protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
4199    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence")
4200    protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
4201    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence")
4202    protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
4203    private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
4204    private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
4205    private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
4206    private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
4207    private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
4208    private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
4209    private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
4210    private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
4211    private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
4212    private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
4213    private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
4214    private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
4215    private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
4216    private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
4217    private static final String _FINDER_COLUMN_R_A_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
4218    private static final String _FINDER_COLUMN_R_A_APPROVED_2 = "journalArticle.approved = ?";
4219    private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
4220    private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
4221    private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
4222    private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
4223    private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
4224    private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
4225    private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
4226    private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
4227    private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
4228    private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4229    private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
4230    private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
4231    private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
4232    private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
4233    private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
4234    private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
4235    private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
4236    private static final String _FINDER_COLUMN_G_A_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
4237    private static final String _FINDER_COLUMN_G_A_A_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
4238    private static final String _FINDER_COLUMN_G_A_A_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
4239    private static final String _FINDER_COLUMN_G_A_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
4240    private static final String _FINDER_COLUMN_G_A_A_APPROVED_2 = "journalArticle.approved = ?";
4241    private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
4242    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
4243    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
4244    private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
4245}