001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.service.persistence.BatchSessionUtil;
040 import com.liferay.portal.service.persistence.ImagePersistence;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.journal.NoSuchArticleImageException;
046 import com.liferay.portlet.journal.model.JournalArticleImage;
047 import com.liferay.portlet.journal.model.impl.JournalArticleImageImpl;
048 import com.liferay.portlet.journal.model.impl.JournalArticleImageModelImpl;
049
050 import java.io.Serializable;
051
052 import java.util.ArrayList;
053 import java.util.Collections;
054 import java.util.List;
055
056
068 public class JournalArticleImagePersistenceImpl extends BasePersistenceImpl<JournalArticleImage>
069 implements JournalArticleImagePersistence {
070
075 public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImageImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List1";
078 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List2";
080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
081 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
082 JournalArticleImageImpl.class,
083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
084 new String[] {
085 Long.class.getName(),
086
087 "java.lang.Integer", "java.lang.Integer",
088 "com.liferay.portal.kernel.util.OrderByComparator"
089 });
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
091 new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
092 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
093 JournalArticleImageImpl.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
095 new String[] { Long.class.getName() },
096 JournalArticleImageModelImpl.GROUPID_COLUMN_BITMASK);
097 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
098 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED, Long.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
100 new String[] { Long.class.getName() });
101 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPIMAGE =
102 new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
103 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
104 JournalArticleImageImpl.class,
105 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByTempImage",
106 new String[] {
107 Boolean.class.getName(),
108
109 "java.lang.Integer", "java.lang.Integer",
110 "com.liferay.portal.kernel.util.OrderByComparator"
111 });
112 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPIMAGE =
113 new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
114 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
115 JournalArticleImageImpl.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTempImage",
117 new String[] { Boolean.class.getName() },
118 JournalArticleImageModelImpl.TEMPIMAGE_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_TEMPIMAGE = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
120 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTempImage",
122 new String[] { Boolean.class.getName() });
123 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_V = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
124 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
125 JournalArticleImageImpl.class,
126 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_A_V",
127 new String[] {
128 Long.class.getName(), String.class.getName(),
129 Double.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_WITHOUT_PAGINATION_FIND_BY_G_A_V = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
135 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
136 JournalArticleImageImpl.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_V",
138 new String[] {
139 Long.class.getName(), String.class.getName(),
140 Double.class.getName()
141 },
142 JournalArticleImageModelImpl.GROUPID_COLUMN_BITMASK |
143 JournalArticleImageModelImpl.ARTICLEID_COLUMN_BITMASK |
144 JournalArticleImageModelImpl.VERSION_COLUMN_BITMASK);
145 public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
146 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED, Long.class,
147 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
148 new String[] {
149 Long.class.getName(), String.class.getName(),
150 Double.class.getName()
151 });
152 public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V_E_E_L = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
153 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
154 JournalArticleImageImpl.class, FINDER_CLASS_NAME_ENTITY,
155 "fetchByG_A_V_E_E_L",
156 new String[] {
157 Long.class.getName(), String.class.getName(),
158 Double.class.getName(), String.class.getName(),
159 String.class.getName(), String.class.getName()
160 },
161 JournalArticleImageModelImpl.GROUPID_COLUMN_BITMASK |
162 JournalArticleImageModelImpl.ARTICLEID_COLUMN_BITMASK |
163 JournalArticleImageModelImpl.VERSION_COLUMN_BITMASK |
164 JournalArticleImageModelImpl.ELINSTANCEID_COLUMN_BITMASK |
165 JournalArticleImageModelImpl.ELNAME_COLUMN_BITMASK |
166 JournalArticleImageModelImpl.LANGUAGEID_COLUMN_BITMASK);
167 public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V_E_E_L = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
168 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED, Long.class,
169 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V_E_E_L",
170 new String[] {
171 Long.class.getName(), String.class.getName(),
172 Double.class.getName(), String.class.getName(),
173 String.class.getName(), String.class.getName()
174 });
175 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
176 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
177 JournalArticleImageImpl.class,
178 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
179 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
180 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED,
181 JournalArticleImageImpl.class,
182 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
183 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
184 JournalArticleImageModelImpl.FINDER_CACHE_ENABLED, Long.class,
185 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
186
187
192 public void cacheResult(JournalArticleImage journalArticleImage) {
193 EntityCacheUtil.putResult(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
194 JournalArticleImageImpl.class, journalArticleImage.getPrimaryKey(),
195 journalArticleImage);
196
197 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L,
198 new Object[] {
199 Long.valueOf(journalArticleImage.getGroupId()),
200
201 journalArticleImage.getArticleId(),
202 Double.valueOf(journalArticleImage.getVersion()),
203
204 journalArticleImage.getElInstanceId(),
205
206 journalArticleImage.getElName(),
207
208 journalArticleImage.getLanguageId()
209 }, journalArticleImage);
210
211 journalArticleImage.resetOriginalValues();
212 }
213
214
219 public void cacheResult(List<JournalArticleImage> journalArticleImages) {
220 for (JournalArticleImage journalArticleImage : journalArticleImages) {
221 if (EntityCacheUtil.getResult(
222 JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
223 JournalArticleImageImpl.class,
224 journalArticleImage.getPrimaryKey()) == null) {
225 cacheResult(journalArticleImage);
226 }
227 else {
228 journalArticleImage.resetOriginalValues();
229 }
230 }
231 }
232
233
240 @Override
241 public void clearCache() {
242 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
243 CacheRegistryUtil.clear(JournalArticleImageImpl.class.getName());
244 }
245
246 EntityCacheUtil.clearCache(JournalArticleImageImpl.class.getName());
247
248 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
249 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
250 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
251 }
252
253
260 @Override
261 public void clearCache(JournalArticleImage journalArticleImage) {
262 EntityCacheUtil.removeResult(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
263 JournalArticleImageImpl.class, journalArticleImage.getPrimaryKey());
264
265 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
266 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
267
268 clearUniqueFindersCache(journalArticleImage);
269 }
270
271 @Override
272 public void clearCache(List<JournalArticleImage> journalArticleImages) {
273 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
274 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
275
276 for (JournalArticleImage journalArticleImage : journalArticleImages) {
277 EntityCacheUtil.removeResult(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
278 JournalArticleImageImpl.class,
279 journalArticleImage.getPrimaryKey());
280
281 clearUniqueFindersCache(journalArticleImage);
282 }
283 }
284
285 protected void cacheUniqueFindersCache(
286 JournalArticleImage journalArticleImage) {
287 if (journalArticleImage.isNew()) {
288 Object[] args = new Object[] {
289 Long.valueOf(journalArticleImage.getGroupId()),
290
291 journalArticleImage.getArticleId(),
292 Double.valueOf(journalArticleImage.getVersion()),
293
294 journalArticleImage.getElInstanceId(),
295
296 journalArticleImage.getElName(),
297
298 journalArticleImage.getLanguageId()
299 };
300
301 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V_E_E_L, args,
302 Long.valueOf(1));
303 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L, args,
304 journalArticleImage);
305 }
306 else {
307 JournalArticleImageModelImpl journalArticleImageModelImpl = (JournalArticleImageModelImpl)journalArticleImage;
308
309 if ((journalArticleImageModelImpl.getColumnBitmask() &
310 FINDER_PATH_FETCH_BY_G_A_V_E_E_L.getColumnBitmask()) != 0) {
311 Object[] args = new Object[] {
312 Long.valueOf(journalArticleImage.getGroupId()),
313
314 journalArticleImage.getArticleId(),
315 Double.valueOf(journalArticleImage.getVersion()),
316
317 journalArticleImage.getElInstanceId(),
318
319 journalArticleImage.getElName(),
320
321 journalArticleImage.getLanguageId()
322 };
323
324 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V_E_E_L,
325 args, Long.valueOf(1));
326 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L,
327 args, journalArticleImage);
328 }
329 }
330 }
331
332 protected void clearUniqueFindersCache(
333 JournalArticleImage journalArticleImage) {
334 JournalArticleImageModelImpl journalArticleImageModelImpl = (JournalArticleImageModelImpl)journalArticleImage;
335
336 Object[] args = new Object[] {
337 Long.valueOf(journalArticleImage.getGroupId()),
338
339 journalArticleImage.getArticleId(),
340 Double.valueOf(journalArticleImage.getVersion()),
341
342 journalArticleImage.getElInstanceId(),
343
344 journalArticleImage.getElName(),
345
346 journalArticleImage.getLanguageId()
347 };
348
349 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V_E_E_L, args);
350 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L, args);
351
352 if ((journalArticleImageModelImpl.getColumnBitmask() &
353 FINDER_PATH_FETCH_BY_G_A_V_E_E_L.getColumnBitmask()) != 0) {
354 args = new Object[] {
355 Long.valueOf(journalArticleImageModelImpl.getOriginalGroupId()),
356
357 journalArticleImageModelImpl.getOriginalArticleId(),
358 Double.valueOf(journalArticleImageModelImpl.getOriginalVersion()),
359
360 journalArticleImageModelImpl.getOriginalElInstanceId(),
361
362 journalArticleImageModelImpl.getOriginalElName(),
363
364 journalArticleImageModelImpl.getOriginalLanguageId()
365 };
366
367 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V_E_E_L, args);
368 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L, args);
369 }
370 }
371
372
378 public JournalArticleImage create(long articleImageId) {
379 JournalArticleImage journalArticleImage = new JournalArticleImageImpl();
380
381 journalArticleImage.setNew(true);
382 journalArticleImage.setPrimaryKey(articleImageId);
383
384 return journalArticleImage;
385 }
386
387
395 public JournalArticleImage remove(long articleImageId)
396 throws NoSuchArticleImageException, SystemException {
397 return remove(Long.valueOf(articleImageId));
398 }
399
400
408 @Override
409 public JournalArticleImage remove(Serializable primaryKey)
410 throws NoSuchArticleImageException, SystemException {
411 Session session = null;
412
413 try {
414 session = openSession();
415
416 JournalArticleImage journalArticleImage = (JournalArticleImage)session.get(JournalArticleImageImpl.class,
417 primaryKey);
418
419 if (journalArticleImage == null) {
420 if (_log.isWarnEnabled()) {
421 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
422 }
423
424 throw new NoSuchArticleImageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
425 primaryKey);
426 }
427
428 return remove(journalArticleImage);
429 }
430 catch (NoSuchArticleImageException nsee) {
431 throw nsee;
432 }
433 catch (Exception e) {
434 throw processException(e);
435 }
436 finally {
437 closeSession(session);
438 }
439 }
440
441 @Override
442 protected JournalArticleImage removeImpl(
443 JournalArticleImage journalArticleImage) throws SystemException {
444 journalArticleImage = toUnwrappedModel(journalArticleImage);
445
446 Session session = null;
447
448 try {
449 session = openSession();
450
451 BatchSessionUtil.delete(session, journalArticleImage);
452 }
453 catch (Exception e) {
454 throw processException(e);
455 }
456 finally {
457 closeSession(session);
458 }
459
460 clearCache(journalArticleImage);
461
462 return journalArticleImage;
463 }
464
465 @Override
466 public JournalArticleImage updateImpl(
467 com.liferay.portlet.journal.model.JournalArticleImage journalArticleImage,
468 boolean merge) throws SystemException {
469 journalArticleImage = toUnwrappedModel(journalArticleImage);
470
471 boolean isNew = journalArticleImage.isNew();
472
473 JournalArticleImageModelImpl journalArticleImageModelImpl = (JournalArticleImageModelImpl)journalArticleImage;
474
475 Session session = null;
476
477 try {
478 session = openSession();
479
480 BatchSessionUtil.update(session, journalArticleImage, merge);
481
482 journalArticleImage.setNew(false);
483 }
484 catch (Exception e) {
485 throw processException(e);
486 }
487 finally {
488 closeSession(session);
489 }
490
491 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
492
493 if (isNew || !JournalArticleImageModelImpl.COLUMN_BITMASK_ENABLED) {
494 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
495 }
496
497 else {
498 if ((journalArticleImageModelImpl.getColumnBitmask() &
499 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
500 Object[] args = new Object[] {
501 Long.valueOf(journalArticleImageModelImpl.getOriginalGroupId())
502 };
503
504 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
505 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
506 args);
507
508 args = new Object[] {
509 Long.valueOf(journalArticleImageModelImpl.getGroupId())
510 };
511
512 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
513 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
514 args);
515 }
516
517 if ((journalArticleImageModelImpl.getColumnBitmask() &
518 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPIMAGE.getColumnBitmask()) != 0) {
519 Object[] args = new Object[] {
520 Boolean.valueOf(journalArticleImageModelImpl.getOriginalTempImage())
521 };
522
523 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPIMAGE,
524 args);
525 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPIMAGE,
526 args);
527
528 args = new Object[] {
529 Boolean.valueOf(journalArticleImageModelImpl.getTempImage())
530 };
531
532 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPIMAGE,
533 args);
534 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPIMAGE,
535 args);
536 }
537
538 if ((journalArticleImageModelImpl.getColumnBitmask() &
539 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_V.getColumnBitmask()) != 0) {
540 Object[] args = new Object[] {
541 Long.valueOf(journalArticleImageModelImpl.getOriginalGroupId()),
542
543 journalArticleImageModelImpl.getOriginalArticleId(),
544 Double.valueOf(journalArticleImageModelImpl.getOriginalVersion())
545 };
546
547 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
548 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_V,
549 args);
550
551 args = new Object[] {
552 Long.valueOf(journalArticleImageModelImpl.getGroupId()),
553
554 journalArticleImageModelImpl.getArticleId(),
555 Double.valueOf(journalArticleImageModelImpl.getVersion())
556 };
557
558 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
559 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_V,
560 args);
561 }
562 }
563
564 EntityCacheUtil.putResult(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
565 JournalArticleImageImpl.class, journalArticleImage.getPrimaryKey(),
566 journalArticleImage);
567
568 clearUniqueFindersCache(journalArticleImage);
569 cacheUniqueFindersCache(journalArticleImage);
570
571 return journalArticleImage;
572 }
573
574 protected JournalArticleImage toUnwrappedModel(
575 JournalArticleImage journalArticleImage) {
576 if (journalArticleImage instanceof JournalArticleImageImpl) {
577 return journalArticleImage;
578 }
579
580 JournalArticleImageImpl journalArticleImageImpl = new JournalArticleImageImpl();
581
582 journalArticleImageImpl.setNew(journalArticleImage.isNew());
583 journalArticleImageImpl.setPrimaryKey(journalArticleImage.getPrimaryKey());
584
585 journalArticleImageImpl.setArticleImageId(journalArticleImage.getArticleImageId());
586 journalArticleImageImpl.setGroupId(journalArticleImage.getGroupId());
587 journalArticleImageImpl.setArticleId(journalArticleImage.getArticleId());
588 journalArticleImageImpl.setVersion(journalArticleImage.getVersion());
589 journalArticleImageImpl.setElInstanceId(journalArticleImage.getElInstanceId());
590 journalArticleImageImpl.setElName(journalArticleImage.getElName());
591 journalArticleImageImpl.setLanguageId(journalArticleImage.getLanguageId());
592 journalArticleImageImpl.setTempImage(journalArticleImage.isTempImage());
593
594 return journalArticleImageImpl;
595 }
596
597
605 @Override
606 public JournalArticleImage findByPrimaryKey(Serializable primaryKey)
607 throws NoSuchModelException, SystemException {
608 return findByPrimaryKey(((Long)primaryKey).longValue());
609 }
610
611
619 public JournalArticleImage findByPrimaryKey(long articleImageId)
620 throws NoSuchArticleImageException, SystemException {
621 JournalArticleImage journalArticleImage = fetchByPrimaryKey(articleImageId);
622
623 if (journalArticleImage == null) {
624 if (_log.isWarnEnabled()) {
625 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + articleImageId);
626 }
627
628 throw new NoSuchArticleImageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
629 articleImageId);
630 }
631
632 return journalArticleImage;
633 }
634
635
642 @Override
643 public JournalArticleImage fetchByPrimaryKey(Serializable primaryKey)
644 throws SystemException {
645 return fetchByPrimaryKey(((Long)primaryKey).longValue());
646 }
647
648
655 public JournalArticleImage fetchByPrimaryKey(long articleImageId)
656 throws SystemException {
657 JournalArticleImage journalArticleImage = (JournalArticleImage)EntityCacheUtil.getResult(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
658 JournalArticleImageImpl.class, articleImageId);
659
660 if (journalArticleImage == _nullJournalArticleImage) {
661 return null;
662 }
663
664 if (journalArticleImage == null) {
665 Session session = null;
666
667 boolean hasException = false;
668
669 try {
670 session = openSession();
671
672 journalArticleImage = (JournalArticleImage)session.get(JournalArticleImageImpl.class,
673 Long.valueOf(articleImageId));
674 }
675 catch (Exception e) {
676 hasException = true;
677
678 throw processException(e);
679 }
680 finally {
681 if (journalArticleImage != null) {
682 cacheResult(journalArticleImage);
683 }
684 else if (!hasException) {
685 EntityCacheUtil.putResult(JournalArticleImageModelImpl.ENTITY_CACHE_ENABLED,
686 JournalArticleImageImpl.class, articleImageId,
687 _nullJournalArticleImage);
688 }
689
690 closeSession(session);
691 }
692 }
693
694 return journalArticleImage;
695 }
696
697
704 public List<JournalArticleImage> findByGroupId(long groupId)
705 throws SystemException {
706 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
707 }
708
709
722 public List<JournalArticleImage> findByGroupId(long groupId, int start,
723 int end) throws SystemException {
724 return findByGroupId(groupId, start, end, null);
725 }
726
727
741 public List<JournalArticleImage> findByGroupId(long groupId, int start,
742 int end, OrderByComparator orderByComparator) throws SystemException {
743 FinderPath finderPath = null;
744 Object[] finderArgs = null;
745
746 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
747 (orderByComparator == null)) {
748 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
749 finderArgs = new Object[] { groupId };
750 }
751 else {
752 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
753 finderArgs = new Object[] { groupId, start, end, orderByComparator };
754 }
755
756 List<JournalArticleImage> list = (List<JournalArticleImage>)FinderCacheUtil.getResult(finderPath,
757 finderArgs, this);
758
759 if ((list != null) && !list.isEmpty()) {
760 for (JournalArticleImage journalArticleImage : list) {
761 if ((groupId != journalArticleImage.getGroupId())) {
762 list = null;
763
764 break;
765 }
766 }
767 }
768
769 if (list == null) {
770 StringBundler query = null;
771
772 if (orderByComparator != null) {
773 query = new StringBundler(3 +
774 (orderByComparator.getOrderByFields().length * 3));
775 }
776 else {
777 query = new StringBundler(2);
778 }
779
780 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE_WHERE);
781
782 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
783
784 if (orderByComparator != null) {
785 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
786 orderByComparator);
787 }
788
789 String sql = query.toString();
790
791 Session session = null;
792
793 try {
794 session = openSession();
795
796 Query q = session.createQuery(sql);
797
798 QueryPos qPos = QueryPos.getInstance(q);
799
800 qPos.add(groupId);
801
802 list = (List<JournalArticleImage>)QueryUtil.list(q,
803 getDialect(), start, end);
804 }
805 catch (Exception e) {
806 throw processException(e);
807 }
808 finally {
809 if (list == null) {
810 FinderCacheUtil.removeResult(finderPath, finderArgs);
811 }
812 else {
813 cacheResult(list);
814
815 FinderCacheUtil.putResult(finderPath, finderArgs, list);
816 }
817
818 closeSession(session);
819 }
820 }
821
822 return list;
823 }
824
825
834 public JournalArticleImage findByGroupId_First(long groupId,
835 OrderByComparator orderByComparator)
836 throws NoSuchArticleImageException, SystemException {
837 JournalArticleImage journalArticleImage = fetchByGroupId_First(groupId,
838 orderByComparator);
839
840 if (journalArticleImage != null) {
841 return journalArticleImage;
842 }
843
844 StringBundler msg = new StringBundler(4);
845
846 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
847
848 msg.append("groupId=");
849 msg.append(groupId);
850
851 msg.append(StringPool.CLOSE_CURLY_BRACE);
852
853 throw new NoSuchArticleImageException(msg.toString());
854 }
855
856
864 public JournalArticleImage fetchByGroupId_First(long groupId,
865 OrderByComparator orderByComparator) throws SystemException {
866 List<JournalArticleImage> list = findByGroupId(groupId, 0, 1,
867 orderByComparator);
868
869 if (!list.isEmpty()) {
870 return list.get(0);
871 }
872
873 return null;
874 }
875
876
885 public JournalArticleImage findByGroupId_Last(long groupId,
886 OrderByComparator orderByComparator)
887 throws NoSuchArticleImageException, SystemException {
888 JournalArticleImage journalArticleImage = fetchByGroupId_Last(groupId,
889 orderByComparator);
890
891 if (journalArticleImage != null) {
892 return journalArticleImage;
893 }
894
895 StringBundler msg = new StringBundler(4);
896
897 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
898
899 msg.append("groupId=");
900 msg.append(groupId);
901
902 msg.append(StringPool.CLOSE_CURLY_BRACE);
903
904 throw new NoSuchArticleImageException(msg.toString());
905 }
906
907
915 public JournalArticleImage fetchByGroupId_Last(long groupId,
916 OrderByComparator orderByComparator) throws SystemException {
917 int count = countByGroupId(groupId);
918
919 List<JournalArticleImage> list = findByGroupId(groupId, count - 1,
920 count, orderByComparator);
921
922 if (!list.isEmpty()) {
923 return list.get(0);
924 }
925
926 return null;
927 }
928
929
939 public JournalArticleImage[] findByGroupId_PrevAndNext(
940 long articleImageId, long groupId, OrderByComparator orderByComparator)
941 throws NoSuchArticleImageException, SystemException {
942 JournalArticleImage journalArticleImage = findByPrimaryKey(articleImageId);
943
944 Session session = null;
945
946 try {
947 session = openSession();
948
949 JournalArticleImage[] array = new JournalArticleImageImpl[3];
950
951 array[0] = getByGroupId_PrevAndNext(session, journalArticleImage,
952 groupId, orderByComparator, true);
953
954 array[1] = journalArticleImage;
955
956 array[2] = getByGroupId_PrevAndNext(session, journalArticleImage,
957 groupId, orderByComparator, false);
958
959 return array;
960 }
961 catch (Exception e) {
962 throw processException(e);
963 }
964 finally {
965 closeSession(session);
966 }
967 }
968
969 protected JournalArticleImage getByGroupId_PrevAndNext(Session session,
970 JournalArticleImage journalArticleImage, long groupId,
971 OrderByComparator orderByComparator, boolean previous) {
972 StringBundler query = null;
973
974 if (orderByComparator != null) {
975 query = new StringBundler(6 +
976 (orderByComparator.getOrderByFields().length * 6));
977 }
978 else {
979 query = new StringBundler(3);
980 }
981
982 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE_WHERE);
983
984 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
985
986 if (orderByComparator != null) {
987 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
988
989 if (orderByConditionFields.length > 0) {
990 query.append(WHERE_AND);
991 }
992
993 for (int i = 0; i < orderByConditionFields.length; i++) {
994 query.append(_ORDER_BY_ENTITY_ALIAS);
995 query.append(orderByConditionFields[i]);
996
997 if ((i + 1) < orderByConditionFields.length) {
998 if (orderByComparator.isAscending() ^ previous) {
999 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1000 }
1001 else {
1002 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1003 }
1004 }
1005 else {
1006 if (orderByComparator.isAscending() ^ previous) {
1007 query.append(WHERE_GREATER_THAN);
1008 }
1009 else {
1010 query.append(WHERE_LESSER_THAN);
1011 }
1012 }
1013 }
1014
1015 query.append(ORDER_BY_CLAUSE);
1016
1017 String[] orderByFields = orderByComparator.getOrderByFields();
1018
1019 for (int i = 0; i < orderByFields.length; i++) {
1020 query.append(_ORDER_BY_ENTITY_ALIAS);
1021 query.append(orderByFields[i]);
1022
1023 if ((i + 1) < orderByFields.length) {
1024 if (orderByComparator.isAscending() ^ previous) {
1025 query.append(ORDER_BY_ASC_HAS_NEXT);
1026 }
1027 else {
1028 query.append(ORDER_BY_DESC_HAS_NEXT);
1029 }
1030 }
1031 else {
1032 if (orderByComparator.isAscending() ^ previous) {
1033 query.append(ORDER_BY_ASC);
1034 }
1035 else {
1036 query.append(ORDER_BY_DESC);
1037 }
1038 }
1039 }
1040 }
1041
1042 String sql = query.toString();
1043
1044 Query q = session.createQuery(sql);
1045
1046 q.setFirstResult(0);
1047 q.setMaxResults(2);
1048
1049 QueryPos qPos = QueryPos.getInstance(q);
1050
1051 qPos.add(groupId);
1052
1053 if (orderByComparator != null) {
1054 Object[] values = orderByComparator.getOrderByConditionValues(journalArticleImage);
1055
1056 for (Object value : values) {
1057 qPos.add(value);
1058 }
1059 }
1060
1061 List<JournalArticleImage> list = q.list();
1062
1063 if (list.size() == 2) {
1064 return list.get(1);
1065 }
1066 else {
1067 return null;
1068 }
1069 }
1070
1071
1078 public List<JournalArticleImage> findByTempImage(boolean tempImage)
1079 throws SystemException {
1080 return findByTempImage(tempImage, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1081 null);
1082 }
1083
1084
1097 public List<JournalArticleImage> findByTempImage(boolean tempImage,
1098 int start, int end) throws SystemException {
1099 return findByTempImage(tempImage, start, end, null);
1100 }
1101
1102
1116 public List<JournalArticleImage> findByTempImage(boolean tempImage,
1117 int start, int end, OrderByComparator orderByComparator)
1118 throws SystemException {
1119 FinderPath finderPath = null;
1120 Object[] finderArgs = null;
1121
1122 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1123 (orderByComparator == null)) {
1124 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPIMAGE;
1125 finderArgs = new Object[] { tempImage };
1126 }
1127 else {
1128 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPIMAGE;
1129 finderArgs = new Object[] { tempImage, start, end, orderByComparator };
1130 }
1131
1132 List<JournalArticleImage> list = (List<JournalArticleImage>)FinderCacheUtil.getResult(finderPath,
1133 finderArgs, this);
1134
1135 if ((list != null) && !list.isEmpty()) {
1136 for (JournalArticleImage journalArticleImage : list) {
1137 if ((tempImage != journalArticleImage.getTempImage())) {
1138 list = null;
1139
1140 break;
1141 }
1142 }
1143 }
1144
1145 if (list == null) {
1146 StringBundler query = null;
1147
1148 if (orderByComparator != null) {
1149 query = new StringBundler(3 +
1150 (orderByComparator.getOrderByFields().length * 3));
1151 }
1152 else {
1153 query = new StringBundler(2);
1154 }
1155
1156 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE_WHERE);
1157
1158 query.append(_FINDER_COLUMN_TEMPIMAGE_TEMPIMAGE_2);
1159
1160 if (orderByComparator != null) {
1161 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1162 orderByComparator);
1163 }
1164
1165 String sql = query.toString();
1166
1167 Session session = null;
1168
1169 try {
1170 session = openSession();
1171
1172 Query q = session.createQuery(sql);
1173
1174 QueryPos qPos = QueryPos.getInstance(q);
1175
1176 qPos.add(tempImage);
1177
1178 list = (List<JournalArticleImage>)QueryUtil.list(q,
1179 getDialect(), start, end);
1180 }
1181 catch (Exception e) {
1182 throw processException(e);
1183 }
1184 finally {
1185 if (list == null) {
1186 FinderCacheUtil.removeResult(finderPath, finderArgs);
1187 }
1188 else {
1189 cacheResult(list);
1190
1191 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1192 }
1193
1194 closeSession(session);
1195 }
1196 }
1197
1198 return list;
1199 }
1200
1201
1210 public JournalArticleImage findByTempImage_First(boolean tempImage,
1211 OrderByComparator orderByComparator)
1212 throws NoSuchArticleImageException, SystemException {
1213 JournalArticleImage journalArticleImage = fetchByTempImage_First(tempImage,
1214 orderByComparator);
1215
1216 if (journalArticleImage != null) {
1217 return journalArticleImage;
1218 }
1219
1220 StringBundler msg = new StringBundler(4);
1221
1222 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1223
1224 msg.append("tempImage=");
1225 msg.append(tempImage);
1226
1227 msg.append(StringPool.CLOSE_CURLY_BRACE);
1228
1229 throw new NoSuchArticleImageException(msg.toString());
1230 }
1231
1232
1240 public JournalArticleImage fetchByTempImage_First(boolean tempImage,
1241 OrderByComparator orderByComparator) throws SystemException {
1242 List<JournalArticleImage> list = findByTempImage(tempImage, 0, 1,
1243 orderByComparator);
1244
1245 if (!list.isEmpty()) {
1246 return list.get(0);
1247 }
1248
1249 return null;
1250 }
1251
1252
1261 public JournalArticleImage findByTempImage_Last(boolean tempImage,
1262 OrderByComparator orderByComparator)
1263 throws NoSuchArticleImageException, SystemException {
1264 JournalArticleImage journalArticleImage = fetchByTempImage_Last(tempImage,
1265 orderByComparator);
1266
1267 if (journalArticleImage != null) {
1268 return journalArticleImage;
1269 }
1270
1271 StringBundler msg = new StringBundler(4);
1272
1273 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1274
1275 msg.append("tempImage=");
1276 msg.append(tempImage);
1277
1278 msg.append(StringPool.CLOSE_CURLY_BRACE);
1279
1280 throw new NoSuchArticleImageException(msg.toString());
1281 }
1282
1283
1291 public JournalArticleImage fetchByTempImage_Last(boolean tempImage,
1292 OrderByComparator orderByComparator) throws SystemException {
1293 int count = countByTempImage(tempImage);
1294
1295 List<JournalArticleImage> list = findByTempImage(tempImage, count - 1,
1296 count, orderByComparator);
1297
1298 if (!list.isEmpty()) {
1299 return list.get(0);
1300 }
1301
1302 return null;
1303 }
1304
1305
1315 public JournalArticleImage[] findByTempImage_PrevAndNext(
1316 long articleImageId, boolean tempImage,
1317 OrderByComparator orderByComparator)
1318 throws NoSuchArticleImageException, SystemException {
1319 JournalArticleImage journalArticleImage = findByPrimaryKey(articleImageId);
1320
1321 Session session = null;
1322
1323 try {
1324 session = openSession();
1325
1326 JournalArticleImage[] array = new JournalArticleImageImpl[3];
1327
1328 array[0] = getByTempImage_PrevAndNext(session, journalArticleImage,
1329 tempImage, orderByComparator, true);
1330
1331 array[1] = journalArticleImage;
1332
1333 array[2] = getByTempImage_PrevAndNext(session, journalArticleImage,
1334 tempImage, orderByComparator, false);
1335
1336 return array;
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 closeSession(session);
1343 }
1344 }
1345
1346 protected JournalArticleImage getByTempImage_PrevAndNext(Session session,
1347 JournalArticleImage journalArticleImage, boolean tempImage,
1348 OrderByComparator orderByComparator, boolean previous) {
1349 StringBundler query = null;
1350
1351 if (orderByComparator != null) {
1352 query = new StringBundler(6 +
1353 (orderByComparator.getOrderByFields().length * 6));
1354 }
1355 else {
1356 query = new StringBundler(3);
1357 }
1358
1359 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE_WHERE);
1360
1361 query.append(_FINDER_COLUMN_TEMPIMAGE_TEMPIMAGE_2);
1362
1363 if (orderByComparator != null) {
1364 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1365
1366 if (orderByConditionFields.length > 0) {
1367 query.append(WHERE_AND);
1368 }
1369
1370 for (int i = 0; i < orderByConditionFields.length; i++) {
1371 query.append(_ORDER_BY_ENTITY_ALIAS);
1372 query.append(orderByConditionFields[i]);
1373
1374 if ((i + 1) < orderByConditionFields.length) {
1375 if (orderByComparator.isAscending() ^ previous) {
1376 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1377 }
1378 else {
1379 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1380 }
1381 }
1382 else {
1383 if (orderByComparator.isAscending() ^ previous) {
1384 query.append(WHERE_GREATER_THAN);
1385 }
1386 else {
1387 query.append(WHERE_LESSER_THAN);
1388 }
1389 }
1390 }
1391
1392 query.append(ORDER_BY_CLAUSE);
1393
1394 String[] orderByFields = orderByComparator.getOrderByFields();
1395
1396 for (int i = 0; i < orderByFields.length; i++) {
1397 query.append(_ORDER_BY_ENTITY_ALIAS);
1398 query.append(orderByFields[i]);
1399
1400 if ((i + 1) < orderByFields.length) {
1401 if (orderByComparator.isAscending() ^ previous) {
1402 query.append(ORDER_BY_ASC_HAS_NEXT);
1403 }
1404 else {
1405 query.append(ORDER_BY_DESC_HAS_NEXT);
1406 }
1407 }
1408 else {
1409 if (orderByComparator.isAscending() ^ previous) {
1410 query.append(ORDER_BY_ASC);
1411 }
1412 else {
1413 query.append(ORDER_BY_DESC);
1414 }
1415 }
1416 }
1417 }
1418
1419 String sql = query.toString();
1420
1421 Query q = session.createQuery(sql);
1422
1423 q.setFirstResult(0);
1424 q.setMaxResults(2);
1425
1426 QueryPos qPos = QueryPos.getInstance(q);
1427
1428 qPos.add(tempImage);
1429
1430 if (orderByComparator != null) {
1431 Object[] values = orderByComparator.getOrderByConditionValues(journalArticleImage);
1432
1433 for (Object value : values) {
1434 qPos.add(value);
1435 }
1436 }
1437
1438 List<JournalArticleImage> list = q.list();
1439
1440 if (list.size() == 2) {
1441 return list.get(1);
1442 }
1443 else {
1444 return null;
1445 }
1446 }
1447
1448
1457 public List<JournalArticleImage> findByG_A_V(long groupId,
1458 String articleId, double version) throws SystemException {
1459 return findByG_A_V(groupId, articleId, version, QueryUtil.ALL_POS,
1460 QueryUtil.ALL_POS, null);
1461 }
1462
1463
1478 public List<JournalArticleImage> findByG_A_V(long groupId,
1479 String articleId, double version, int start, int end)
1480 throws SystemException {
1481 return findByG_A_V(groupId, articleId, version, start, end, null);
1482 }
1483
1484
1500 public List<JournalArticleImage> findByG_A_V(long groupId,
1501 String articleId, double version, int start, int end,
1502 OrderByComparator orderByComparator) throws SystemException {
1503 FinderPath finderPath = null;
1504 Object[] finderArgs = null;
1505
1506 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1507 (orderByComparator == null)) {
1508 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_V;
1509 finderArgs = new Object[] { groupId, articleId, version };
1510 }
1511 else {
1512 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_V;
1513 finderArgs = new Object[] {
1514 groupId, articleId, version,
1515
1516 start, end, orderByComparator
1517 };
1518 }
1519
1520 List<JournalArticleImage> list = (List<JournalArticleImage>)FinderCacheUtil.getResult(finderPath,
1521 finderArgs, this);
1522
1523 if ((list != null) && !list.isEmpty()) {
1524 for (JournalArticleImage journalArticleImage : list) {
1525 if ((groupId != journalArticleImage.getGroupId()) ||
1526 !Validator.equals(articleId,
1527 journalArticleImage.getArticleId()) ||
1528 (version != journalArticleImage.getVersion())) {
1529 list = null;
1530
1531 break;
1532 }
1533 }
1534 }
1535
1536 if (list == null) {
1537 StringBundler query = null;
1538
1539 if (orderByComparator != null) {
1540 query = new StringBundler(5 +
1541 (orderByComparator.getOrderByFields().length * 3));
1542 }
1543 else {
1544 query = new StringBundler(4);
1545 }
1546
1547 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE_WHERE);
1548
1549 query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
1550
1551 if (articleId == null) {
1552 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
1553 }
1554 else {
1555 if (articleId.equals(StringPool.BLANK)) {
1556 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
1557 }
1558 else {
1559 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
1560 }
1561 }
1562
1563 query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
1564
1565 if (orderByComparator != null) {
1566 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1567 orderByComparator);
1568 }
1569
1570 String sql = query.toString();
1571
1572 Session session = null;
1573
1574 try {
1575 session = openSession();
1576
1577 Query q = session.createQuery(sql);
1578
1579 QueryPos qPos = QueryPos.getInstance(q);
1580
1581 qPos.add(groupId);
1582
1583 if (articleId != null) {
1584 qPos.add(articleId);
1585 }
1586
1587 qPos.add(version);
1588
1589 list = (List<JournalArticleImage>)QueryUtil.list(q,
1590 getDialect(), start, end);
1591 }
1592 catch (Exception e) {
1593 throw processException(e);
1594 }
1595 finally {
1596 if (list == null) {
1597 FinderCacheUtil.removeResult(finderPath, finderArgs);
1598 }
1599 else {
1600 cacheResult(list);
1601
1602 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1603 }
1604
1605 closeSession(session);
1606 }
1607 }
1608
1609 return list;
1610 }
1611
1612
1623 public JournalArticleImage findByG_A_V_First(long groupId,
1624 String articleId, double version, OrderByComparator orderByComparator)
1625 throws NoSuchArticleImageException, SystemException {
1626 JournalArticleImage journalArticleImage = fetchByG_A_V_First(groupId,
1627 articleId, version, orderByComparator);
1628
1629 if (journalArticleImage != null) {
1630 return journalArticleImage;
1631 }
1632
1633 StringBundler msg = new StringBundler(8);
1634
1635 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1636
1637 msg.append("groupId=");
1638 msg.append(groupId);
1639
1640 msg.append(", articleId=");
1641 msg.append(articleId);
1642
1643 msg.append(", version=");
1644 msg.append(version);
1645
1646 msg.append(StringPool.CLOSE_CURLY_BRACE);
1647
1648 throw new NoSuchArticleImageException(msg.toString());
1649 }
1650
1651
1661 public JournalArticleImage fetchByG_A_V_First(long groupId,
1662 String articleId, double version, OrderByComparator orderByComparator)
1663 throws SystemException {
1664 List<JournalArticleImage> list = findByG_A_V(groupId, articleId,
1665 version, 0, 1, orderByComparator);
1666
1667 if (!list.isEmpty()) {
1668 return list.get(0);
1669 }
1670
1671 return null;
1672 }
1673
1674
1685 public JournalArticleImage findByG_A_V_Last(long groupId, String articleId,
1686 double version, OrderByComparator orderByComparator)
1687 throws NoSuchArticleImageException, SystemException {
1688 JournalArticleImage journalArticleImage = fetchByG_A_V_Last(groupId,
1689 articleId, version, orderByComparator);
1690
1691 if (journalArticleImage != null) {
1692 return journalArticleImage;
1693 }
1694
1695 StringBundler msg = new StringBundler(8);
1696
1697 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1698
1699 msg.append("groupId=");
1700 msg.append(groupId);
1701
1702 msg.append(", articleId=");
1703 msg.append(articleId);
1704
1705 msg.append(", version=");
1706 msg.append(version);
1707
1708 msg.append(StringPool.CLOSE_CURLY_BRACE);
1709
1710 throw new NoSuchArticleImageException(msg.toString());
1711 }
1712
1713
1723 public JournalArticleImage fetchByG_A_V_Last(long groupId,
1724 String articleId, double version, OrderByComparator orderByComparator)
1725 throws SystemException {
1726 int count = countByG_A_V(groupId, articleId, version);
1727
1728 List<JournalArticleImage> list = findByG_A_V(groupId, articleId,
1729 version, count - 1, count, orderByComparator);
1730
1731 if (!list.isEmpty()) {
1732 return list.get(0);
1733 }
1734
1735 return null;
1736 }
1737
1738
1750 public JournalArticleImage[] findByG_A_V_PrevAndNext(long articleImageId,
1751 long groupId, String articleId, double version,
1752 OrderByComparator orderByComparator)
1753 throws NoSuchArticleImageException, SystemException {
1754 JournalArticleImage journalArticleImage = findByPrimaryKey(articleImageId);
1755
1756 Session session = null;
1757
1758 try {
1759 session = openSession();
1760
1761 JournalArticleImage[] array = new JournalArticleImageImpl[3];
1762
1763 array[0] = getByG_A_V_PrevAndNext(session, journalArticleImage,
1764 groupId, articleId, version, orderByComparator, true);
1765
1766 array[1] = journalArticleImage;
1767
1768 array[2] = getByG_A_V_PrevAndNext(session, journalArticleImage,
1769 groupId, articleId, version, orderByComparator, false);
1770
1771 return array;
1772 }
1773 catch (Exception e) {
1774 throw processException(e);
1775 }
1776 finally {
1777 closeSession(session);
1778 }
1779 }
1780
1781 protected JournalArticleImage getByG_A_V_PrevAndNext(Session session,
1782 JournalArticleImage journalArticleImage, long groupId,
1783 String articleId, double version, OrderByComparator orderByComparator,
1784 boolean previous) {
1785 StringBundler query = null;
1786
1787 if (orderByComparator != null) {
1788 query = new StringBundler(6 +
1789 (orderByComparator.getOrderByFields().length * 6));
1790 }
1791 else {
1792 query = new StringBundler(3);
1793 }
1794
1795 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE_WHERE);
1796
1797 query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
1798
1799 if (articleId == null) {
1800 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
1801 }
1802 else {
1803 if (articleId.equals(StringPool.BLANK)) {
1804 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
1805 }
1806 else {
1807 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
1808 }
1809 }
1810
1811 query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
1812
1813 if (orderByComparator != null) {
1814 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1815
1816 if (orderByConditionFields.length > 0) {
1817 query.append(WHERE_AND);
1818 }
1819
1820 for (int i = 0; i < orderByConditionFields.length; i++) {
1821 query.append(_ORDER_BY_ENTITY_ALIAS);
1822 query.append(orderByConditionFields[i]);
1823
1824 if ((i + 1) < orderByConditionFields.length) {
1825 if (orderByComparator.isAscending() ^ previous) {
1826 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1827 }
1828 else {
1829 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1830 }
1831 }
1832 else {
1833 if (orderByComparator.isAscending() ^ previous) {
1834 query.append(WHERE_GREATER_THAN);
1835 }
1836 else {
1837 query.append(WHERE_LESSER_THAN);
1838 }
1839 }
1840 }
1841
1842 query.append(ORDER_BY_CLAUSE);
1843
1844 String[] orderByFields = orderByComparator.getOrderByFields();
1845
1846 for (int i = 0; i < orderByFields.length; i++) {
1847 query.append(_ORDER_BY_ENTITY_ALIAS);
1848 query.append(orderByFields[i]);
1849
1850 if ((i + 1) < orderByFields.length) {
1851 if (orderByComparator.isAscending() ^ previous) {
1852 query.append(ORDER_BY_ASC_HAS_NEXT);
1853 }
1854 else {
1855 query.append(ORDER_BY_DESC_HAS_NEXT);
1856 }
1857 }
1858 else {
1859 if (orderByComparator.isAscending() ^ previous) {
1860 query.append(ORDER_BY_ASC);
1861 }
1862 else {
1863 query.append(ORDER_BY_DESC);
1864 }
1865 }
1866 }
1867 }
1868
1869 String sql = query.toString();
1870
1871 Query q = session.createQuery(sql);
1872
1873 q.setFirstResult(0);
1874 q.setMaxResults(2);
1875
1876 QueryPos qPos = QueryPos.getInstance(q);
1877
1878 qPos.add(groupId);
1879
1880 if (articleId != null) {
1881 qPos.add(articleId);
1882 }
1883
1884 qPos.add(version);
1885
1886 if (orderByComparator != null) {
1887 Object[] values = orderByComparator.getOrderByConditionValues(journalArticleImage);
1888
1889 for (Object value : values) {
1890 qPos.add(value);
1891 }
1892 }
1893
1894 List<JournalArticleImage> list = q.list();
1895
1896 if (list.size() == 2) {
1897 return list.get(1);
1898 }
1899 else {
1900 return null;
1901 }
1902 }
1903
1904
1917 public JournalArticleImage findByG_A_V_E_E_L(long groupId,
1918 String articleId, double version, String elInstanceId, String elName,
1919 String languageId) throws NoSuchArticleImageException, SystemException {
1920 JournalArticleImage journalArticleImage = fetchByG_A_V_E_E_L(groupId,
1921 articleId, version, elInstanceId, elName, languageId);
1922
1923 if (journalArticleImage == null) {
1924 StringBundler msg = new StringBundler(14);
1925
1926 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1927
1928 msg.append("groupId=");
1929 msg.append(groupId);
1930
1931 msg.append(", articleId=");
1932 msg.append(articleId);
1933
1934 msg.append(", version=");
1935 msg.append(version);
1936
1937 msg.append(", elInstanceId=");
1938 msg.append(elInstanceId);
1939
1940 msg.append(", elName=");
1941 msg.append(elName);
1942
1943 msg.append(", languageId=");
1944 msg.append(languageId);
1945
1946 msg.append(StringPool.CLOSE_CURLY_BRACE);
1947
1948 if (_log.isWarnEnabled()) {
1949 _log.warn(msg.toString());
1950 }
1951
1952 throw new NoSuchArticleImageException(msg.toString());
1953 }
1954
1955 return journalArticleImage;
1956 }
1957
1958
1970 public JournalArticleImage fetchByG_A_V_E_E_L(long groupId,
1971 String articleId, double version, String elInstanceId, String elName,
1972 String languageId) throws SystemException {
1973 return fetchByG_A_V_E_E_L(groupId, articleId, version, elInstanceId,
1974 elName, languageId, true);
1975 }
1976
1977
1990 public JournalArticleImage fetchByG_A_V_E_E_L(long groupId,
1991 String articleId, double version, String elInstanceId, String elName,
1992 String languageId, boolean retrieveFromCache) throws SystemException {
1993 Object[] finderArgs = new Object[] {
1994 groupId, articleId, version, elInstanceId, elName, languageId
1995 };
1996
1997 Object result = null;
1998
1999 if (retrieveFromCache) {
2000 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L,
2001 finderArgs, this);
2002 }
2003
2004 if (result instanceof JournalArticleImage) {
2005 JournalArticleImage journalArticleImage = (JournalArticleImage)result;
2006
2007 if ((groupId != journalArticleImage.getGroupId()) ||
2008 !Validator.equals(articleId,
2009 journalArticleImage.getArticleId()) ||
2010 (version != journalArticleImage.getVersion()) ||
2011 !Validator.equals(elInstanceId,
2012 journalArticleImage.getElInstanceId()) ||
2013 !Validator.equals(elName, journalArticleImage.getElName()) ||
2014 !Validator.equals(languageId,
2015 journalArticleImage.getLanguageId())) {
2016 result = null;
2017 }
2018 }
2019
2020 if (result == null) {
2021 StringBundler query = new StringBundler(7);
2022
2023 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE_WHERE);
2024
2025 query.append(_FINDER_COLUMN_G_A_V_E_E_L_GROUPID_2);
2026
2027 if (articleId == null) {
2028 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_1);
2029 }
2030 else {
2031 if (articleId.equals(StringPool.BLANK)) {
2032 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_3);
2033 }
2034 else {
2035 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_2);
2036 }
2037 }
2038
2039 query.append(_FINDER_COLUMN_G_A_V_E_E_L_VERSION_2);
2040
2041 if (elInstanceId == null) {
2042 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_1);
2043 }
2044 else {
2045 if (elInstanceId.equals(StringPool.BLANK)) {
2046 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_3);
2047 }
2048 else {
2049 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_2);
2050 }
2051 }
2052
2053 if (elName == null) {
2054 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELNAME_1);
2055 }
2056 else {
2057 if (elName.equals(StringPool.BLANK)) {
2058 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELNAME_3);
2059 }
2060 else {
2061 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELNAME_2);
2062 }
2063 }
2064
2065 if (languageId == null) {
2066 query.append(_FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_1);
2067 }
2068 else {
2069 if (languageId.equals(StringPool.BLANK)) {
2070 query.append(_FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_3);
2071 }
2072 else {
2073 query.append(_FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_2);
2074 }
2075 }
2076
2077 String sql = query.toString();
2078
2079 Session session = null;
2080
2081 try {
2082 session = openSession();
2083
2084 Query q = session.createQuery(sql);
2085
2086 QueryPos qPos = QueryPos.getInstance(q);
2087
2088 qPos.add(groupId);
2089
2090 if (articleId != null) {
2091 qPos.add(articleId);
2092 }
2093
2094 qPos.add(version);
2095
2096 if (elInstanceId != null) {
2097 qPos.add(elInstanceId);
2098 }
2099
2100 if (elName != null) {
2101 qPos.add(elName);
2102 }
2103
2104 if (languageId != null) {
2105 qPos.add(languageId);
2106 }
2107
2108 List<JournalArticleImage> list = q.list();
2109
2110 result = list;
2111
2112 JournalArticleImage journalArticleImage = null;
2113
2114 if (list.isEmpty()) {
2115 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L,
2116 finderArgs, list);
2117 }
2118 else {
2119 journalArticleImage = list.get(0);
2120
2121 cacheResult(journalArticleImage);
2122
2123 if ((journalArticleImage.getGroupId() != groupId) ||
2124 (journalArticleImage.getArticleId() == null) ||
2125 !journalArticleImage.getArticleId().equals(articleId) ||
2126 (journalArticleImage.getVersion() != version) ||
2127 (journalArticleImage.getElInstanceId() == null) ||
2128 !journalArticleImage.getElInstanceId()
2129 .equals(elInstanceId) ||
2130 (journalArticleImage.getElName() == null) ||
2131 !journalArticleImage.getElName().equals(elName) ||
2132 (journalArticleImage.getLanguageId() == null) ||
2133 !journalArticleImage.getLanguageId()
2134 .equals(languageId)) {
2135 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L,
2136 finderArgs, journalArticleImage);
2137 }
2138 }
2139
2140 return journalArticleImage;
2141 }
2142 catch (Exception e) {
2143 throw processException(e);
2144 }
2145 finally {
2146 if (result == null) {
2147 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V_E_E_L,
2148 finderArgs);
2149 }
2150
2151 closeSession(session);
2152 }
2153 }
2154 else {
2155 if (result instanceof List<?>) {
2156 return null;
2157 }
2158 else {
2159 return (JournalArticleImage)result;
2160 }
2161 }
2162 }
2163
2164
2170 public List<JournalArticleImage> findAll() throws SystemException {
2171 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2172 }
2173
2174
2186 public List<JournalArticleImage> findAll(int start, int end)
2187 throws SystemException {
2188 return findAll(start, end, null);
2189 }
2190
2191
2204 public List<JournalArticleImage> findAll(int start, int end,
2205 OrderByComparator orderByComparator) throws SystemException {
2206 FinderPath finderPath = null;
2207 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2208
2209 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2210 (orderByComparator == null)) {
2211 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2212 finderArgs = FINDER_ARGS_EMPTY;
2213 }
2214 else {
2215 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2216 finderArgs = new Object[] { start, end, orderByComparator };
2217 }
2218
2219 List<JournalArticleImage> list = (List<JournalArticleImage>)FinderCacheUtil.getResult(finderPath,
2220 finderArgs, this);
2221
2222 if (list == null) {
2223 StringBundler query = null;
2224 String sql = null;
2225
2226 if (orderByComparator != null) {
2227 query = new StringBundler(2 +
2228 (orderByComparator.getOrderByFields().length * 3));
2229
2230 query.append(_SQL_SELECT_JOURNALARTICLEIMAGE);
2231
2232 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2233 orderByComparator);
2234
2235 sql = query.toString();
2236 }
2237 else {
2238 sql = _SQL_SELECT_JOURNALARTICLEIMAGE;
2239 }
2240
2241 Session session = null;
2242
2243 try {
2244 session = openSession();
2245
2246 Query q = session.createQuery(sql);
2247
2248 if (orderByComparator == null) {
2249 list = (List<JournalArticleImage>)QueryUtil.list(q,
2250 getDialect(), start, end, false);
2251
2252 Collections.sort(list);
2253 }
2254 else {
2255 list = (List<JournalArticleImage>)QueryUtil.list(q,
2256 getDialect(), start, end);
2257 }
2258 }
2259 catch (Exception e) {
2260 throw processException(e);
2261 }
2262 finally {
2263 if (list == null) {
2264 FinderCacheUtil.removeResult(finderPath, finderArgs);
2265 }
2266 else {
2267 cacheResult(list);
2268
2269 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2270 }
2271
2272 closeSession(session);
2273 }
2274 }
2275
2276 return list;
2277 }
2278
2279
2285 public void removeByGroupId(long groupId) throws SystemException {
2286 for (JournalArticleImage journalArticleImage : findByGroupId(groupId)) {
2287 remove(journalArticleImage);
2288 }
2289 }
2290
2291
2297 public void removeByTempImage(boolean tempImage) throws SystemException {
2298 for (JournalArticleImage journalArticleImage : findByTempImage(
2299 tempImage)) {
2300 remove(journalArticleImage);
2301 }
2302 }
2303
2304
2312 public void removeByG_A_V(long groupId, String articleId, double version)
2313 throws SystemException {
2314 for (JournalArticleImage journalArticleImage : findByG_A_V(groupId,
2315 articleId, version)) {
2316 remove(journalArticleImage);
2317 }
2318 }
2319
2320
2332 public JournalArticleImage removeByG_A_V_E_E_L(long groupId,
2333 String articleId, double version, String elInstanceId, String elName,
2334 String languageId) throws NoSuchArticleImageException, SystemException {
2335 JournalArticleImage journalArticleImage = findByG_A_V_E_E_L(groupId,
2336 articleId, version, elInstanceId, elName, languageId);
2337
2338 return remove(journalArticleImage);
2339 }
2340
2341
2346 public void removeAll() throws SystemException {
2347 for (JournalArticleImage journalArticleImage : findAll()) {
2348 remove(journalArticleImage);
2349 }
2350 }
2351
2352
2359 public int countByGroupId(long groupId) throws SystemException {
2360 Object[] finderArgs = new Object[] { groupId };
2361
2362 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2363 finderArgs, this);
2364
2365 if (count == null) {
2366 StringBundler query = new StringBundler(2);
2367
2368 query.append(_SQL_COUNT_JOURNALARTICLEIMAGE_WHERE);
2369
2370 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2371
2372 String sql = query.toString();
2373
2374 Session session = null;
2375
2376 try {
2377 session = openSession();
2378
2379 Query q = session.createQuery(sql);
2380
2381 QueryPos qPos = QueryPos.getInstance(q);
2382
2383 qPos.add(groupId);
2384
2385 count = (Long)q.uniqueResult();
2386 }
2387 catch (Exception e) {
2388 throw processException(e);
2389 }
2390 finally {
2391 if (count == null) {
2392 count = Long.valueOf(0);
2393 }
2394
2395 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2396 finderArgs, count);
2397
2398 closeSession(session);
2399 }
2400 }
2401
2402 return count.intValue();
2403 }
2404
2405
2412 public int countByTempImage(boolean tempImage) throws SystemException {
2413 Object[] finderArgs = new Object[] { tempImage };
2414
2415 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TEMPIMAGE,
2416 finderArgs, this);
2417
2418 if (count == null) {
2419 StringBundler query = new StringBundler(2);
2420
2421 query.append(_SQL_COUNT_JOURNALARTICLEIMAGE_WHERE);
2422
2423 query.append(_FINDER_COLUMN_TEMPIMAGE_TEMPIMAGE_2);
2424
2425 String sql = query.toString();
2426
2427 Session session = null;
2428
2429 try {
2430 session = openSession();
2431
2432 Query q = session.createQuery(sql);
2433
2434 QueryPos qPos = QueryPos.getInstance(q);
2435
2436 qPos.add(tempImage);
2437
2438 count = (Long)q.uniqueResult();
2439 }
2440 catch (Exception e) {
2441 throw processException(e);
2442 }
2443 finally {
2444 if (count == null) {
2445 count = Long.valueOf(0);
2446 }
2447
2448 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TEMPIMAGE,
2449 finderArgs, count);
2450
2451 closeSession(session);
2452 }
2453 }
2454
2455 return count.intValue();
2456 }
2457
2458
2467 public int countByG_A_V(long groupId, String articleId, double version)
2468 throws SystemException {
2469 Object[] finderArgs = new Object[] { groupId, articleId, version };
2470
2471 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
2472 finderArgs, this);
2473
2474 if (count == null) {
2475 StringBundler query = new StringBundler(4);
2476
2477 query.append(_SQL_COUNT_JOURNALARTICLEIMAGE_WHERE);
2478
2479 query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
2480
2481 if (articleId == null) {
2482 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
2483 }
2484 else {
2485 if (articleId.equals(StringPool.BLANK)) {
2486 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
2487 }
2488 else {
2489 query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
2490 }
2491 }
2492
2493 query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
2494
2495 String sql = query.toString();
2496
2497 Session session = null;
2498
2499 try {
2500 session = openSession();
2501
2502 Query q = session.createQuery(sql);
2503
2504 QueryPos qPos = QueryPos.getInstance(q);
2505
2506 qPos.add(groupId);
2507
2508 if (articleId != null) {
2509 qPos.add(articleId);
2510 }
2511
2512 qPos.add(version);
2513
2514 count = (Long)q.uniqueResult();
2515 }
2516 catch (Exception e) {
2517 throw processException(e);
2518 }
2519 finally {
2520 if (count == null) {
2521 count = Long.valueOf(0);
2522 }
2523
2524 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
2525 finderArgs, count);
2526
2527 closeSession(session);
2528 }
2529 }
2530
2531 return count.intValue();
2532 }
2533
2534
2546 public int countByG_A_V_E_E_L(long groupId, String articleId,
2547 double version, String elInstanceId, String elName, String languageId)
2548 throws SystemException {
2549 Object[] finderArgs = new Object[] {
2550 groupId, articleId, version, elInstanceId, elName, languageId
2551 };
2552
2553 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V_E_E_L,
2554 finderArgs, this);
2555
2556 if (count == null) {
2557 StringBundler query = new StringBundler(7);
2558
2559 query.append(_SQL_COUNT_JOURNALARTICLEIMAGE_WHERE);
2560
2561 query.append(_FINDER_COLUMN_G_A_V_E_E_L_GROUPID_2);
2562
2563 if (articleId == null) {
2564 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_1);
2565 }
2566 else {
2567 if (articleId.equals(StringPool.BLANK)) {
2568 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_3);
2569 }
2570 else {
2571 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_2);
2572 }
2573 }
2574
2575 query.append(_FINDER_COLUMN_G_A_V_E_E_L_VERSION_2);
2576
2577 if (elInstanceId == null) {
2578 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_1);
2579 }
2580 else {
2581 if (elInstanceId.equals(StringPool.BLANK)) {
2582 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_3);
2583 }
2584 else {
2585 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_2);
2586 }
2587 }
2588
2589 if (elName == null) {
2590 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELNAME_1);
2591 }
2592 else {
2593 if (elName.equals(StringPool.BLANK)) {
2594 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELNAME_3);
2595 }
2596 else {
2597 query.append(_FINDER_COLUMN_G_A_V_E_E_L_ELNAME_2);
2598 }
2599 }
2600
2601 if (languageId == null) {
2602 query.append(_FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_1);
2603 }
2604 else {
2605 if (languageId.equals(StringPool.BLANK)) {
2606 query.append(_FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_3);
2607 }
2608 else {
2609 query.append(_FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_2);
2610 }
2611 }
2612
2613 String sql = query.toString();
2614
2615 Session session = null;
2616
2617 try {
2618 session = openSession();
2619
2620 Query q = session.createQuery(sql);
2621
2622 QueryPos qPos = QueryPos.getInstance(q);
2623
2624 qPos.add(groupId);
2625
2626 if (articleId != null) {
2627 qPos.add(articleId);
2628 }
2629
2630 qPos.add(version);
2631
2632 if (elInstanceId != null) {
2633 qPos.add(elInstanceId);
2634 }
2635
2636 if (elName != null) {
2637 qPos.add(elName);
2638 }
2639
2640 if (languageId != null) {
2641 qPos.add(languageId);
2642 }
2643
2644 count = (Long)q.uniqueResult();
2645 }
2646 catch (Exception e) {
2647 throw processException(e);
2648 }
2649 finally {
2650 if (count == null) {
2651 count = Long.valueOf(0);
2652 }
2653
2654 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V_E_E_L,
2655 finderArgs, count);
2656
2657 closeSession(session);
2658 }
2659 }
2660
2661 return count.intValue();
2662 }
2663
2664
2670 public int countAll() throws SystemException {
2671 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2672 FINDER_ARGS_EMPTY, this);
2673
2674 if (count == null) {
2675 Session session = null;
2676
2677 try {
2678 session = openSession();
2679
2680 Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLEIMAGE);
2681
2682 count = (Long)q.uniqueResult();
2683 }
2684 catch (Exception e) {
2685 throw processException(e);
2686 }
2687 finally {
2688 if (count == null) {
2689 count = Long.valueOf(0);
2690 }
2691
2692 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2693 FINDER_ARGS_EMPTY, count);
2694
2695 closeSession(session);
2696 }
2697 }
2698
2699 return count.intValue();
2700 }
2701
2702
2705 public void afterPropertiesSet() {
2706 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2707 com.liferay.portal.util.PropsUtil.get(
2708 "value.object.listener.com.liferay.portlet.journal.model.JournalArticleImage")));
2709
2710 if (listenerClassNames.length > 0) {
2711 try {
2712 List<ModelListener<JournalArticleImage>> listenersList = new ArrayList<ModelListener<JournalArticleImage>>();
2713
2714 for (String listenerClassName : listenerClassNames) {
2715 Class<?> clazz = getClass();
2716
2717 listenersList.add((ModelListener<JournalArticleImage>)InstanceFactory.newInstance(
2718 clazz.getClassLoader(), listenerClassName));
2719 }
2720
2721 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2722 }
2723 catch (Exception e) {
2724 _log.error(e);
2725 }
2726 }
2727 }
2728
2729 public void destroy() {
2730 EntityCacheUtil.removeCache(JournalArticleImageImpl.class.getName());
2731 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2732 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2733 }
2734
2735 @BeanReference(type = JournalArticlePersistence.class)
2736 protected JournalArticlePersistence journalArticlePersistence;
2737 @BeanReference(type = JournalArticleImagePersistence.class)
2738 protected JournalArticleImagePersistence journalArticleImagePersistence;
2739 @BeanReference(type = JournalArticleResourcePersistence.class)
2740 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
2741 @BeanReference(type = JournalContentSearchPersistence.class)
2742 protected JournalContentSearchPersistence journalContentSearchPersistence;
2743 @BeanReference(type = JournalFeedPersistence.class)
2744 protected JournalFeedPersistence journalFeedPersistence;
2745 @BeanReference(type = JournalStructurePersistence.class)
2746 protected JournalStructurePersistence journalStructurePersistence;
2747 @BeanReference(type = JournalTemplatePersistence.class)
2748 protected JournalTemplatePersistence journalTemplatePersistence;
2749 @BeanReference(type = ImagePersistence.class)
2750 protected ImagePersistence imagePersistence;
2751 @BeanReference(type = ResourcePersistence.class)
2752 protected ResourcePersistence resourcePersistence;
2753 @BeanReference(type = UserPersistence.class)
2754 protected UserPersistence userPersistence;
2755 private static final String _SQL_SELECT_JOURNALARTICLEIMAGE = "SELECT journalArticleImage FROM JournalArticleImage journalArticleImage";
2756 private static final String _SQL_SELECT_JOURNALARTICLEIMAGE_WHERE = "SELECT journalArticleImage FROM JournalArticleImage journalArticleImage WHERE ";
2757 private static final String _SQL_COUNT_JOURNALARTICLEIMAGE = "SELECT COUNT(journalArticleImage) FROM JournalArticleImage journalArticleImage";
2758 private static final String _SQL_COUNT_JOURNALARTICLEIMAGE_WHERE = "SELECT COUNT(journalArticleImage) FROM JournalArticleImage journalArticleImage WHERE ";
2759 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticleImage.groupId = ?";
2760 private static final String _FINDER_COLUMN_TEMPIMAGE_TEMPIMAGE_2 = "journalArticleImage.tempImage = ?";
2761 private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticleImage.groupId = ? AND ";
2762 private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticleImage.articleId IS NULL AND ";
2763 private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticleImage.articleId = ? AND ";
2764 private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticleImage.articleId IS NULL OR journalArticleImage.articleId = ?) AND ";
2765 private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticleImage.version = ?";
2766 private static final String _FINDER_COLUMN_G_A_V_E_E_L_GROUPID_2 = "journalArticleImage.groupId = ? AND ";
2767 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_1 = "journalArticleImage.articleId IS NULL AND ";
2768 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_2 = "journalArticleImage.articleId = ? AND ";
2769 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ARTICLEID_3 = "(journalArticleImage.articleId IS NULL OR journalArticleImage.articleId = ?) AND ";
2770 private static final String _FINDER_COLUMN_G_A_V_E_E_L_VERSION_2 = "journalArticleImage.version = ? AND ";
2771 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_1 = "journalArticleImage.elInstanceId IS NULL AND ";
2772 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_2 = "journalArticleImage.elInstanceId = ? AND ";
2773 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ELINSTANCEID_3 = "(journalArticleImage.elInstanceId IS NULL OR journalArticleImage.elInstanceId = ?) AND ";
2774 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ELNAME_1 = "journalArticleImage.elName IS NULL AND ";
2775 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ELNAME_2 = "journalArticleImage.elName = ? AND ";
2776 private static final String _FINDER_COLUMN_G_A_V_E_E_L_ELNAME_3 = "(journalArticleImage.elName IS NULL OR journalArticleImage.elName = ?) AND ";
2777 private static final String _FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_1 = "journalArticleImage.languageId IS NULL";
2778 private static final String _FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_2 = "journalArticleImage.languageId = ?";
2779 private static final String _FINDER_COLUMN_G_A_V_E_E_L_LANGUAGEID_3 = "(journalArticleImage.languageId IS NULL OR journalArticleImage.languageId = ?)";
2780 private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticleImage.";
2781 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticleImage exists with the primary key ";
2782 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticleImage exists with the key {";
2783 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2784 private static Log _log = LogFactoryUtil.getLog(JournalArticleImagePersistenceImpl.class);
2785 private static JournalArticleImage _nullJournalArticleImage = new JournalArticleImageImpl() {
2786 @Override
2787 public Object clone() {
2788 return this;
2789 }
2790
2791 @Override
2792 public CacheModel<JournalArticleImage> toCacheModel() {
2793 return _nullJournalArticleImageCacheModel;
2794 }
2795 };
2796
2797 private static CacheModel<JournalArticleImage> _nullJournalArticleImageCacheModel =
2798 new CacheModel<JournalArticleImage>() {
2799 public JournalArticleImage toEntityModel() {
2800 return _nullJournalArticleImage;
2801 }
2802 };
2803 }