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