1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.persistence;
24  
25  import com.liferay.portal.NoSuchImageException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.annotation.BeanReference;
28  import com.liferay.portal.kernel.cache.CacheRegistry;
29  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32  import com.liferay.portal.kernel.dao.orm.FinderPath;
33  import com.liferay.portal.kernel.dao.orm.Query;
34  import com.liferay.portal.kernel.dao.orm.QueryPos;
35  import com.liferay.portal.kernel.dao.orm.QueryUtil;
36  import com.liferay.portal.kernel.dao.orm.Session;
37  import com.liferay.portal.kernel.log.Log;
38  import com.liferay.portal.kernel.log.LogFactoryUtil;
39  import com.liferay.portal.kernel.util.GetterUtil;
40  import com.liferay.portal.kernel.util.OrderByComparator;
41  import com.liferay.portal.kernel.util.StringPool;
42  import com.liferay.portal.kernel.util.StringUtil;
43  import com.liferay.portal.model.Image;
44  import com.liferay.portal.model.ModelListener;
45  import com.liferay.portal.model.impl.ImageImpl;
46  import com.liferay.portal.model.impl.ImageModelImpl;
47  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
48  
49  import java.util.ArrayList;
50  import java.util.Collections;
51  import java.util.List;
52  
53  /**
54   * <a href="ImagePersistenceImpl.java.html"><b><i>View Source</i></b></a>
55   *
56   * <p>
57   * ServiceBuilder generated this class. Modifications in this class will be
58   * overwritten the next time is generated.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       ImagePersistence
63   * @see       ImageUtil
64   * @generated
65   */
66  public class ImagePersistenceImpl extends BasePersistenceImpl
67      implements ImagePersistence {
68      public static final String FINDER_CLASS_NAME_ENTITY = ImageImpl.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_SIZE = new FinderPath(ImageModelImpl.ENTITY_CACHE_ENABLED,
72              ImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
73              "findBySize", new String[] { Integer.class.getName() });
74      public static final FinderPath FINDER_PATH_FIND_BY_OBC_SIZE = new FinderPath(ImageModelImpl.ENTITY_CACHE_ENABLED,
75              ImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
76              "findBySize",
77              new String[] {
78                  Integer.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_SIZE = new FinderPath(ImageModelImpl.ENTITY_CACHE_ENABLED,
84              ImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85              "countBySize", new String[] { Integer.class.getName() });
86      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ImageModelImpl.ENTITY_CACHE_ENABLED,
87              ImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
88              "findAll", new String[0]);
89      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ImageModelImpl.ENTITY_CACHE_ENABLED,
90              ImageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91              "countAll", new String[0]);
92  
93      public void cacheResult(Image image) {
94          EntityCacheUtil.putResult(ImageModelImpl.ENTITY_CACHE_ENABLED,
95              ImageImpl.class, image.getPrimaryKey(), image);
96      }
97  
98      public void cacheResult(List<Image> images) {
99          for (Image image : images) {
100             if (EntityCacheUtil.getResult(ImageModelImpl.ENTITY_CACHE_ENABLED,
101                         ImageImpl.class, image.getPrimaryKey(), this) == null) {
102                 cacheResult(image);
103             }
104         }
105     }
106 
107     public void clearCache() {
108         CacheRegistry.clear(ImageImpl.class.getName());
109         EntityCacheUtil.clearCache(ImageImpl.class.getName());
110         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
111         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
112     }
113 
114     public Image create(long imageId) {
115         Image image = new ImageImpl();
116 
117         image.setNew(true);
118         image.setPrimaryKey(imageId);
119 
120         return image;
121     }
122 
123     public Image remove(long imageId)
124         throws NoSuchImageException, SystemException {
125         Session session = null;
126 
127         try {
128             session = openSession();
129 
130             Image image = (Image)session.get(ImageImpl.class, new Long(imageId));
131 
132             if (image == null) {
133                 if (_log.isWarnEnabled()) {
134                     _log.warn("No Image exists with the primary key " +
135                         imageId);
136                 }
137 
138                 throw new NoSuchImageException(
139                     "No Image exists with the primary key " + imageId);
140             }
141 
142             return remove(image);
143         }
144         catch (NoSuchImageException nsee) {
145             throw nsee;
146         }
147         catch (Exception e) {
148             throw processException(e);
149         }
150         finally {
151             closeSession(session);
152         }
153     }
154 
155     public Image remove(Image image) throws SystemException {
156         for (ModelListener<Image> listener : listeners) {
157             listener.onBeforeRemove(image);
158         }
159 
160         image = removeImpl(image);
161 
162         for (ModelListener<Image> listener : listeners) {
163             listener.onAfterRemove(image);
164         }
165 
166         return image;
167     }
168 
169     protected Image removeImpl(Image image) throws SystemException {
170         image = toUnwrappedModel(image);
171 
172         Session session = null;
173 
174         try {
175             session = openSession();
176 
177             if (image.isCachedModel() || BatchSessionUtil.isEnabled()) {
178                 Object staleObject = session.get(ImageImpl.class,
179                         image.getPrimaryKeyObj());
180 
181                 if (staleObject != null) {
182                     session.evict(staleObject);
183                 }
184             }
185 
186             session.delete(image);
187 
188             session.flush();
189         }
190         catch (Exception e) {
191             throw processException(e);
192         }
193         finally {
194             closeSession(session);
195         }
196 
197         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
198 
199         EntityCacheUtil.removeResult(ImageModelImpl.ENTITY_CACHE_ENABLED,
200             ImageImpl.class, image.getPrimaryKey());
201 
202         return image;
203     }
204 
205     /**
206      * @deprecated Use {@link #update(Image, boolean merge)}.
207      */
208     public Image update(Image image) throws SystemException {
209         if (_log.isWarnEnabled()) {
210             _log.warn(
211                 "Using the deprecated update(Image image) method. Use update(Image image, boolean merge) instead.");
212         }
213 
214         return update(image, false);
215     }
216 
217     /**
218      * Add, update, or merge, the entity. This method also calls the model
219      * listeners to trigger the proper events associated with adding, deleting,
220      * or updating an entity.
221      *
222      * @param  image the entity to add, update, or merge
223      * @param  merge boolean value for whether to merge the entity. The default
224      *         value is false. Setting merge to true is more expensive and
225      *         should only be true when image is transient. See
226      *         LEP-5473 for a detailed discussion of this method.
227      * @return the entity that was added, updated, or merged
228      */
229     public Image update(Image image, boolean merge) throws SystemException {
230         boolean isNew = image.isNew();
231 
232         for (ModelListener<Image> listener : listeners) {
233             if (isNew) {
234                 listener.onBeforeCreate(image);
235             }
236             else {
237                 listener.onBeforeUpdate(image);
238             }
239         }
240 
241         image = updateImpl(image, merge);
242 
243         for (ModelListener<Image> listener : listeners) {
244             if (isNew) {
245                 listener.onAfterCreate(image);
246             }
247             else {
248                 listener.onAfterUpdate(image);
249             }
250         }
251 
252         return image;
253     }
254 
255     public Image updateImpl(com.liferay.portal.model.Image image, boolean merge)
256         throws SystemException {
257         image = toUnwrappedModel(image);
258 
259         Session session = null;
260 
261         try {
262             session = openSession();
263 
264             BatchSessionUtil.update(session, image, merge);
265 
266             image.setNew(false);
267         }
268         catch (Exception e) {
269             throw processException(e);
270         }
271         finally {
272             closeSession(session);
273         }
274 
275         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
276 
277         EntityCacheUtil.putResult(ImageModelImpl.ENTITY_CACHE_ENABLED,
278             ImageImpl.class, image.getPrimaryKey(), image);
279 
280         return image;
281     }
282 
283     protected Image toUnwrappedModel(Image image) {
284         if (image instanceof ImageImpl) {
285             return image;
286         }
287 
288         ImageImpl imageImpl = new ImageImpl();
289 
290         imageImpl.setNew(image.isNew());
291         imageImpl.setPrimaryKey(image.getPrimaryKey());
292 
293         imageImpl.setImageId(image.getImageId());
294         imageImpl.setModifiedDate(image.getModifiedDate());
295         imageImpl.setText(image.getText());
296         imageImpl.setType(image.getType());
297         imageImpl.setHeight(image.getHeight());
298         imageImpl.setWidth(image.getWidth());
299         imageImpl.setSize(image.getSize());
300 
301         return imageImpl;
302     }
303 
304     public Image findByPrimaryKey(long imageId)
305         throws NoSuchImageException, SystemException {
306         Image image = fetchByPrimaryKey(imageId);
307 
308         if (image == null) {
309             if (_log.isWarnEnabled()) {
310                 _log.warn("No Image exists with the primary key " + imageId);
311             }
312 
313             throw new NoSuchImageException(
314                 "No Image exists with the primary key " + imageId);
315         }
316 
317         return image;
318     }
319 
320     public Image fetchByPrimaryKey(long imageId) throws SystemException {
321         Image image = (Image)EntityCacheUtil.getResult(ImageModelImpl.ENTITY_CACHE_ENABLED,
322                 ImageImpl.class, imageId, this);
323 
324         if (image == null) {
325             Session session = null;
326 
327             try {
328                 session = openSession();
329 
330                 image = (Image)session.get(ImageImpl.class, new Long(imageId));
331             }
332             catch (Exception e) {
333                 throw processException(e);
334             }
335             finally {
336                 if (image != null) {
337                     cacheResult(image);
338                 }
339 
340                 closeSession(session);
341             }
342         }
343 
344         return image;
345     }
346 
347     public List<Image> findBySize(int size) throws SystemException {
348         Object[] finderArgs = new Object[] { new Integer(size) };
349 
350         List<Image> list = (List<Image>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_SIZE,
351                 finderArgs, this);
352 
353         if (list == null) {
354             Session session = null;
355 
356             try {
357                 session = openSession();
358 
359                 StringBuilder query = new StringBuilder();
360 
361                 query.append("SELECT image FROM Image image WHERE ");
362 
363                 query.append("image.size < ?");
364 
365                 query.append(" ");
366 
367                 query.append("ORDER BY ");
368 
369                 query.append("image.imageId ASC");
370 
371                 Query q = session.createQuery(query.toString());
372 
373                 QueryPos qPos = QueryPos.getInstance(q);
374 
375                 qPos.add(size);
376 
377                 list = q.list();
378             }
379             catch (Exception e) {
380                 throw processException(e);
381             }
382             finally {
383                 if (list == null) {
384                     list = new ArrayList<Image>();
385                 }
386 
387                 cacheResult(list);
388 
389                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_SIZE, finderArgs,
390                     list);
391 
392                 closeSession(session);
393             }
394         }
395 
396         return list;
397     }
398 
399     public List<Image> findBySize(int size, int start, int end)
400         throws SystemException {
401         return findBySize(size, start, end, null);
402     }
403 
404     public List<Image> findBySize(int size, int start, int end,
405         OrderByComparator obc) throws SystemException {
406         Object[] finderArgs = new Object[] {
407                 new Integer(size),
408                 
409                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
410             };
411 
412         List<Image> list = (List<Image>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_SIZE,
413                 finderArgs, this);
414 
415         if (list == null) {
416             Session session = null;
417 
418             try {
419                 session = openSession();
420 
421                 StringBuilder query = new StringBuilder();
422 
423                 query.append("SELECT image FROM Image image WHERE ");
424 
425                 query.append("image.size < ?");
426 
427                 query.append(" ");
428 
429                 if (obc != null) {
430                     query.append("ORDER BY ");
431 
432                     String[] orderByFields = obc.getOrderByFields();
433 
434                     for (int i = 0; i < orderByFields.length; i++) {
435                         query.append("image.");
436                         query.append(orderByFields[i]);
437 
438                         if (obc.isAscending()) {
439                             query.append(" ASC");
440                         }
441                         else {
442                             query.append(" DESC");
443                         }
444 
445                         if ((i + 1) < orderByFields.length) {
446                             query.append(", ");
447                         }
448                     }
449                 }
450 
451                 else {
452                     query.append("ORDER BY ");
453 
454                     query.append("image.imageId ASC");
455                 }
456 
457                 Query q = session.createQuery(query.toString());
458 
459                 QueryPos qPos = QueryPos.getInstance(q);
460 
461                 qPos.add(size);
462 
463                 list = (List<Image>)QueryUtil.list(q, getDialect(), start, end);
464             }
465             catch (Exception e) {
466                 throw processException(e);
467             }
468             finally {
469                 if (list == null) {
470                     list = new ArrayList<Image>();
471                 }
472 
473                 cacheResult(list);
474 
475                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_SIZE,
476                     finderArgs, list);
477 
478                 closeSession(session);
479             }
480         }
481 
482         return list;
483     }
484 
485     public Image findBySize_First(int size, OrderByComparator obc)
486         throws NoSuchImageException, SystemException {
487         List<Image> list = findBySize(size, 0, 1, obc);
488 
489         if (list.isEmpty()) {
490             StringBuilder msg = new StringBuilder();
491 
492             msg.append("No Image exists with the key {");
493 
494             msg.append("size=" + size);
495 
496             msg.append(StringPool.CLOSE_CURLY_BRACE);
497 
498             throw new NoSuchImageException(msg.toString());
499         }
500         else {
501             return list.get(0);
502         }
503     }
504 
505     public Image findBySize_Last(int size, OrderByComparator obc)
506         throws NoSuchImageException, SystemException {
507         int count = countBySize(size);
508 
509         List<Image> list = findBySize(size, count - 1, count, obc);
510 
511         if (list.isEmpty()) {
512             StringBuilder msg = new StringBuilder();
513 
514             msg.append("No Image exists with the key {");
515 
516             msg.append("size=" + size);
517 
518             msg.append(StringPool.CLOSE_CURLY_BRACE);
519 
520             throw new NoSuchImageException(msg.toString());
521         }
522         else {
523             return list.get(0);
524         }
525     }
526 
527     public Image[] findBySize_PrevAndNext(long imageId, int size,
528         OrderByComparator obc) throws NoSuchImageException, SystemException {
529         Image image = findByPrimaryKey(imageId);
530 
531         int count = countBySize(size);
532 
533         Session session = null;
534 
535         try {
536             session = openSession();
537 
538             StringBuilder query = new StringBuilder();
539 
540             query.append("SELECT image FROM Image image WHERE ");
541 
542             query.append("image.size < ?");
543 
544             query.append(" ");
545 
546             if (obc != null) {
547                 query.append("ORDER BY ");
548 
549                 String[] orderByFields = obc.getOrderByFields();
550 
551                 for (int i = 0; i < orderByFields.length; i++) {
552                     query.append("image.");
553                     query.append(orderByFields[i]);
554 
555                     if (obc.isAscending()) {
556                         query.append(" ASC");
557                     }
558                     else {
559                         query.append(" DESC");
560                     }
561 
562                     if ((i + 1) < orderByFields.length) {
563                         query.append(", ");
564                     }
565                 }
566             }
567 
568             else {
569                 query.append("ORDER BY ");
570 
571                 query.append("image.imageId ASC");
572             }
573 
574             Query q = session.createQuery(query.toString());
575 
576             QueryPos qPos = QueryPos.getInstance(q);
577 
578             qPos.add(size);
579 
580             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, image);
581 
582             Image[] array = new ImageImpl[3];
583 
584             array[0] = (Image)objArray[0];
585             array[1] = (Image)objArray[1];
586             array[2] = (Image)objArray[2];
587 
588             return array;
589         }
590         catch (Exception e) {
591             throw processException(e);
592         }
593         finally {
594             closeSession(session);
595         }
596     }
597 
598     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
599         throws SystemException {
600         Session session = null;
601 
602         try {
603             session = openSession();
604 
605             dynamicQuery.compile(session);
606 
607             return dynamicQuery.list();
608         }
609         catch (Exception e) {
610             throw processException(e);
611         }
612         finally {
613             closeSession(session);
614         }
615     }
616 
617     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
618         int start, int end) throws SystemException {
619         Session session = null;
620 
621         try {
622             session = openSession();
623 
624             dynamicQuery.setLimit(start, end);
625 
626             dynamicQuery.compile(session);
627 
628             return dynamicQuery.list();
629         }
630         catch (Exception e) {
631             throw processException(e);
632         }
633         finally {
634             closeSession(session);
635         }
636     }
637 
638     public List<Image> findAll() throws SystemException {
639         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
640     }
641 
642     public List<Image> findAll(int start, int end) throws SystemException {
643         return findAll(start, end, null);
644     }
645 
646     public List<Image> findAll(int start, int end, OrderByComparator obc)
647         throws SystemException {
648         Object[] finderArgs = new Object[] {
649                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
650             };
651 
652         List<Image> list = (List<Image>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
653                 finderArgs, this);
654 
655         if (list == null) {
656             Session session = null;
657 
658             try {
659                 session = openSession();
660 
661                 StringBuilder query = new StringBuilder();
662 
663                 query.append("SELECT image FROM Image image ");
664 
665                 if (obc != null) {
666                     query.append("ORDER BY ");
667 
668                     String[] orderByFields = obc.getOrderByFields();
669 
670                     for (int i = 0; i < orderByFields.length; i++) {
671                         query.append("image.");
672                         query.append(orderByFields[i]);
673 
674                         if (obc.isAscending()) {
675                             query.append(" ASC");
676                         }
677                         else {
678                             query.append(" DESC");
679                         }
680 
681                         if ((i + 1) < orderByFields.length) {
682                             query.append(", ");
683                         }
684                     }
685                 }
686 
687                 else {
688                     query.append("ORDER BY ");
689 
690                     query.append("image.imageId ASC");
691                 }
692 
693                 Query q = session.createQuery(query.toString());
694 
695                 if (obc == null) {
696                     list = (List<Image>)QueryUtil.list(q, getDialect(), start,
697                             end, false);
698 
699                     Collections.sort(list);
700                 }
701                 else {
702                     list = (List<Image>)QueryUtil.list(q, getDialect(), start,
703                             end);
704                 }
705             }
706             catch (Exception e) {
707                 throw processException(e);
708             }
709             finally {
710                 if (list == null) {
711                     list = new ArrayList<Image>();
712                 }
713 
714                 cacheResult(list);
715 
716                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
717 
718                 closeSession(session);
719             }
720         }
721 
722         return list;
723     }
724 
725     public void removeBySize(int size) throws SystemException {
726         for (Image image : findBySize(size)) {
727             remove(image);
728         }
729     }
730 
731     public void removeAll() throws SystemException {
732         for (Image image : findAll()) {
733             remove(image);
734         }
735     }
736 
737     public int countBySize(int size) throws SystemException {
738         Object[] finderArgs = new Object[] { new Integer(size) };
739 
740         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SIZE,
741                 finderArgs, this);
742 
743         if (count == null) {
744             Session session = null;
745 
746             try {
747                 session = openSession();
748 
749                 StringBuilder query = new StringBuilder();
750 
751                 query.append("SELECT COUNT(image) ");
752                 query.append("FROM Image image WHERE ");
753 
754                 query.append("image.size < ?");
755 
756                 query.append(" ");
757 
758                 Query q = session.createQuery(query.toString());
759 
760                 QueryPos qPos = QueryPos.getInstance(q);
761 
762                 qPos.add(size);
763 
764                 count = (Long)q.uniqueResult();
765             }
766             catch (Exception e) {
767                 throw processException(e);
768             }
769             finally {
770                 if (count == null) {
771                     count = Long.valueOf(0);
772                 }
773 
774                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SIZE,
775                     finderArgs, count);
776 
777                 closeSession(session);
778             }
779         }
780 
781         return count.intValue();
782     }
783 
784     public int countAll() throws SystemException {
785         Object[] finderArgs = new Object[0];
786 
787         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
788                 finderArgs, this);
789 
790         if (count == null) {
791             Session session = null;
792 
793             try {
794                 session = openSession();
795 
796                 Query q = session.createQuery(
797                         "SELECT COUNT(image) FROM Image image");
798 
799                 count = (Long)q.uniqueResult();
800             }
801             catch (Exception e) {
802                 throw processException(e);
803             }
804             finally {
805                 if (count == null) {
806                     count = Long.valueOf(0);
807                 }
808 
809                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
810                     count);
811 
812                 closeSession(session);
813             }
814         }
815 
816         return count.intValue();
817     }
818 
819     public void afterPropertiesSet() {
820         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
821                     com.liferay.portal.util.PropsUtil.get(
822                         "value.object.listener.com.liferay.portal.model.Image")));
823 
824         if (listenerClassNames.length > 0) {
825             try {
826                 List<ModelListener<Image>> listenersList = new ArrayList<ModelListener<Image>>();
827 
828                 for (String listenerClassName : listenerClassNames) {
829                     listenersList.add((ModelListener<Image>)Class.forName(
830                             listenerClassName).newInstance());
831                 }
832 
833                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
834             }
835             catch (Exception e) {
836                 _log.error(e);
837             }
838         }
839     }
840 
841     @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
842     protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
843     @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
844     protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
845     @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
846     protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
847     @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
848     protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
849     @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
850     protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
851     @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
852     protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
853     @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
854     protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
855     @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
856     protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
857     @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
858     protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
859     @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
860     protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
861     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
862     protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
863     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
864     protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
865     @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
866     protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
867     @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence.impl")
868     protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
869     @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
870     protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
871     @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
872     protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
873     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
874     protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
875     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
876     protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
877     @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
878     protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
879     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
880     protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
881     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
882     protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
883     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
884     protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
885     @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
886     protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
887     @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
888     protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
889     @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
890     protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
891     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
892     protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
893     @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
894     protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
895     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
896     protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
897     @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
898     protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
899     @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
900     protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
901     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
902     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
903     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
904     protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
905     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
906     protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
907     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
908     protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
909     @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
910     protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
911     @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
912     protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
913     @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
914     protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
915     @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
916     protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
917     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
918     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
919     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
920     protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
921     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence.impl")
922     protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
923     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
924     protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
925     @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
926     protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
927     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
928     protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
929     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
930     protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
931     @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
932     protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
933     @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
934     protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
935     private static Log _log = LogFactoryUtil.getLog(ImagePersistenceImpl.class);
936 }