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