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