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