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