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