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