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