1
14
15 package com.liferay.portlet.imagegallery.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.GetterUtil;
31 import com.liferay.portal.kernel.util.InstanceFactory;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.kernel.util.Validator;
37 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
38 import com.liferay.portal.model.ModelListener;
39 import com.liferay.portal.service.persistence.BatchSessionUtil;
40 import com.liferay.portal.service.persistence.ImagePersistence;
41 import com.liferay.portal.service.persistence.ResourcePersistence;
42 import com.liferay.portal.service.persistence.UserPersistence;
43 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
44
45 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
46 import com.liferay.portlet.imagegallery.NoSuchImageException;
47 import com.liferay.portlet.imagegallery.model.IGImage;
48 import com.liferay.portlet.imagegallery.model.impl.IGImageImpl;
49 import com.liferay.portlet.imagegallery.model.impl.IGImageModelImpl;
50 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
51 import com.liferay.portlet.tags.service.persistence.TagsAssetPersistence;
52 import com.liferay.portlet.tags.service.persistence.TagsEntryPersistence;
53
54 import java.io.Serializable;
55
56 import java.util.ArrayList;
57 import java.util.Collections;
58 import java.util.List;
59
60
73 public class IGImagePersistenceImpl extends BasePersistenceImpl<IGImage>
74 implements IGImagePersistence {
75 public static final String FINDER_CLASS_NAME_ENTITY = IGImageImpl.class.getName();
76 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
77 ".List";
78 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
79 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80 "findByUuid",
81 new String[] {
82 String.class.getName(),
83
84 "java.lang.Integer", "java.lang.Integer",
85 "com.liferay.portal.kernel.util.OrderByComparator"
86 });
87 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
88 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89 "countByUuid", new String[] { String.class.getName() });
90 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
91 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
92 "fetchByUUID_G",
93 new String[] { String.class.getName(), Long.class.getName() });
94 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
95 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "countByUUID_G",
97 new String[] { String.class.getName(), Long.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
99 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "findByGroupId",
101 new String[] {
102 Long.class.getName(),
103
104 "java.lang.Integer", "java.lang.Integer",
105 "com.liferay.portal.kernel.util.OrderByComparator"
106 });
107 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
108 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
109 "countByGroupId", new String[] { Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FIND_BY_FOLDERID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
111 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112 "findByFolderId",
113 new String[] {
114 Long.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_COUNT_BY_FOLDERID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
120 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121 "countByFolderId", new String[] { Long.class.getName() });
122 public static final FinderPath FINDER_PATH_FETCH_BY_SMALLIMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
123 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
124 "fetchBySmallImageId", new String[] { Long.class.getName() });
125 public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
126 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127 "countBySmallImageId", new String[] { Long.class.getName() });
128 public static final FinderPath FINDER_PATH_FETCH_BY_LARGEIMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
129 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
130 "fetchByLargeImageId", new String[] { Long.class.getName() });
131 public static final FinderPath FINDER_PATH_COUNT_BY_LARGEIMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
132 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
133 "countByLargeImageId", new String[] { Long.class.getName() });
134 public static final FinderPath FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
135 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
136 "fetchByCustom1ImageId", new String[] { Long.class.getName() });
137 public static final FinderPath FINDER_PATH_COUNT_BY_CUSTOM1IMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
138 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
139 "countByCustom1ImageId", new String[] { Long.class.getName() });
140 public static final FinderPath FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
141 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
142 "fetchByCustom2ImageId", new String[] { Long.class.getName() });
143 public static final FinderPath FINDER_PATH_COUNT_BY_CUSTOM2IMAGEID = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
144 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
145 "countByCustom2ImageId", new String[] { Long.class.getName() });
146 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
147 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
148 "findByG_U",
149 new String[] {
150 Long.class.getName(), Long.class.getName(),
151
152 "java.lang.Integer", "java.lang.Integer",
153 "com.liferay.portal.kernel.util.OrderByComparator"
154 });
155 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
156 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
157 "countByG_U",
158 new String[] { Long.class.getName(), Long.class.getName() });
159 public static final FinderPath FINDER_PATH_FIND_BY_F_N = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
160 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
161 "findByF_N",
162 new String[] {
163 Long.class.getName(), String.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_F_N = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
169 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
170 "countByF_N",
171 new String[] { Long.class.getName(), String.class.getName() });
172 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
173 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
174 "findAll", new String[0]);
175 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(IGImageModelImpl.ENTITY_CACHE_ENABLED,
176 IGImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
177 "countAll", new String[0]);
178
179 public void cacheResult(IGImage igImage) {
180 EntityCacheUtil.putResult(IGImageModelImpl.ENTITY_CACHE_ENABLED,
181 IGImageImpl.class, igImage.getPrimaryKey(), igImage);
182
183 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
184 new Object[] { igImage.getUuid(), new Long(igImage.getGroupId()) },
185 igImage);
186
187 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
188 new Object[] { new Long(igImage.getSmallImageId()) }, igImage);
189
190 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
191 new Object[] { new Long(igImage.getLargeImageId()) }, igImage);
192
193 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
194 new Object[] { new Long(igImage.getCustom1ImageId()) }, igImage);
195
196 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
197 new Object[] { new Long(igImage.getCustom2ImageId()) }, igImage);
198 }
199
200 public void cacheResult(List<IGImage> igImages) {
201 for (IGImage igImage : igImages) {
202 if (EntityCacheUtil.getResult(
203 IGImageModelImpl.ENTITY_CACHE_ENABLED,
204 IGImageImpl.class, igImage.getPrimaryKey(), this) == null) {
205 cacheResult(igImage);
206 }
207 }
208 }
209
210 public void clearCache() {
211 CacheRegistry.clear(IGImageImpl.class.getName());
212 EntityCacheUtil.clearCache(IGImageImpl.class.getName());
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
215 }
216
217 public void clearCache(IGImage igImage) {
218 EntityCacheUtil.removeResult(IGImageModelImpl.ENTITY_CACHE_ENABLED,
219 IGImageImpl.class, igImage.getPrimaryKey());
220
221 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
222 new Object[] { igImage.getUuid(), new Long(igImage.getGroupId()) });
223
224 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
225 new Object[] { new Long(igImage.getSmallImageId()) });
226
227 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
228 new Object[] { new Long(igImage.getLargeImageId()) });
229
230 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
231 new Object[] { new Long(igImage.getCustom1ImageId()) });
232
233 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
234 new Object[] { new Long(igImage.getCustom2ImageId()) });
235 }
236
237 public IGImage create(long imageId) {
238 IGImage igImage = new IGImageImpl();
239
240 igImage.setNew(true);
241 igImage.setPrimaryKey(imageId);
242
243 String uuid = PortalUUIDUtil.generate();
244
245 igImage.setUuid(uuid);
246
247 return igImage;
248 }
249
250 public IGImage remove(Serializable primaryKey)
251 throws NoSuchModelException, SystemException {
252 return remove(((Long)primaryKey).longValue());
253 }
254
255 public IGImage remove(long imageId)
256 throws NoSuchImageException, SystemException {
257 Session session = null;
258
259 try {
260 session = openSession();
261
262 IGImage igImage = (IGImage)session.get(IGImageImpl.class,
263 new Long(imageId));
264
265 if (igImage == null) {
266 if (_log.isWarnEnabled()) {
267 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + imageId);
268 }
269
270 throw new NoSuchImageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
271 imageId);
272 }
273
274 return remove(igImage);
275 }
276 catch (NoSuchImageException nsee) {
277 throw nsee;
278 }
279 catch (Exception e) {
280 throw processException(e);
281 }
282 finally {
283 closeSession(session);
284 }
285 }
286
287 protected IGImage removeImpl(IGImage igImage) throws SystemException {
288 igImage = toUnwrappedModel(igImage);
289
290 Session session = null;
291
292 try {
293 session = openSession();
294
295 BatchSessionUtil.delete(session, igImage);
296 }
297 catch (Exception e) {
298 throw processException(e);
299 }
300 finally {
301 closeSession(session);
302 }
303
304 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
305
306 IGImageModelImpl igImageModelImpl = (IGImageModelImpl)igImage;
307
308 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
309 new Object[] {
310 igImageModelImpl.getOriginalUuid(),
311 new Long(igImageModelImpl.getOriginalGroupId())
312 });
313
314 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
315 new Object[] { new Long(igImageModelImpl.getOriginalSmallImageId()) });
316
317 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
318 new Object[] { new Long(igImageModelImpl.getOriginalLargeImageId()) });
319
320 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
321 new Object[] { new Long(igImageModelImpl.getOriginalCustom1ImageId()) });
322
323 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
324 new Object[] { new Long(igImageModelImpl.getOriginalCustom2ImageId()) });
325
326 EntityCacheUtil.removeResult(IGImageModelImpl.ENTITY_CACHE_ENABLED,
327 IGImageImpl.class, igImage.getPrimaryKey());
328
329 return igImage;
330 }
331
332
335 public IGImage update(IGImage igImage) throws SystemException {
336 if (_log.isWarnEnabled()) {
337 _log.warn(
338 "Using the deprecated update(IGImage igImage) method. Use update(IGImage igImage, boolean merge) instead.");
339 }
340
341 return update(igImage, false);
342 }
343
344 public IGImage updateImpl(
345 com.liferay.portlet.imagegallery.model.IGImage igImage, boolean merge)
346 throws SystemException {
347 igImage = toUnwrappedModel(igImage);
348
349 boolean isNew = igImage.isNew();
350
351 IGImageModelImpl igImageModelImpl = (IGImageModelImpl)igImage;
352
353 if (Validator.isNull(igImage.getUuid())) {
354 String uuid = PortalUUIDUtil.generate();
355
356 igImage.setUuid(uuid);
357 }
358
359 Session session = null;
360
361 try {
362 session = openSession();
363
364 BatchSessionUtil.update(session, igImage, merge);
365
366 igImage.setNew(false);
367 }
368 catch (Exception e) {
369 throw processException(e);
370 }
371 finally {
372 closeSession(session);
373 }
374
375 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
376
377 EntityCacheUtil.putResult(IGImageModelImpl.ENTITY_CACHE_ENABLED,
378 IGImageImpl.class, igImage.getPrimaryKey(), igImage);
379
380 if (!isNew &&
381 (!Validator.equals(igImage.getUuid(),
382 igImageModelImpl.getOriginalUuid()) ||
383 (igImage.getGroupId() != igImageModelImpl.getOriginalGroupId()))) {
384 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
385 new Object[] {
386 igImageModelImpl.getOriginalUuid(),
387 new Long(igImageModelImpl.getOriginalGroupId())
388 });
389 }
390
391 if (isNew ||
392 (!Validator.equals(igImage.getUuid(),
393 igImageModelImpl.getOriginalUuid()) ||
394 (igImage.getGroupId() != igImageModelImpl.getOriginalGroupId()))) {
395 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
396 new Object[] { igImage.getUuid(), new Long(igImage.getGroupId()) },
397 igImage);
398 }
399
400 if (!isNew &&
401 (igImage.getSmallImageId() != igImageModelImpl.getOriginalSmallImageId())) {
402 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
403 new Object[] {
404 new Long(igImageModelImpl.getOriginalSmallImageId())
405 });
406 }
407
408 if (isNew ||
409 (igImage.getSmallImageId() != igImageModelImpl.getOriginalSmallImageId())) {
410 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
411 new Object[] { new Long(igImage.getSmallImageId()) }, igImage);
412 }
413
414 if (!isNew &&
415 (igImage.getLargeImageId() != igImageModelImpl.getOriginalLargeImageId())) {
416 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
417 new Object[] {
418 new Long(igImageModelImpl.getOriginalLargeImageId())
419 });
420 }
421
422 if (isNew ||
423 (igImage.getLargeImageId() != igImageModelImpl.getOriginalLargeImageId())) {
424 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
425 new Object[] { new Long(igImage.getLargeImageId()) }, igImage);
426 }
427
428 if (!isNew &&
429 (igImage.getCustom1ImageId() != igImageModelImpl.getOriginalCustom1ImageId())) {
430 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
431 new Object[] {
432 new Long(igImageModelImpl.getOriginalCustom1ImageId())
433 });
434 }
435
436 if (isNew ||
437 (igImage.getCustom1ImageId() != igImageModelImpl.getOriginalCustom1ImageId())) {
438 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
439 new Object[] { new Long(igImage.getCustom1ImageId()) }, igImage);
440 }
441
442 if (!isNew &&
443 (igImage.getCustom2ImageId() != igImageModelImpl.getOriginalCustom2ImageId())) {
444 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
445 new Object[] {
446 new Long(igImageModelImpl.getOriginalCustom2ImageId())
447 });
448 }
449
450 if (isNew ||
451 (igImage.getCustom2ImageId() != igImageModelImpl.getOriginalCustom2ImageId())) {
452 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
453 new Object[] { new Long(igImage.getCustom2ImageId()) }, igImage);
454 }
455
456 return igImage;
457 }
458
459 protected IGImage toUnwrappedModel(IGImage igImage) {
460 if (igImage instanceof IGImageImpl) {
461 return igImage;
462 }
463
464 IGImageImpl igImageImpl = new IGImageImpl();
465
466 igImageImpl.setNew(igImage.isNew());
467 igImageImpl.setPrimaryKey(igImage.getPrimaryKey());
468
469 igImageImpl.setUuid(igImage.getUuid());
470 igImageImpl.setImageId(igImage.getImageId());
471 igImageImpl.setGroupId(igImage.getGroupId());
472 igImageImpl.setCompanyId(igImage.getCompanyId());
473 igImageImpl.setUserId(igImage.getUserId());
474 igImageImpl.setCreateDate(igImage.getCreateDate());
475 igImageImpl.setModifiedDate(igImage.getModifiedDate());
476 igImageImpl.setFolderId(igImage.getFolderId());
477 igImageImpl.setName(igImage.getName());
478 igImageImpl.setDescription(igImage.getDescription());
479 igImageImpl.setSmallImageId(igImage.getSmallImageId());
480 igImageImpl.setLargeImageId(igImage.getLargeImageId());
481 igImageImpl.setCustom1ImageId(igImage.getCustom1ImageId());
482 igImageImpl.setCustom2ImageId(igImage.getCustom2ImageId());
483
484 return igImageImpl;
485 }
486
487 public IGImage findByPrimaryKey(Serializable primaryKey)
488 throws NoSuchModelException, SystemException {
489 return findByPrimaryKey(((Long)primaryKey).longValue());
490 }
491
492 public IGImage findByPrimaryKey(long imageId)
493 throws NoSuchImageException, SystemException {
494 IGImage igImage = fetchByPrimaryKey(imageId);
495
496 if (igImage == null) {
497 if (_log.isWarnEnabled()) {
498 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + imageId);
499 }
500
501 throw new NoSuchImageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
502 imageId);
503 }
504
505 return igImage;
506 }
507
508 public IGImage fetchByPrimaryKey(Serializable primaryKey)
509 throws SystemException {
510 return fetchByPrimaryKey(((Long)primaryKey).longValue());
511 }
512
513 public IGImage fetchByPrimaryKey(long imageId) throws SystemException {
514 IGImage igImage = (IGImage)EntityCacheUtil.getResult(IGImageModelImpl.ENTITY_CACHE_ENABLED,
515 IGImageImpl.class, imageId, this);
516
517 if (igImage == null) {
518 Session session = null;
519
520 try {
521 session = openSession();
522
523 igImage = (IGImage)session.get(IGImageImpl.class,
524 new Long(imageId));
525 }
526 catch (Exception e) {
527 throw processException(e);
528 }
529 finally {
530 if (igImage != null) {
531 cacheResult(igImage);
532 }
533
534 closeSession(session);
535 }
536 }
537
538 return igImage;
539 }
540
541 public List<IGImage> findByUuid(String uuid) throws SystemException {
542 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
543 }
544
545 public List<IGImage> findByUuid(String uuid, int start, int end)
546 throws SystemException {
547 return findByUuid(uuid, start, end, null);
548 }
549
550 public List<IGImage> findByUuid(String uuid, int start, int end,
551 OrderByComparator orderByComparator) throws SystemException {
552 Object[] finderArgs = new Object[] {
553 uuid,
554
555 String.valueOf(start), String.valueOf(end),
556 String.valueOf(orderByComparator)
557 };
558
559 List<IGImage> list = (List<IGImage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
560 finderArgs, this);
561
562 if (list == null) {
563 StringBundler query = null;
564
565 if (orderByComparator != null) {
566 query = new StringBundler(3 +
567 (orderByComparator.getOrderByFields().length * 3));
568 }
569 else {
570 query = new StringBundler(3);
571 }
572
573 query.append(_SQL_SELECT_IGIMAGE_WHERE);
574
575 if (uuid == null) {
576 query.append(_FINDER_COLUMN_UUID_UUID_1);
577 }
578 else {
579 if (uuid.equals(StringPool.BLANK)) {
580 query.append(_FINDER_COLUMN_UUID_UUID_3);
581 }
582 else {
583 query.append(_FINDER_COLUMN_UUID_UUID_2);
584 }
585 }
586
587 if (orderByComparator != null) {
588 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
589 orderByComparator);
590 }
591
592 else {
593 query.append(IGImageModelImpl.ORDER_BY_JPQL);
594 }
595
596 String sql = query.toString();
597
598 Session session = null;
599
600 try {
601 session = openSession();
602
603 Query q = session.createQuery(sql);
604
605 QueryPos qPos = QueryPos.getInstance(q);
606
607 if (uuid != null) {
608 qPos.add(uuid);
609 }
610
611 list = (List<IGImage>)QueryUtil.list(q, getDialect(), start, end);
612 }
613 catch (Exception e) {
614 throw processException(e);
615 }
616 finally {
617 if (list == null) {
618 list = new ArrayList<IGImage>();
619 }
620
621 cacheResult(list);
622
623 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
624 list);
625
626 closeSession(session);
627 }
628 }
629
630 return list;
631 }
632
633 public IGImage findByUuid_First(String uuid,
634 OrderByComparator orderByComparator)
635 throws NoSuchImageException, SystemException {
636 List<IGImage> list = findByUuid(uuid, 0, 1, orderByComparator);
637
638 if (list.isEmpty()) {
639 StringBundler msg = new StringBundler(4);
640
641 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
642
643 msg.append("uuid=");
644 msg.append(uuid);
645
646 msg.append(StringPool.CLOSE_CURLY_BRACE);
647
648 throw new NoSuchImageException(msg.toString());
649 }
650 else {
651 return list.get(0);
652 }
653 }
654
655 public IGImage findByUuid_Last(String uuid,
656 OrderByComparator orderByComparator)
657 throws NoSuchImageException, SystemException {
658 int count = countByUuid(uuid);
659
660 List<IGImage> list = findByUuid(uuid, count - 1, count,
661 orderByComparator);
662
663 if (list.isEmpty()) {
664 StringBundler msg = new StringBundler(4);
665
666 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
667
668 msg.append("uuid=");
669 msg.append(uuid);
670
671 msg.append(StringPool.CLOSE_CURLY_BRACE);
672
673 throw new NoSuchImageException(msg.toString());
674 }
675 else {
676 return list.get(0);
677 }
678 }
679
680 public IGImage[] findByUuid_PrevAndNext(long imageId, String uuid,
681 OrderByComparator orderByComparator)
682 throws NoSuchImageException, SystemException {
683 IGImage igImage = findByPrimaryKey(imageId);
684
685 Session session = null;
686
687 try {
688 session = openSession();
689
690 IGImage[] array = new IGImageImpl[3];
691
692 array[0] = getByUuid_PrevAndNext(session, igImage, uuid,
693 orderByComparator, true);
694
695 array[1] = igImage;
696
697 array[2] = getByUuid_PrevAndNext(session, igImage, uuid,
698 orderByComparator, false);
699
700 return array;
701 }
702 catch (Exception e) {
703 throw processException(e);
704 }
705 finally {
706 closeSession(session);
707 }
708 }
709
710 protected IGImage getByUuid_PrevAndNext(Session session, IGImage igImage,
711 String uuid, OrderByComparator orderByComparator, boolean previous) {
712 StringBundler query = null;
713
714 if (orderByComparator != null) {
715 query = new StringBundler(6 +
716 (orderByComparator.getOrderByFields().length * 6));
717 }
718 else {
719 query = new StringBundler(3);
720 }
721
722 query.append(_SQL_SELECT_IGIMAGE_WHERE);
723
724 if (uuid == null) {
725 query.append(_FINDER_COLUMN_UUID_UUID_1);
726 }
727 else {
728 if (uuid.equals(StringPool.BLANK)) {
729 query.append(_FINDER_COLUMN_UUID_UUID_3);
730 }
731 else {
732 query.append(_FINDER_COLUMN_UUID_UUID_2);
733 }
734 }
735
736 if (orderByComparator != null) {
737 String[] orderByFields = orderByComparator.getOrderByFields();
738
739 if (orderByFields.length > 0) {
740 query.append(WHERE_AND);
741 }
742
743 for (int i = 0; i < orderByFields.length; i++) {
744 query.append(_ORDER_BY_ENTITY_ALIAS);
745 query.append(orderByFields[i]);
746
747 if ((i + 1) < orderByFields.length) {
748 if (orderByComparator.isAscending() ^ previous) {
749 query.append(WHERE_GREATER_THAN_HAS_NEXT);
750 }
751 else {
752 query.append(WHERE_LESSER_THAN_HAS_NEXT);
753 }
754 }
755 else {
756 if (orderByComparator.isAscending() ^ previous) {
757 query.append(WHERE_GREATER_THAN);
758 }
759 else {
760 query.append(WHERE_LESSER_THAN);
761 }
762 }
763 }
764
765 query.append(ORDER_BY_CLAUSE);
766
767 for (int i = 0; i < orderByFields.length; i++) {
768 query.append(_ORDER_BY_ENTITY_ALIAS);
769 query.append(orderByFields[i]);
770
771 if ((i + 1) < orderByFields.length) {
772 if (orderByComparator.isAscending() ^ previous) {
773 query.append(ORDER_BY_ASC_HAS_NEXT);
774 }
775 else {
776 query.append(ORDER_BY_DESC_HAS_NEXT);
777 }
778 }
779 else {
780 if (orderByComparator.isAscending() ^ previous) {
781 query.append(ORDER_BY_ASC);
782 }
783 else {
784 query.append(ORDER_BY_DESC);
785 }
786 }
787 }
788 }
789
790 else {
791 query.append(IGImageModelImpl.ORDER_BY_JPQL);
792 }
793
794 String sql = query.toString();
795
796 Query q = session.createQuery(sql);
797
798 q.setFirstResult(0);
799 q.setMaxResults(2);
800
801 QueryPos qPos = QueryPos.getInstance(q);
802
803 if (uuid != null) {
804 qPos.add(uuid);
805 }
806
807 if (orderByComparator != null) {
808 Object[] values = orderByComparator.getOrderByValues(igImage);
809
810 for (Object value : values) {
811 qPos.add(value);
812 }
813 }
814
815 List<IGImage> list = q.list();
816
817 if (list.size() == 2) {
818 return list.get(1);
819 }
820 else {
821 return null;
822 }
823 }
824
825 public IGImage findByUUID_G(String uuid, long groupId)
826 throws NoSuchImageException, SystemException {
827 IGImage igImage = fetchByUUID_G(uuid, groupId);
828
829 if (igImage == null) {
830 StringBundler msg = new StringBundler(6);
831
832 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
833
834 msg.append("uuid=");
835 msg.append(uuid);
836
837 msg.append(", groupId=");
838 msg.append(groupId);
839
840 msg.append(StringPool.CLOSE_CURLY_BRACE);
841
842 if (_log.isWarnEnabled()) {
843 _log.warn(msg.toString());
844 }
845
846 throw new NoSuchImageException(msg.toString());
847 }
848
849 return igImage;
850 }
851
852 public IGImage fetchByUUID_G(String uuid, long groupId)
853 throws SystemException {
854 return fetchByUUID_G(uuid, groupId, true);
855 }
856
857 public IGImage fetchByUUID_G(String uuid, long groupId,
858 boolean retrieveFromCache) throws SystemException {
859 Object[] finderArgs = new Object[] { uuid, groupId };
860
861 Object result = null;
862
863 if (retrieveFromCache) {
864 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
865 finderArgs, this);
866 }
867
868 if (result == null) {
869 StringBundler query = new StringBundler(4);
870
871 query.append(_SQL_SELECT_IGIMAGE_WHERE);
872
873 if (uuid == null) {
874 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
875 }
876 else {
877 if (uuid.equals(StringPool.BLANK)) {
878 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
879 }
880 else {
881 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
882 }
883 }
884
885 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
886
887 query.append(IGImageModelImpl.ORDER_BY_JPQL);
888
889 String sql = query.toString();
890
891 Session session = null;
892
893 try {
894 session = openSession();
895
896 Query q = session.createQuery(sql);
897
898 QueryPos qPos = QueryPos.getInstance(q);
899
900 if (uuid != null) {
901 qPos.add(uuid);
902 }
903
904 qPos.add(groupId);
905
906 List<IGImage> list = q.list();
907
908 result = list;
909
910 IGImage igImage = null;
911
912 if (list.isEmpty()) {
913 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
914 finderArgs, list);
915 }
916 else {
917 igImage = list.get(0);
918
919 cacheResult(igImage);
920
921 if ((igImage.getUuid() == null) ||
922 !igImage.getUuid().equals(uuid) ||
923 (igImage.getGroupId() != groupId)) {
924 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
925 finderArgs, igImage);
926 }
927 }
928
929 return igImage;
930 }
931 catch (Exception e) {
932 throw processException(e);
933 }
934 finally {
935 if (result == null) {
936 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
937 finderArgs, new ArrayList<IGImage>());
938 }
939
940 closeSession(session);
941 }
942 }
943 else {
944 if (result instanceof List<?>) {
945 return null;
946 }
947 else {
948 return (IGImage)result;
949 }
950 }
951 }
952
953 public List<IGImage> findByGroupId(long groupId) throws SystemException {
954 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
955 }
956
957 public List<IGImage> findByGroupId(long groupId, int start, int end)
958 throws SystemException {
959 return findByGroupId(groupId, start, end, null);
960 }
961
962 public List<IGImage> findByGroupId(long groupId, int start, int end,
963 OrderByComparator orderByComparator) throws SystemException {
964 Object[] finderArgs = new Object[] {
965 groupId,
966
967 String.valueOf(start), String.valueOf(end),
968 String.valueOf(orderByComparator)
969 };
970
971 List<IGImage> list = (List<IGImage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
972 finderArgs, this);
973
974 if (list == null) {
975 StringBundler query = null;
976
977 if (orderByComparator != null) {
978 query = new StringBundler(3 +
979 (orderByComparator.getOrderByFields().length * 3));
980 }
981 else {
982 query = new StringBundler(3);
983 }
984
985 query.append(_SQL_SELECT_IGIMAGE_WHERE);
986
987 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
988
989 if (orderByComparator != null) {
990 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
991 orderByComparator);
992 }
993
994 else {
995 query.append(IGImageModelImpl.ORDER_BY_JPQL);
996 }
997
998 String sql = query.toString();
999
1000 Session session = null;
1001
1002 try {
1003 session = openSession();
1004
1005 Query q = session.createQuery(sql);
1006
1007 QueryPos qPos = QueryPos.getInstance(q);
1008
1009 qPos.add(groupId);
1010
1011 list = (List<IGImage>)QueryUtil.list(q, getDialect(), start, end);
1012 }
1013 catch (Exception e) {
1014 throw processException(e);
1015 }
1016 finally {
1017 if (list == null) {
1018 list = new ArrayList<IGImage>();
1019 }
1020
1021 cacheResult(list);
1022
1023 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1024 finderArgs, list);
1025
1026 closeSession(session);
1027 }
1028 }
1029
1030 return list;
1031 }
1032
1033 public IGImage findByGroupId_First(long groupId,
1034 OrderByComparator orderByComparator)
1035 throws NoSuchImageException, SystemException {
1036 List<IGImage> list = findByGroupId(groupId, 0, 1, orderByComparator);
1037
1038 if (list.isEmpty()) {
1039 StringBundler msg = new StringBundler(4);
1040
1041 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1042
1043 msg.append("groupId=");
1044 msg.append(groupId);
1045
1046 msg.append(StringPool.CLOSE_CURLY_BRACE);
1047
1048 throw new NoSuchImageException(msg.toString());
1049 }
1050 else {
1051 return list.get(0);
1052 }
1053 }
1054
1055 public IGImage findByGroupId_Last(long groupId,
1056 OrderByComparator orderByComparator)
1057 throws NoSuchImageException, SystemException {
1058 int count = countByGroupId(groupId);
1059
1060 List<IGImage> list = findByGroupId(groupId, count - 1, count,
1061 orderByComparator);
1062
1063 if (list.isEmpty()) {
1064 StringBundler msg = new StringBundler(4);
1065
1066 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1067
1068 msg.append("groupId=");
1069 msg.append(groupId);
1070
1071 msg.append(StringPool.CLOSE_CURLY_BRACE);
1072
1073 throw new NoSuchImageException(msg.toString());
1074 }
1075 else {
1076 return list.get(0);
1077 }
1078 }
1079
1080 public IGImage[] findByGroupId_PrevAndNext(long imageId, long groupId,
1081 OrderByComparator orderByComparator)
1082 throws NoSuchImageException, SystemException {
1083 IGImage igImage = findByPrimaryKey(imageId);
1084
1085 Session session = null;
1086
1087 try {
1088 session = openSession();
1089
1090 IGImage[] array = new IGImageImpl[3];
1091
1092 array[0] = getByGroupId_PrevAndNext(session, igImage, groupId,
1093 orderByComparator, true);
1094
1095 array[1] = igImage;
1096
1097 array[2] = getByGroupId_PrevAndNext(session, igImage, groupId,
1098 orderByComparator, false);
1099
1100 return array;
1101 }
1102 catch (Exception e) {
1103 throw processException(e);
1104 }
1105 finally {
1106 closeSession(session);
1107 }
1108 }
1109
1110 protected IGImage getByGroupId_PrevAndNext(Session session,
1111 IGImage igImage, long groupId, OrderByComparator orderByComparator,
1112 boolean previous) {
1113 StringBundler query = null;
1114
1115 if (orderByComparator != null) {
1116 query = new StringBundler(6 +
1117 (orderByComparator.getOrderByFields().length * 6));
1118 }
1119 else {
1120 query = new StringBundler(3);
1121 }
1122
1123 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1124
1125 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1126
1127 if (orderByComparator != null) {
1128 String[] orderByFields = orderByComparator.getOrderByFields();
1129
1130 if (orderByFields.length > 0) {
1131 query.append(WHERE_AND);
1132 }
1133
1134 for (int i = 0; i < orderByFields.length; i++) {
1135 query.append(_ORDER_BY_ENTITY_ALIAS);
1136 query.append(orderByFields[i]);
1137
1138 if ((i + 1) < orderByFields.length) {
1139 if (orderByComparator.isAscending() ^ previous) {
1140 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1141 }
1142 else {
1143 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1144 }
1145 }
1146 else {
1147 if (orderByComparator.isAscending() ^ previous) {
1148 query.append(WHERE_GREATER_THAN);
1149 }
1150 else {
1151 query.append(WHERE_LESSER_THAN);
1152 }
1153 }
1154 }
1155
1156 query.append(ORDER_BY_CLAUSE);
1157
1158 for (int i = 0; i < orderByFields.length; i++) {
1159 query.append(_ORDER_BY_ENTITY_ALIAS);
1160 query.append(orderByFields[i]);
1161
1162 if ((i + 1) < orderByFields.length) {
1163 if (orderByComparator.isAscending() ^ previous) {
1164 query.append(ORDER_BY_ASC_HAS_NEXT);
1165 }
1166 else {
1167 query.append(ORDER_BY_DESC_HAS_NEXT);
1168 }
1169 }
1170 else {
1171 if (orderByComparator.isAscending() ^ previous) {
1172 query.append(ORDER_BY_ASC);
1173 }
1174 else {
1175 query.append(ORDER_BY_DESC);
1176 }
1177 }
1178 }
1179 }
1180
1181 else {
1182 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1183 }
1184
1185 String sql = query.toString();
1186
1187 Query q = session.createQuery(sql);
1188
1189 q.setFirstResult(0);
1190 q.setMaxResults(2);
1191
1192 QueryPos qPos = QueryPos.getInstance(q);
1193
1194 qPos.add(groupId);
1195
1196 if (orderByComparator != null) {
1197 Object[] values = orderByComparator.getOrderByValues(igImage);
1198
1199 for (Object value : values) {
1200 qPos.add(value);
1201 }
1202 }
1203
1204 List<IGImage> list = q.list();
1205
1206 if (list.size() == 2) {
1207 return list.get(1);
1208 }
1209 else {
1210 return null;
1211 }
1212 }
1213
1214 public List<IGImage> findByFolderId(long folderId)
1215 throws SystemException {
1216 return findByFolderId(folderId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1217 null);
1218 }
1219
1220 public List<IGImage> findByFolderId(long folderId, int start, int end)
1221 throws SystemException {
1222 return findByFolderId(folderId, start, end, null);
1223 }
1224
1225 public List<IGImage> findByFolderId(long folderId, int start, int end,
1226 OrderByComparator orderByComparator) throws SystemException {
1227 Object[] finderArgs = new Object[] {
1228 folderId,
1229
1230 String.valueOf(start), String.valueOf(end),
1231 String.valueOf(orderByComparator)
1232 };
1233
1234 List<IGImage> list = (List<IGImage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FOLDERID,
1235 finderArgs, this);
1236
1237 if (list == null) {
1238 StringBundler query = null;
1239
1240 if (orderByComparator != null) {
1241 query = new StringBundler(3 +
1242 (orderByComparator.getOrderByFields().length * 3));
1243 }
1244 else {
1245 query = new StringBundler(3);
1246 }
1247
1248 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1249
1250 query.append(_FINDER_COLUMN_FOLDERID_FOLDERID_2);
1251
1252 if (orderByComparator != null) {
1253 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1254 orderByComparator);
1255 }
1256
1257 else {
1258 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1259 }
1260
1261 String sql = query.toString();
1262
1263 Session session = null;
1264
1265 try {
1266 session = openSession();
1267
1268 Query q = session.createQuery(sql);
1269
1270 QueryPos qPos = QueryPos.getInstance(q);
1271
1272 qPos.add(folderId);
1273
1274 list = (List<IGImage>)QueryUtil.list(q, getDialect(), start, end);
1275 }
1276 catch (Exception e) {
1277 throw processException(e);
1278 }
1279 finally {
1280 if (list == null) {
1281 list = new ArrayList<IGImage>();
1282 }
1283
1284 cacheResult(list);
1285
1286 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FOLDERID,
1287 finderArgs, list);
1288
1289 closeSession(session);
1290 }
1291 }
1292
1293 return list;
1294 }
1295
1296 public IGImage findByFolderId_First(long folderId,
1297 OrderByComparator orderByComparator)
1298 throws NoSuchImageException, SystemException {
1299 List<IGImage> list = findByFolderId(folderId, 0, 1, orderByComparator);
1300
1301 if (list.isEmpty()) {
1302 StringBundler msg = new StringBundler(4);
1303
1304 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1305
1306 msg.append("folderId=");
1307 msg.append(folderId);
1308
1309 msg.append(StringPool.CLOSE_CURLY_BRACE);
1310
1311 throw new NoSuchImageException(msg.toString());
1312 }
1313 else {
1314 return list.get(0);
1315 }
1316 }
1317
1318 public IGImage findByFolderId_Last(long folderId,
1319 OrderByComparator orderByComparator)
1320 throws NoSuchImageException, SystemException {
1321 int count = countByFolderId(folderId);
1322
1323 List<IGImage> list = findByFolderId(folderId, count - 1, count,
1324 orderByComparator);
1325
1326 if (list.isEmpty()) {
1327 StringBundler msg = new StringBundler(4);
1328
1329 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1330
1331 msg.append("folderId=");
1332 msg.append(folderId);
1333
1334 msg.append(StringPool.CLOSE_CURLY_BRACE);
1335
1336 throw new NoSuchImageException(msg.toString());
1337 }
1338 else {
1339 return list.get(0);
1340 }
1341 }
1342
1343 public IGImage[] findByFolderId_PrevAndNext(long imageId, long folderId,
1344 OrderByComparator orderByComparator)
1345 throws NoSuchImageException, SystemException {
1346 IGImage igImage = findByPrimaryKey(imageId);
1347
1348 Session session = null;
1349
1350 try {
1351 session = openSession();
1352
1353 IGImage[] array = new IGImageImpl[3];
1354
1355 array[0] = getByFolderId_PrevAndNext(session, igImage, folderId,
1356 orderByComparator, true);
1357
1358 array[1] = igImage;
1359
1360 array[2] = getByFolderId_PrevAndNext(session, igImage, folderId,
1361 orderByComparator, false);
1362
1363 return array;
1364 }
1365 catch (Exception e) {
1366 throw processException(e);
1367 }
1368 finally {
1369 closeSession(session);
1370 }
1371 }
1372
1373 protected IGImage getByFolderId_PrevAndNext(Session session,
1374 IGImage igImage, long folderId, OrderByComparator orderByComparator,
1375 boolean previous) {
1376 StringBundler query = null;
1377
1378 if (orderByComparator != null) {
1379 query = new StringBundler(6 +
1380 (orderByComparator.getOrderByFields().length * 6));
1381 }
1382 else {
1383 query = new StringBundler(3);
1384 }
1385
1386 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1387
1388 query.append(_FINDER_COLUMN_FOLDERID_FOLDERID_2);
1389
1390 if (orderByComparator != null) {
1391 String[] orderByFields = orderByComparator.getOrderByFields();
1392
1393 if (orderByFields.length > 0) {
1394 query.append(WHERE_AND);
1395 }
1396
1397 for (int i = 0; i < orderByFields.length; i++) {
1398 query.append(_ORDER_BY_ENTITY_ALIAS);
1399 query.append(orderByFields[i]);
1400
1401 if ((i + 1) < orderByFields.length) {
1402 if (orderByComparator.isAscending() ^ previous) {
1403 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1404 }
1405 else {
1406 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1407 }
1408 }
1409 else {
1410 if (orderByComparator.isAscending() ^ previous) {
1411 query.append(WHERE_GREATER_THAN);
1412 }
1413 else {
1414 query.append(WHERE_LESSER_THAN);
1415 }
1416 }
1417 }
1418
1419 query.append(ORDER_BY_CLAUSE);
1420
1421 for (int i = 0; i < orderByFields.length; i++) {
1422 query.append(_ORDER_BY_ENTITY_ALIAS);
1423 query.append(orderByFields[i]);
1424
1425 if ((i + 1) < orderByFields.length) {
1426 if (orderByComparator.isAscending() ^ previous) {
1427 query.append(ORDER_BY_ASC_HAS_NEXT);
1428 }
1429 else {
1430 query.append(ORDER_BY_DESC_HAS_NEXT);
1431 }
1432 }
1433 else {
1434 if (orderByComparator.isAscending() ^ previous) {
1435 query.append(ORDER_BY_ASC);
1436 }
1437 else {
1438 query.append(ORDER_BY_DESC);
1439 }
1440 }
1441 }
1442 }
1443
1444 else {
1445 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1446 }
1447
1448 String sql = query.toString();
1449
1450 Query q = session.createQuery(sql);
1451
1452 q.setFirstResult(0);
1453 q.setMaxResults(2);
1454
1455 QueryPos qPos = QueryPos.getInstance(q);
1456
1457 qPos.add(folderId);
1458
1459 if (orderByComparator != null) {
1460 Object[] values = orderByComparator.getOrderByValues(igImage);
1461
1462 for (Object value : values) {
1463 qPos.add(value);
1464 }
1465 }
1466
1467 List<IGImage> list = q.list();
1468
1469 if (list.size() == 2) {
1470 return list.get(1);
1471 }
1472 else {
1473 return null;
1474 }
1475 }
1476
1477 public IGImage findBySmallImageId(long smallImageId)
1478 throws NoSuchImageException, SystemException {
1479 IGImage igImage = fetchBySmallImageId(smallImageId);
1480
1481 if (igImage == null) {
1482 StringBundler msg = new StringBundler(4);
1483
1484 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1485
1486 msg.append("smallImageId=");
1487 msg.append(smallImageId);
1488
1489 msg.append(StringPool.CLOSE_CURLY_BRACE);
1490
1491 if (_log.isWarnEnabled()) {
1492 _log.warn(msg.toString());
1493 }
1494
1495 throw new NoSuchImageException(msg.toString());
1496 }
1497
1498 return igImage;
1499 }
1500
1501 public IGImage fetchBySmallImageId(long smallImageId)
1502 throws SystemException {
1503 return fetchBySmallImageId(smallImageId, true);
1504 }
1505
1506 public IGImage fetchBySmallImageId(long smallImageId,
1507 boolean retrieveFromCache) throws SystemException {
1508 Object[] finderArgs = new Object[] { smallImageId };
1509
1510 Object result = null;
1511
1512 if (retrieveFromCache) {
1513 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1514 finderArgs, this);
1515 }
1516
1517 if (result == null) {
1518 StringBundler query = new StringBundler(3);
1519
1520 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1521
1522 query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
1523
1524 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1525
1526 String sql = query.toString();
1527
1528 Session session = null;
1529
1530 try {
1531 session = openSession();
1532
1533 Query q = session.createQuery(sql);
1534
1535 QueryPos qPos = QueryPos.getInstance(q);
1536
1537 qPos.add(smallImageId);
1538
1539 List<IGImage> list = q.list();
1540
1541 result = list;
1542
1543 IGImage igImage = null;
1544
1545 if (list.isEmpty()) {
1546 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1547 finderArgs, list);
1548 }
1549 else {
1550 igImage = list.get(0);
1551
1552 cacheResult(igImage);
1553
1554 if ((igImage.getSmallImageId() != smallImageId)) {
1555 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1556 finderArgs, igImage);
1557 }
1558 }
1559
1560 return igImage;
1561 }
1562 catch (Exception e) {
1563 throw processException(e);
1564 }
1565 finally {
1566 if (result == null) {
1567 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SMALLIMAGEID,
1568 finderArgs, new ArrayList<IGImage>());
1569 }
1570
1571 closeSession(session);
1572 }
1573 }
1574 else {
1575 if (result instanceof List<?>) {
1576 return null;
1577 }
1578 else {
1579 return (IGImage)result;
1580 }
1581 }
1582 }
1583
1584 public IGImage findByLargeImageId(long largeImageId)
1585 throws NoSuchImageException, SystemException {
1586 IGImage igImage = fetchByLargeImageId(largeImageId);
1587
1588 if (igImage == null) {
1589 StringBundler msg = new StringBundler(4);
1590
1591 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1592
1593 msg.append("largeImageId=");
1594 msg.append(largeImageId);
1595
1596 msg.append(StringPool.CLOSE_CURLY_BRACE);
1597
1598 if (_log.isWarnEnabled()) {
1599 _log.warn(msg.toString());
1600 }
1601
1602 throw new NoSuchImageException(msg.toString());
1603 }
1604
1605 return igImage;
1606 }
1607
1608 public IGImage fetchByLargeImageId(long largeImageId)
1609 throws SystemException {
1610 return fetchByLargeImageId(largeImageId, true);
1611 }
1612
1613 public IGImage fetchByLargeImageId(long largeImageId,
1614 boolean retrieveFromCache) throws SystemException {
1615 Object[] finderArgs = new Object[] { largeImageId };
1616
1617 Object result = null;
1618
1619 if (retrieveFromCache) {
1620 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
1621 finderArgs, this);
1622 }
1623
1624 if (result == null) {
1625 StringBundler query = new StringBundler(3);
1626
1627 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1628
1629 query.append(_FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2);
1630
1631 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1632
1633 String sql = query.toString();
1634
1635 Session session = null;
1636
1637 try {
1638 session = openSession();
1639
1640 Query q = session.createQuery(sql);
1641
1642 QueryPos qPos = QueryPos.getInstance(q);
1643
1644 qPos.add(largeImageId);
1645
1646 List<IGImage> list = q.list();
1647
1648 result = list;
1649
1650 IGImage igImage = null;
1651
1652 if (list.isEmpty()) {
1653 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
1654 finderArgs, list);
1655 }
1656 else {
1657 igImage = list.get(0);
1658
1659 cacheResult(igImage);
1660
1661 if ((igImage.getLargeImageId() != largeImageId)) {
1662 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
1663 finderArgs, igImage);
1664 }
1665 }
1666
1667 return igImage;
1668 }
1669 catch (Exception e) {
1670 throw processException(e);
1671 }
1672 finally {
1673 if (result == null) {
1674 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LARGEIMAGEID,
1675 finderArgs, new ArrayList<IGImage>());
1676 }
1677
1678 closeSession(session);
1679 }
1680 }
1681 else {
1682 if (result instanceof List<?>) {
1683 return null;
1684 }
1685 else {
1686 return (IGImage)result;
1687 }
1688 }
1689 }
1690
1691 public IGImage findByCustom1ImageId(long custom1ImageId)
1692 throws NoSuchImageException, SystemException {
1693 IGImage igImage = fetchByCustom1ImageId(custom1ImageId);
1694
1695 if (igImage == null) {
1696 StringBundler msg = new StringBundler(4);
1697
1698 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1699
1700 msg.append("custom1ImageId=");
1701 msg.append(custom1ImageId);
1702
1703 msg.append(StringPool.CLOSE_CURLY_BRACE);
1704
1705 if (_log.isWarnEnabled()) {
1706 _log.warn(msg.toString());
1707 }
1708
1709 throw new NoSuchImageException(msg.toString());
1710 }
1711
1712 return igImage;
1713 }
1714
1715 public IGImage fetchByCustom1ImageId(long custom1ImageId)
1716 throws SystemException {
1717 return fetchByCustom1ImageId(custom1ImageId, true);
1718 }
1719
1720 public IGImage fetchByCustom1ImageId(long custom1ImageId,
1721 boolean retrieveFromCache) throws SystemException {
1722 Object[] finderArgs = new Object[] { custom1ImageId };
1723
1724 Object result = null;
1725
1726 if (retrieveFromCache) {
1727 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
1728 finderArgs, this);
1729 }
1730
1731 if (result == null) {
1732 StringBundler query = new StringBundler(3);
1733
1734 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1735
1736 query.append(_FINDER_COLUMN_CUSTOM1IMAGEID_CUSTOM1IMAGEID_2);
1737
1738 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1739
1740 String sql = query.toString();
1741
1742 Session session = null;
1743
1744 try {
1745 session = openSession();
1746
1747 Query q = session.createQuery(sql);
1748
1749 QueryPos qPos = QueryPos.getInstance(q);
1750
1751 qPos.add(custom1ImageId);
1752
1753 List<IGImage> list = q.list();
1754
1755 result = list;
1756
1757 IGImage igImage = null;
1758
1759 if (list.isEmpty()) {
1760 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
1761 finderArgs, list);
1762 }
1763 else {
1764 igImage = list.get(0);
1765
1766 cacheResult(igImage);
1767
1768 if ((igImage.getCustom1ImageId() != custom1ImageId)) {
1769 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
1770 finderArgs, igImage);
1771 }
1772 }
1773
1774 return igImage;
1775 }
1776 catch (Exception e) {
1777 throw processException(e);
1778 }
1779 finally {
1780 if (result == null) {
1781 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM1IMAGEID,
1782 finderArgs, new ArrayList<IGImage>());
1783 }
1784
1785 closeSession(session);
1786 }
1787 }
1788 else {
1789 if (result instanceof List<?>) {
1790 return null;
1791 }
1792 else {
1793 return (IGImage)result;
1794 }
1795 }
1796 }
1797
1798 public IGImage findByCustom2ImageId(long custom2ImageId)
1799 throws NoSuchImageException, SystemException {
1800 IGImage igImage = fetchByCustom2ImageId(custom2ImageId);
1801
1802 if (igImage == null) {
1803 StringBundler msg = new StringBundler(4);
1804
1805 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1806
1807 msg.append("custom2ImageId=");
1808 msg.append(custom2ImageId);
1809
1810 msg.append(StringPool.CLOSE_CURLY_BRACE);
1811
1812 if (_log.isWarnEnabled()) {
1813 _log.warn(msg.toString());
1814 }
1815
1816 throw new NoSuchImageException(msg.toString());
1817 }
1818
1819 return igImage;
1820 }
1821
1822 public IGImage fetchByCustom2ImageId(long custom2ImageId)
1823 throws SystemException {
1824 return fetchByCustom2ImageId(custom2ImageId, true);
1825 }
1826
1827 public IGImage fetchByCustom2ImageId(long custom2ImageId,
1828 boolean retrieveFromCache) throws SystemException {
1829 Object[] finderArgs = new Object[] { custom2ImageId };
1830
1831 Object result = null;
1832
1833 if (retrieveFromCache) {
1834 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
1835 finderArgs, this);
1836 }
1837
1838 if (result == null) {
1839 StringBundler query = new StringBundler(3);
1840
1841 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1842
1843 query.append(_FINDER_COLUMN_CUSTOM2IMAGEID_CUSTOM2IMAGEID_2);
1844
1845 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1846
1847 String sql = query.toString();
1848
1849 Session session = null;
1850
1851 try {
1852 session = openSession();
1853
1854 Query q = session.createQuery(sql);
1855
1856 QueryPos qPos = QueryPos.getInstance(q);
1857
1858 qPos.add(custom2ImageId);
1859
1860 List<IGImage> list = q.list();
1861
1862 result = list;
1863
1864 IGImage igImage = null;
1865
1866 if (list.isEmpty()) {
1867 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
1868 finderArgs, list);
1869 }
1870 else {
1871 igImage = list.get(0);
1872
1873 cacheResult(igImage);
1874
1875 if ((igImage.getCustom2ImageId() != custom2ImageId)) {
1876 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
1877 finderArgs, igImage);
1878 }
1879 }
1880
1881 return igImage;
1882 }
1883 catch (Exception e) {
1884 throw processException(e);
1885 }
1886 finally {
1887 if (result == null) {
1888 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CUSTOM2IMAGEID,
1889 finderArgs, new ArrayList<IGImage>());
1890 }
1891
1892 closeSession(session);
1893 }
1894 }
1895 else {
1896 if (result instanceof List<?>) {
1897 return null;
1898 }
1899 else {
1900 return (IGImage)result;
1901 }
1902 }
1903 }
1904
1905 public List<IGImage> findByG_U(long groupId, long userId)
1906 throws SystemException {
1907 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1908 null);
1909 }
1910
1911 public List<IGImage> findByG_U(long groupId, long userId, int start, int end)
1912 throws SystemException {
1913 return findByG_U(groupId, userId, start, end, null);
1914 }
1915
1916 public List<IGImage> findByG_U(long groupId, long userId, int start,
1917 int end, OrderByComparator orderByComparator) throws SystemException {
1918 Object[] finderArgs = new Object[] {
1919 groupId, userId,
1920
1921 String.valueOf(start), String.valueOf(end),
1922 String.valueOf(orderByComparator)
1923 };
1924
1925 List<IGImage> list = (List<IGImage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
1926 finderArgs, this);
1927
1928 if (list == null) {
1929 StringBundler query = null;
1930
1931 if (orderByComparator != null) {
1932 query = new StringBundler(4 +
1933 (orderByComparator.getOrderByFields().length * 3));
1934 }
1935 else {
1936 query = new StringBundler(4);
1937 }
1938
1939 query.append(_SQL_SELECT_IGIMAGE_WHERE);
1940
1941 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1942
1943 query.append(_FINDER_COLUMN_G_U_USERID_2);
1944
1945 if (orderByComparator != null) {
1946 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1947 orderByComparator);
1948 }
1949
1950 else {
1951 query.append(IGImageModelImpl.ORDER_BY_JPQL);
1952 }
1953
1954 String sql = query.toString();
1955
1956 Session session = null;
1957
1958 try {
1959 session = openSession();
1960
1961 Query q = session.createQuery(sql);
1962
1963 QueryPos qPos = QueryPos.getInstance(q);
1964
1965 qPos.add(groupId);
1966
1967 qPos.add(userId);
1968
1969 list = (List<IGImage>)QueryUtil.list(q, getDialect(), start, end);
1970 }
1971 catch (Exception e) {
1972 throw processException(e);
1973 }
1974 finally {
1975 if (list == null) {
1976 list = new ArrayList<IGImage>();
1977 }
1978
1979 cacheResult(list);
1980
1981 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1982 list);
1983
1984 closeSession(session);
1985 }
1986 }
1987
1988 return list;
1989 }
1990
1991 public IGImage findByG_U_First(long groupId, long userId,
1992 OrderByComparator orderByComparator)
1993 throws NoSuchImageException, SystemException {
1994 List<IGImage> list = findByG_U(groupId, userId, 0, 1, orderByComparator);
1995
1996 if (list.isEmpty()) {
1997 StringBundler msg = new StringBundler(6);
1998
1999 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2000
2001 msg.append("groupId=");
2002 msg.append(groupId);
2003
2004 msg.append(", userId=");
2005 msg.append(userId);
2006
2007 msg.append(StringPool.CLOSE_CURLY_BRACE);
2008
2009 throw new NoSuchImageException(msg.toString());
2010 }
2011 else {
2012 return list.get(0);
2013 }
2014 }
2015
2016 public IGImage findByG_U_Last(long groupId, long userId,
2017 OrderByComparator orderByComparator)
2018 throws NoSuchImageException, SystemException {
2019 int count = countByG_U(groupId, userId);
2020
2021 List<IGImage> list = findByG_U(groupId, userId, count - 1, count,
2022 orderByComparator);
2023
2024 if (list.isEmpty()) {
2025 StringBundler msg = new StringBundler(6);
2026
2027 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2028
2029 msg.append("groupId=");
2030 msg.append(groupId);
2031
2032 msg.append(", userId=");
2033 msg.append(userId);
2034
2035 msg.append(StringPool.CLOSE_CURLY_BRACE);
2036
2037 throw new NoSuchImageException(msg.toString());
2038 }
2039 else {
2040 return list.get(0);
2041 }
2042 }
2043
2044 public IGImage[] findByG_U_PrevAndNext(long imageId, long groupId,
2045 long userId, OrderByComparator orderByComparator)
2046 throws NoSuchImageException, SystemException {
2047 IGImage igImage = findByPrimaryKey(imageId);
2048
2049 Session session = null;
2050
2051 try {
2052 session = openSession();
2053
2054 IGImage[] array = new IGImageImpl[3];
2055
2056 array[0] = getByG_U_PrevAndNext(session, igImage, groupId, userId,
2057 orderByComparator, true);
2058
2059 array[1] = igImage;
2060
2061 array[2] = getByG_U_PrevAndNext(session, igImage, groupId, userId,
2062 orderByComparator, false);
2063
2064 return array;
2065 }
2066 catch (Exception e) {
2067 throw processException(e);
2068 }
2069 finally {
2070 closeSession(session);
2071 }
2072 }
2073
2074 protected IGImage getByG_U_PrevAndNext(Session session, IGImage igImage,
2075 long groupId, long userId, OrderByComparator orderByComparator,
2076 boolean previous) {
2077 StringBundler query = null;
2078
2079 if (orderByComparator != null) {
2080 query = new StringBundler(6 +
2081 (orderByComparator.getOrderByFields().length * 6));
2082 }
2083 else {
2084 query = new StringBundler(3);
2085 }
2086
2087 query.append(_SQL_SELECT_IGIMAGE_WHERE);
2088
2089 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2090
2091 query.append(_FINDER_COLUMN_G_U_USERID_2);
2092
2093 if (orderByComparator != null) {
2094 String[] orderByFields = orderByComparator.getOrderByFields();
2095
2096 if (orderByFields.length > 0) {
2097 query.append(WHERE_AND);
2098 }
2099
2100 for (int i = 0; i < orderByFields.length; i++) {
2101 query.append(_ORDER_BY_ENTITY_ALIAS);
2102 query.append(orderByFields[i]);
2103
2104 if ((i + 1) < orderByFields.length) {
2105 if (orderByComparator.isAscending() ^ previous) {
2106 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2107 }
2108 else {
2109 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2110 }
2111 }
2112 else {
2113 if (orderByComparator.isAscending() ^ previous) {
2114 query.append(WHERE_GREATER_THAN);
2115 }
2116 else {
2117 query.append(WHERE_LESSER_THAN);
2118 }
2119 }
2120 }
2121
2122 query.append(ORDER_BY_CLAUSE);
2123
2124 for (int i = 0; i < orderByFields.length; i++) {
2125 query.append(_ORDER_BY_ENTITY_ALIAS);
2126 query.append(orderByFields[i]);
2127
2128 if ((i + 1) < orderByFields.length) {
2129 if (orderByComparator.isAscending() ^ previous) {
2130 query.append(ORDER_BY_ASC_HAS_NEXT);
2131 }
2132 else {
2133 query.append(ORDER_BY_DESC_HAS_NEXT);
2134 }
2135 }
2136 else {
2137 if (orderByComparator.isAscending() ^ previous) {
2138 query.append(ORDER_BY_ASC);
2139 }
2140 else {
2141 query.append(ORDER_BY_DESC);
2142 }
2143 }
2144 }
2145 }
2146
2147 else {
2148 query.append(IGImageModelImpl.ORDER_BY_JPQL);
2149 }
2150
2151 String sql = query.toString();
2152
2153 Query q = session.createQuery(sql);
2154
2155 q.setFirstResult(0);
2156 q.setMaxResults(2);
2157
2158 QueryPos qPos = QueryPos.getInstance(q);
2159
2160 qPos.add(groupId);
2161
2162 qPos.add(userId);
2163
2164 if (orderByComparator != null) {
2165 Object[] values = orderByComparator.getOrderByValues(igImage);
2166
2167 for (Object value : values) {
2168 qPos.add(value);
2169 }
2170 }
2171
2172 List<IGImage> list = q.list();
2173
2174 if (list.size() == 2) {
2175 return list.get(1);
2176 }
2177 else {
2178 return null;
2179 }
2180 }
2181
2182 public List<IGImage> findByF_N(long folderId, String name)
2183 throws SystemException {
2184 return findByF_N(folderId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2185 null);
2186 }
2187
2188 public List<IGImage> findByF_N(long folderId, String name, int start,
2189 int end) throws SystemException {
2190 return findByF_N(folderId, name, start, end, null);
2191 }
2192
2193 public List<IGImage> findByF_N(long folderId, String name, int start,
2194 int end, OrderByComparator orderByComparator) throws SystemException {
2195 Object[] finderArgs = new Object[] {
2196 folderId, name,
2197
2198 String.valueOf(start), String.valueOf(end),
2199 String.valueOf(orderByComparator)
2200 };
2201
2202 List<IGImage> list = (List<IGImage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_F_N,
2203 finderArgs, this);
2204
2205 if (list == null) {
2206 StringBundler query = null;
2207
2208 if (orderByComparator != null) {
2209 query = new StringBundler(4 +
2210 (orderByComparator.getOrderByFields().length * 3));
2211 }
2212 else {
2213 query = new StringBundler(4);
2214 }
2215
2216 query.append(_SQL_SELECT_IGIMAGE_WHERE);
2217
2218 query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
2219
2220 if (name == null) {
2221 query.append(_FINDER_COLUMN_F_N_NAME_1);
2222 }
2223 else {
2224 if (name.equals(StringPool.BLANK)) {
2225 query.append(_FINDER_COLUMN_F_N_NAME_3);
2226 }
2227 else {
2228 query.append(_FINDER_COLUMN_F_N_NAME_2);
2229 }
2230 }
2231
2232 if (orderByComparator != null) {
2233 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2234 orderByComparator);
2235 }
2236
2237 else {
2238 query.append(IGImageModelImpl.ORDER_BY_JPQL);
2239 }
2240
2241 String sql = query.toString();
2242
2243 Session session = null;
2244
2245 try {
2246 session = openSession();
2247
2248 Query q = session.createQuery(sql);
2249
2250 QueryPos qPos = QueryPos.getInstance(q);
2251
2252 qPos.add(folderId);
2253
2254 if (name != null) {
2255 qPos.add(name);
2256 }
2257
2258 list = (List<IGImage>)QueryUtil.list(q, getDialect(), start, end);
2259 }
2260 catch (Exception e) {
2261 throw processException(e);
2262 }
2263 finally {
2264 if (list == null) {
2265 list = new ArrayList<IGImage>();
2266 }
2267
2268 cacheResult(list);
2269
2270 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_F_N, finderArgs,
2271 list);
2272
2273 closeSession(session);
2274 }
2275 }
2276
2277 return list;
2278 }
2279
2280 public IGImage findByF_N_First(long folderId, String name,
2281 OrderByComparator orderByComparator)
2282 throws NoSuchImageException, SystemException {
2283 List<IGImage> list = findByF_N(folderId, name, 0, 1, orderByComparator);
2284
2285 if (list.isEmpty()) {
2286 StringBundler msg = new StringBundler(6);
2287
2288 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2289
2290 msg.append("folderId=");
2291 msg.append(folderId);
2292
2293 msg.append(", name=");
2294 msg.append(name);
2295
2296 msg.append(StringPool.CLOSE_CURLY_BRACE);
2297
2298 throw new NoSuchImageException(msg.toString());
2299 }
2300 else {
2301 return list.get(0);
2302 }
2303 }
2304
2305 public IGImage findByF_N_Last(long folderId, String name,
2306 OrderByComparator orderByComparator)
2307 throws NoSuchImageException, SystemException {
2308 int count = countByF_N(folderId, name);
2309
2310 List<IGImage> list = findByF_N(folderId, name, count - 1, count,
2311 orderByComparator);
2312
2313 if (list.isEmpty()) {
2314 StringBundler msg = new StringBundler(6);
2315
2316 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2317
2318 msg.append("folderId=");
2319 msg.append(folderId);
2320
2321 msg.append(", name=");
2322 msg.append(name);
2323
2324 msg.append(StringPool.CLOSE_CURLY_BRACE);
2325
2326 throw new NoSuchImageException(msg.toString());
2327 }
2328 else {
2329 return list.get(0);
2330 }
2331 }
2332
2333 public IGImage[] findByF_N_PrevAndNext(long imageId, long folderId,
2334 String name, OrderByComparator orderByComparator)
2335 throws NoSuchImageException, SystemException {
2336 IGImage igImage = findByPrimaryKey(imageId);
2337
2338 Session session = null;
2339
2340 try {
2341 session = openSession();
2342
2343 IGImage[] array = new IGImageImpl[3];
2344
2345 array[0] = getByF_N_PrevAndNext(session, igImage, folderId, name,
2346 orderByComparator, true);
2347
2348 array[1] = igImage;
2349
2350 array[2] = getByF_N_PrevAndNext(session, igImage, folderId, name,
2351 orderByComparator, false);
2352
2353 return array;
2354 }
2355 catch (Exception e) {
2356 throw processException(e);
2357 }
2358 finally {
2359 closeSession(session);
2360 }
2361 }
2362
2363 protected IGImage getByF_N_PrevAndNext(Session session, IGImage igImage,
2364 long folderId, String name, OrderByComparator orderByComparator,
2365 boolean previous) {
2366 StringBundler query = null;
2367
2368 if (orderByComparator != null) {
2369 query = new StringBundler(6 +
2370 (orderByComparator.getOrderByFields().length * 6));
2371 }
2372 else {
2373 query = new StringBundler(3);
2374 }
2375
2376 query.append(_SQL_SELECT_IGIMAGE_WHERE);
2377
2378 query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
2379
2380 if (name == null) {
2381 query.append(_FINDER_COLUMN_F_N_NAME_1);
2382 }
2383 else {
2384 if (name.equals(StringPool.BLANK)) {
2385 query.append(_FINDER_COLUMN_F_N_NAME_3);
2386 }
2387 else {
2388 query.append(_FINDER_COLUMN_F_N_NAME_2);
2389 }
2390 }
2391
2392 if (orderByComparator != null) {
2393 String[] orderByFields = orderByComparator.getOrderByFields();
2394
2395 if (orderByFields.length > 0) {
2396 query.append(WHERE_AND);
2397 }
2398
2399 for (int i = 0; i < orderByFields.length; i++) {
2400 query.append(_ORDER_BY_ENTITY_ALIAS);
2401 query.append(orderByFields[i]);
2402
2403 if ((i + 1) < orderByFields.length) {
2404 if (orderByComparator.isAscending() ^ previous) {
2405 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2406 }
2407 else {
2408 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2409 }
2410 }
2411 else {
2412 if (orderByComparator.isAscending() ^ previous) {
2413 query.append(WHERE_GREATER_THAN);
2414 }
2415 else {
2416 query.append(WHERE_LESSER_THAN);
2417 }
2418 }
2419 }
2420
2421 query.append(ORDER_BY_CLAUSE);
2422
2423 for (int i = 0; i < orderByFields.length; i++) {
2424 query.append(_ORDER_BY_ENTITY_ALIAS);
2425 query.append(orderByFields[i]);
2426
2427 if ((i + 1) < orderByFields.length) {
2428 if (orderByComparator.isAscending() ^ previous) {
2429 query.append(ORDER_BY_ASC_HAS_NEXT);
2430 }
2431 else {
2432 query.append(ORDER_BY_DESC_HAS_NEXT);
2433 }
2434 }
2435 else {
2436 if (orderByComparator.isAscending() ^ previous) {
2437 query.append(ORDER_BY_ASC);
2438 }
2439 else {
2440 query.append(ORDER_BY_DESC);
2441 }
2442 }
2443 }
2444 }
2445
2446 else {
2447 query.append(IGImageModelImpl.ORDER_BY_JPQL);
2448 }
2449
2450 String sql = query.toString();
2451
2452 Query q = session.createQuery(sql);
2453
2454 q.setFirstResult(0);
2455 q.setMaxResults(2);
2456
2457 QueryPos qPos = QueryPos.getInstance(q);
2458
2459 qPos.add(folderId);
2460
2461 if (name != null) {
2462 qPos.add(name);
2463 }
2464
2465 if (orderByComparator != null) {
2466 Object[] values = orderByComparator.getOrderByValues(igImage);
2467
2468 for (Object value : values) {
2469 qPos.add(value);
2470 }
2471 }
2472
2473 List<IGImage> list = q.list();
2474
2475 if (list.size() == 2) {
2476 return list.get(1);
2477 }
2478 else {
2479 return null;
2480 }
2481 }
2482
2483 public List<IGImage> findAll() throws SystemException {
2484 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2485 }
2486
2487 public List<IGImage> findAll(int start, int end) throws SystemException {
2488 return findAll(start, end, null);
2489 }
2490
2491 public List<IGImage> findAll(int start, int end,
2492 OrderByComparator orderByComparator) throws SystemException {
2493 Object[] finderArgs = new Object[] {
2494 String.valueOf(start), String.valueOf(end),
2495 String.valueOf(orderByComparator)
2496 };
2497
2498 List<IGImage> list = (List<IGImage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2499 finderArgs, this);
2500
2501 if (list == null) {
2502 StringBundler query = null;
2503 String sql = null;
2504
2505 if (orderByComparator != null) {
2506 query = new StringBundler(2 +
2507 (orderByComparator.getOrderByFields().length * 3));
2508
2509 query.append(_SQL_SELECT_IGIMAGE);
2510
2511 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2512 orderByComparator);
2513
2514 sql = query.toString();
2515 }
2516 else {
2517 sql = _SQL_SELECT_IGIMAGE.concat(IGImageModelImpl.ORDER_BY_JPQL);
2518 }
2519
2520 Session session = null;
2521
2522 try {
2523 session = openSession();
2524
2525 Query q = session.createQuery(sql);
2526
2527 if (orderByComparator == null) {
2528 list = (List<IGImage>)QueryUtil.list(q, getDialect(),
2529 start, end, false);
2530
2531 Collections.sort(list);
2532 }
2533 else {
2534 list = (List<IGImage>)QueryUtil.list(q, getDialect(),
2535 start, end);
2536 }
2537 }
2538 catch (Exception e) {
2539 throw processException(e);
2540 }
2541 finally {
2542 if (list == null) {
2543 list = new ArrayList<IGImage>();
2544 }
2545
2546 cacheResult(list);
2547
2548 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2549
2550 closeSession(session);
2551 }
2552 }
2553
2554 return list;
2555 }
2556
2557 public void removeByUuid(String uuid) throws SystemException {
2558 for (IGImage igImage : findByUuid(uuid)) {
2559 remove(igImage);
2560 }
2561 }
2562
2563 public void removeByUUID_G(String uuid, long groupId)
2564 throws NoSuchImageException, SystemException {
2565 IGImage igImage = findByUUID_G(uuid, groupId);
2566
2567 remove(igImage);
2568 }
2569
2570 public void removeByGroupId(long groupId) throws SystemException {
2571 for (IGImage igImage : findByGroupId(groupId)) {
2572 remove(igImage);
2573 }
2574 }
2575
2576 public void removeByFolderId(long folderId) throws SystemException {
2577 for (IGImage igImage : findByFolderId(folderId)) {
2578 remove(igImage);
2579 }
2580 }
2581
2582 public void removeBySmallImageId(long smallImageId)
2583 throws NoSuchImageException, SystemException {
2584 IGImage igImage = findBySmallImageId(smallImageId);
2585
2586 remove(igImage);
2587 }
2588
2589 public void removeByLargeImageId(long largeImageId)
2590 throws NoSuchImageException, SystemException {
2591 IGImage igImage = findByLargeImageId(largeImageId);
2592
2593 remove(igImage);
2594 }
2595
2596 public void removeByCustom1ImageId(long custom1ImageId)
2597 throws NoSuchImageException, SystemException {
2598 IGImage igImage = findByCustom1ImageId(custom1ImageId);
2599
2600 remove(igImage);
2601 }
2602
2603 public void removeByCustom2ImageId(long custom2ImageId)
2604 throws NoSuchImageException, SystemException {
2605 IGImage igImage = findByCustom2ImageId(custom2ImageId);
2606
2607 remove(igImage);
2608 }
2609
2610 public void removeByG_U(long groupId, long userId)
2611 throws SystemException {
2612 for (IGImage igImage : findByG_U(groupId, userId)) {
2613 remove(igImage);
2614 }
2615 }
2616
2617 public void removeByF_N(long folderId, String name)
2618 throws SystemException {
2619 for (IGImage igImage : findByF_N(folderId, name)) {
2620 remove(igImage);
2621 }
2622 }
2623
2624 public void removeAll() throws SystemException {
2625 for (IGImage igImage : findAll()) {
2626 remove(igImage);
2627 }
2628 }
2629
2630 public int countByUuid(String uuid) throws SystemException {
2631 Object[] finderArgs = new Object[] { uuid };
2632
2633 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2634 finderArgs, this);
2635
2636 if (count == null) {
2637 StringBundler query = new StringBundler(2);
2638
2639 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2640
2641 if (uuid == null) {
2642 query.append(_FINDER_COLUMN_UUID_UUID_1);
2643 }
2644 else {
2645 if (uuid.equals(StringPool.BLANK)) {
2646 query.append(_FINDER_COLUMN_UUID_UUID_3);
2647 }
2648 else {
2649 query.append(_FINDER_COLUMN_UUID_UUID_2);
2650 }
2651 }
2652
2653 String sql = query.toString();
2654
2655 Session session = null;
2656
2657 try {
2658 session = openSession();
2659
2660 Query q = session.createQuery(sql);
2661
2662 QueryPos qPos = QueryPos.getInstance(q);
2663
2664 if (uuid != null) {
2665 qPos.add(uuid);
2666 }
2667
2668 count = (Long)q.uniqueResult();
2669 }
2670 catch (Exception e) {
2671 throw processException(e);
2672 }
2673 finally {
2674 if (count == null) {
2675 count = Long.valueOf(0);
2676 }
2677
2678 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2679 finderArgs, count);
2680
2681 closeSession(session);
2682 }
2683 }
2684
2685 return count.intValue();
2686 }
2687
2688 public int countByUUID_G(String uuid, long groupId)
2689 throws SystemException {
2690 Object[] finderArgs = new Object[] { uuid, groupId };
2691
2692 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2693 finderArgs, this);
2694
2695 if (count == null) {
2696 StringBundler query = new StringBundler(3);
2697
2698 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2699
2700 if (uuid == null) {
2701 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2702 }
2703 else {
2704 if (uuid.equals(StringPool.BLANK)) {
2705 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2706 }
2707 else {
2708 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2709 }
2710 }
2711
2712 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2713
2714 String sql = query.toString();
2715
2716 Session session = null;
2717
2718 try {
2719 session = openSession();
2720
2721 Query q = session.createQuery(sql);
2722
2723 QueryPos qPos = QueryPos.getInstance(q);
2724
2725 if (uuid != null) {
2726 qPos.add(uuid);
2727 }
2728
2729 qPos.add(groupId);
2730
2731 count = (Long)q.uniqueResult();
2732 }
2733 catch (Exception e) {
2734 throw processException(e);
2735 }
2736 finally {
2737 if (count == null) {
2738 count = Long.valueOf(0);
2739 }
2740
2741 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2742 finderArgs, count);
2743
2744 closeSession(session);
2745 }
2746 }
2747
2748 return count.intValue();
2749 }
2750
2751 public int countByGroupId(long groupId) throws SystemException {
2752 Object[] finderArgs = new Object[] { groupId };
2753
2754 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2755 finderArgs, this);
2756
2757 if (count == null) {
2758 StringBundler query = new StringBundler(2);
2759
2760 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2761
2762 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2763
2764 String sql = query.toString();
2765
2766 Session session = null;
2767
2768 try {
2769 session = openSession();
2770
2771 Query q = session.createQuery(sql);
2772
2773 QueryPos qPos = QueryPos.getInstance(q);
2774
2775 qPos.add(groupId);
2776
2777 count = (Long)q.uniqueResult();
2778 }
2779 catch (Exception e) {
2780 throw processException(e);
2781 }
2782 finally {
2783 if (count == null) {
2784 count = Long.valueOf(0);
2785 }
2786
2787 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2788 finderArgs, count);
2789
2790 closeSession(session);
2791 }
2792 }
2793
2794 return count.intValue();
2795 }
2796
2797 public int countByFolderId(long folderId) throws SystemException {
2798 Object[] finderArgs = new Object[] { folderId };
2799
2800 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FOLDERID,
2801 finderArgs, this);
2802
2803 if (count == null) {
2804 StringBundler query = new StringBundler(2);
2805
2806 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2807
2808 query.append(_FINDER_COLUMN_FOLDERID_FOLDERID_2);
2809
2810 String sql = query.toString();
2811
2812 Session session = null;
2813
2814 try {
2815 session = openSession();
2816
2817 Query q = session.createQuery(sql);
2818
2819 QueryPos qPos = QueryPos.getInstance(q);
2820
2821 qPos.add(folderId);
2822
2823 count = (Long)q.uniqueResult();
2824 }
2825 catch (Exception e) {
2826 throw processException(e);
2827 }
2828 finally {
2829 if (count == null) {
2830 count = Long.valueOf(0);
2831 }
2832
2833 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FOLDERID,
2834 finderArgs, count);
2835
2836 closeSession(session);
2837 }
2838 }
2839
2840 return count.intValue();
2841 }
2842
2843 public int countBySmallImageId(long smallImageId) throws SystemException {
2844 Object[] finderArgs = new Object[] { smallImageId };
2845
2846 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
2847 finderArgs, this);
2848
2849 if (count == null) {
2850 StringBundler query = new StringBundler(2);
2851
2852 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2853
2854 query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
2855
2856 String sql = query.toString();
2857
2858 Session session = null;
2859
2860 try {
2861 session = openSession();
2862
2863 Query q = session.createQuery(sql);
2864
2865 QueryPos qPos = QueryPos.getInstance(q);
2866
2867 qPos.add(smallImageId);
2868
2869 count = (Long)q.uniqueResult();
2870 }
2871 catch (Exception e) {
2872 throw processException(e);
2873 }
2874 finally {
2875 if (count == null) {
2876 count = Long.valueOf(0);
2877 }
2878
2879 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
2880 finderArgs, count);
2881
2882 closeSession(session);
2883 }
2884 }
2885
2886 return count.intValue();
2887 }
2888
2889 public int countByLargeImageId(long largeImageId) throws SystemException {
2890 Object[] finderArgs = new Object[] { largeImageId };
2891
2892 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LARGEIMAGEID,
2893 finderArgs, this);
2894
2895 if (count == null) {
2896 StringBundler query = new StringBundler(2);
2897
2898 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2899
2900 query.append(_FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2);
2901
2902 String sql = query.toString();
2903
2904 Session session = null;
2905
2906 try {
2907 session = openSession();
2908
2909 Query q = session.createQuery(sql);
2910
2911 QueryPos qPos = QueryPos.getInstance(q);
2912
2913 qPos.add(largeImageId);
2914
2915 count = (Long)q.uniqueResult();
2916 }
2917 catch (Exception e) {
2918 throw processException(e);
2919 }
2920 finally {
2921 if (count == null) {
2922 count = Long.valueOf(0);
2923 }
2924
2925 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LARGEIMAGEID,
2926 finderArgs, count);
2927
2928 closeSession(session);
2929 }
2930 }
2931
2932 return count.intValue();
2933 }
2934
2935 public int countByCustom1ImageId(long custom1ImageId)
2936 throws SystemException {
2937 Object[] finderArgs = new Object[] { custom1ImageId };
2938
2939 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CUSTOM1IMAGEID,
2940 finderArgs, this);
2941
2942 if (count == null) {
2943 StringBundler query = new StringBundler(2);
2944
2945 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2946
2947 query.append(_FINDER_COLUMN_CUSTOM1IMAGEID_CUSTOM1IMAGEID_2);
2948
2949 String sql = query.toString();
2950
2951 Session session = null;
2952
2953 try {
2954 session = openSession();
2955
2956 Query q = session.createQuery(sql);
2957
2958 QueryPos qPos = QueryPos.getInstance(q);
2959
2960 qPos.add(custom1ImageId);
2961
2962 count = (Long)q.uniqueResult();
2963 }
2964 catch (Exception e) {
2965 throw processException(e);
2966 }
2967 finally {
2968 if (count == null) {
2969 count = Long.valueOf(0);
2970 }
2971
2972 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CUSTOM1IMAGEID,
2973 finderArgs, count);
2974
2975 closeSession(session);
2976 }
2977 }
2978
2979 return count.intValue();
2980 }
2981
2982 public int countByCustom2ImageId(long custom2ImageId)
2983 throws SystemException {
2984 Object[] finderArgs = new Object[] { custom2ImageId };
2985
2986 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CUSTOM2IMAGEID,
2987 finderArgs, this);
2988
2989 if (count == null) {
2990 StringBundler query = new StringBundler(2);
2991
2992 query.append(_SQL_COUNT_IGIMAGE_WHERE);
2993
2994 query.append(_FINDER_COLUMN_CUSTOM2IMAGEID_CUSTOM2IMAGEID_2);
2995
2996 String sql = query.toString();
2997
2998 Session session = null;
2999
3000 try {
3001 session = openSession();
3002
3003 Query q = session.createQuery(sql);
3004
3005 QueryPos qPos = QueryPos.getInstance(q);
3006
3007 qPos.add(custom2ImageId);
3008
3009 count = (Long)q.uniqueResult();
3010 }
3011 catch (Exception e) {
3012 throw processException(e);
3013 }
3014 finally {
3015 if (count == null) {
3016 count = Long.valueOf(0);
3017 }
3018
3019 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CUSTOM2IMAGEID,
3020 finderArgs, count);
3021
3022 closeSession(session);
3023 }
3024 }
3025
3026 return count.intValue();
3027 }
3028
3029 public int countByG_U(long groupId, long userId) throws SystemException {
3030 Object[] finderArgs = new Object[] { groupId, userId };
3031
3032 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
3033 finderArgs, this);
3034
3035 if (count == null) {
3036 StringBundler query = new StringBundler(3);
3037
3038 query.append(_SQL_COUNT_IGIMAGE_WHERE);
3039
3040 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
3041
3042 query.append(_FINDER_COLUMN_G_U_USERID_2);
3043
3044 String sql = query.toString();
3045
3046 Session session = null;
3047
3048 try {
3049 session = openSession();
3050
3051 Query q = session.createQuery(sql);
3052
3053 QueryPos qPos = QueryPos.getInstance(q);
3054
3055 qPos.add(groupId);
3056
3057 qPos.add(userId);
3058
3059 count = (Long)q.uniqueResult();
3060 }
3061 catch (Exception e) {
3062 throw processException(e);
3063 }
3064 finally {
3065 if (count == null) {
3066 count = Long.valueOf(0);
3067 }
3068
3069 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
3070 count);
3071
3072 closeSession(session);
3073 }
3074 }
3075
3076 return count.intValue();
3077 }
3078
3079 public int countByF_N(long folderId, String name) throws SystemException {
3080 Object[] finderArgs = new Object[] { folderId, name };
3081
3082 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_N,
3083 finderArgs, this);
3084
3085 if (count == null) {
3086 StringBundler query = new StringBundler(3);
3087
3088 query.append(_SQL_COUNT_IGIMAGE_WHERE);
3089
3090 query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
3091
3092 if (name == null) {
3093 query.append(_FINDER_COLUMN_F_N_NAME_1);
3094 }
3095 else {
3096 if (name.equals(StringPool.BLANK)) {
3097 query.append(_FINDER_COLUMN_F_N_NAME_3);
3098 }
3099 else {
3100 query.append(_FINDER_COLUMN_F_N_NAME_2);
3101 }
3102 }
3103
3104 String sql = query.toString();
3105
3106 Session session = null;
3107
3108 try {
3109 session = openSession();
3110
3111 Query q = session.createQuery(sql);
3112
3113 QueryPos qPos = QueryPos.getInstance(q);
3114
3115 qPos.add(folderId);
3116
3117 if (name != null) {
3118 qPos.add(name);
3119 }
3120
3121 count = (Long)q.uniqueResult();
3122 }
3123 catch (Exception e) {
3124 throw processException(e);
3125 }
3126 finally {
3127 if (count == null) {
3128 count = Long.valueOf(0);
3129 }
3130
3131 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_N, finderArgs,
3132 count);
3133
3134 closeSession(session);
3135 }
3136 }
3137
3138 return count.intValue();
3139 }
3140
3141 public int countAll() throws SystemException {
3142 Object[] finderArgs = new Object[0];
3143
3144 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3145 finderArgs, this);
3146
3147 if (count == null) {
3148 Session session = null;
3149
3150 try {
3151 session = openSession();
3152
3153 Query q = session.createQuery(_SQL_COUNT_IGIMAGE);
3154
3155 count = (Long)q.uniqueResult();
3156 }
3157 catch (Exception e) {
3158 throw processException(e);
3159 }
3160 finally {
3161 if (count == null) {
3162 count = Long.valueOf(0);
3163 }
3164
3165 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3166 count);
3167
3168 closeSession(session);
3169 }
3170 }
3171
3172 return count.intValue();
3173 }
3174
3175 public void afterPropertiesSet() {
3176 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3177 com.liferay.portal.util.PropsUtil.get(
3178 "value.object.listener.com.liferay.portlet.imagegallery.model.IGImage")));
3179
3180 if (listenerClassNames.length > 0) {
3181 try {
3182 List<ModelListener<IGImage>> listenersList = new ArrayList<ModelListener<IGImage>>();
3183
3184 for (String listenerClassName : listenerClassNames) {
3185 listenersList.add((ModelListener<IGImage>)InstanceFactory.newInstance(
3186 listenerClassName));
3187 }
3188
3189 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3190 }
3191 catch (Exception e) {
3192 _log.error(e);
3193 }
3194 }
3195 }
3196
3197 public void destroy() {
3198 EntityCacheUtil.removeCache(IGImageImpl.class.getName());
3199 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3200 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
3201 }
3202
3203 @BeanReference(type = IGFolderPersistence.class)
3204 protected IGFolderPersistence igFolderPersistence;
3205 @BeanReference(type = IGImagePersistence.class)
3206 protected IGImagePersistence igImagePersistence;
3207 @BeanReference(type = ImagePersistence.class)
3208 protected ImagePersistence imagePersistence;
3209 @BeanReference(type = ResourcePersistence.class)
3210 protected ResourcePersistence resourcePersistence;
3211 @BeanReference(type = UserPersistence.class)
3212 protected UserPersistence userPersistence;
3213 @BeanReference(type = ExpandoValuePersistence.class)
3214 protected ExpandoValuePersistence expandoValuePersistence;
3215 @BeanReference(type = SocialActivityPersistence.class)
3216 protected SocialActivityPersistence socialActivityPersistence;
3217 @BeanReference(type = TagsAssetPersistence.class)
3218 protected TagsAssetPersistence tagsAssetPersistence;
3219 @BeanReference(type = TagsEntryPersistence.class)
3220 protected TagsEntryPersistence tagsEntryPersistence;
3221 private static final String _SQL_SELECT_IGIMAGE = "SELECT igImage FROM IGImage igImage";
3222 private static final String _SQL_SELECT_IGIMAGE_WHERE = "SELECT igImage FROM IGImage igImage WHERE ";
3223 private static final String _SQL_COUNT_IGIMAGE = "SELECT COUNT(igImage) FROM IGImage igImage";
3224 private static final String _SQL_COUNT_IGIMAGE_WHERE = "SELECT COUNT(igImage) FROM IGImage igImage WHERE ";
3225 private static final String _FINDER_COLUMN_UUID_UUID_1 = "igImage.uuid IS NULL";
3226 private static final String _FINDER_COLUMN_UUID_UUID_2 = "igImage.uuid = ?";
3227 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(igImage.uuid IS NULL OR igImage.uuid = ?)";
3228 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "igImage.uuid IS NULL AND ";
3229 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "igImage.uuid = ? AND ";
3230 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(igImage.uuid IS NULL OR igImage.uuid = ?) AND ";
3231 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "igImage.groupId = ?";
3232 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "igImage.groupId = ?";
3233 private static final String _FINDER_COLUMN_FOLDERID_FOLDERID_2 = "igImage.folderId = ?";
3234 private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "igImage.smallImageId = ?";
3235 private static final String _FINDER_COLUMN_LARGEIMAGEID_LARGEIMAGEID_2 = "igImage.largeImageId = ?";
3236 private static final String _FINDER_COLUMN_CUSTOM1IMAGEID_CUSTOM1IMAGEID_2 = "igImage.custom1ImageId = ?";
3237 private static final String _FINDER_COLUMN_CUSTOM2IMAGEID_CUSTOM2IMAGEID_2 = "igImage.custom2ImageId = ?";
3238 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "igImage.groupId = ? AND ";
3239 private static final String _FINDER_COLUMN_G_U_USERID_2 = "igImage.userId = ?";
3240 private static final String _FINDER_COLUMN_F_N_FOLDERID_2 = "igImage.folderId = ? AND ";
3241 private static final String _FINDER_COLUMN_F_N_NAME_1 = "igImage.name IS NULL";
3242 private static final String _FINDER_COLUMN_F_N_NAME_2 = "igImage.name = ?";
3243 private static final String _FINDER_COLUMN_F_N_NAME_3 = "(igImage.name IS NULL OR igImage.name = ?)";
3244 private static final String _ORDER_BY_ENTITY_ALIAS = "igImage.";
3245 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No IGImage exists with the primary key ";
3246 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No IGImage exists with the key {";
3247 private static Log _log = LogFactoryUtil.getLog(IGImagePersistenceImpl.class);
3248}