1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.kernel.annotation.BeanReference;
19  import com.liferay.portal.kernel.cache.CacheRegistry;
20  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderPath;
23  import com.liferay.portal.kernel.dao.orm.Query;
24  import com.liferay.portal.kernel.dao.orm.QueryPos;
25  import com.liferay.portal.kernel.dao.orm.QueryUtil;
26  import com.liferay.portal.kernel.dao.orm.Session;
27  import com.liferay.portal.kernel.exception.SystemException;
28  import com.liferay.portal.kernel.log.Log;
29  import com.liferay.portal.kernel.log.LogFactoryUtil;
30  import com.liferay.portal.kernel.util.GetterUtil;
31  import com.liferay.portal.kernel.util.OrderByComparator;
32  import com.liferay.portal.kernel.util.StringBundler;
33  import com.liferay.portal.kernel.util.StringPool;
34  import com.liferay.portal.kernel.util.StringUtil;
35  import com.liferay.portal.model.ModelListener;
36  import com.liferay.portal.service.persistence.BatchSessionUtil;
37  import com.liferay.portal.service.persistence.ResourcePersistence;
38  import com.liferay.portal.service.persistence.UserPersistence;
39  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
40  
41  import com.liferay.portlet.shopping.NoSuchItemFieldException;
42  import com.liferay.portlet.shopping.model.ShoppingItemField;
43  import com.liferay.portlet.shopping.model.impl.ShoppingItemFieldImpl;
44  import com.liferay.portlet.shopping.model.impl.ShoppingItemFieldModelImpl;
45  
46  import java.io.Serializable;
47  
48  import java.util.ArrayList;
49  import java.util.Collections;
50  import java.util.List;
51  
52  /**
53   * <a href="ShoppingItemFieldPersistenceImpl.java.html"><b><i>View Source</i></b></a>
54   *
55   * <p>
56   * ServiceBuilder generated this class. Modifications in this class will be
57   * overwritten the next time is generated.
58   * </p>
59   *
60   * @author    Brian Wing Shun Chan
61   * @see       ShoppingItemFieldPersistence
62   * @see       ShoppingItemFieldUtil
63   * @generated
64   */
65  public class ShoppingItemFieldPersistenceImpl extends BasePersistenceImpl<ShoppingItemField>
66      implements ShoppingItemFieldPersistence {
67      public static final String FINDER_CLASS_NAME_ENTITY = ShoppingItemFieldImpl.class.getName();
68      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
69          ".List";
70      public static final FinderPath FINDER_PATH_FIND_BY_ITEMID = new FinderPath(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
71              ShoppingItemFieldModelImpl.FINDER_CACHE_ENABLED,
72              FINDER_CLASS_NAME_LIST, "findByItemId",
73              new String[] { Long.class.getName() });
74      public static final FinderPath FINDER_PATH_FIND_BY_OBC_ITEMID = new FinderPath(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
75              ShoppingItemFieldModelImpl.FINDER_CACHE_ENABLED,
76              FINDER_CLASS_NAME_LIST, "findByItemId",
77              new String[] {
78                  Long.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_ITEMID = new FinderPath(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
84              ShoppingItemFieldModelImpl.FINDER_CACHE_ENABLED,
85              FINDER_CLASS_NAME_LIST, "countByItemId",
86              new String[] { Long.class.getName() });
87      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
88              ShoppingItemFieldModelImpl.FINDER_CACHE_ENABLED,
89              FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
90      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
91              ShoppingItemFieldModelImpl.FINDER_CACHE_ENABLED,
92              FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
93  
94      public void cacheResult(ShoppingItemField shoppingItemField) {
95          EntityCacheUtil.putResult(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
96              ShoppingItemFieldImpl.class, shoppingItemField.getPrimaryKey(),
97              shoppingItemField);
98      }
99  
100     public void cacheResult(List<ShoppingItemField> shoppingItemFields) {
101         for (ShoppingItemField shoppingItemField : shoppingItemFields) {
102             if (EntityCacheUtil.getResult(
103                         ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
104                         ShoppingItemFieldImpl.class,
105                         shoppingItemField.getPrimaryKey(), this) == null) {
106                 cacheResult(shoppingItemField);
107             }
108         }
109     }
110 
111     public void clearCache() {
112         CacheRegistry.clear(ShoppingItemFieldImpl.class.getName());
113         EntityCacheUtil.clearCache(ShoppingItemFieldImpl.class.getName());
114         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
115         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
116     }
117 
118     public ShoppingItemField create(long itemFieldId) {
119         ShoppingItemField shoppingItemField = new ShoppingItemFieldImpl();
120 
121         shoppingItemField.setNew(true);
122         shoppingItemField.setPrimaryKey(itemFieldId);
123 
124         return shoppingItemField;
125     }
126 
127     public ShoppingItemField remove(Serializable primaryKey)
128         throws NoSuchModelException, SystemException {
129         return remove(((Long)primaryKey).longValue());
130     }
131 
132     public ShoppingItemField remove(long itemFieldId)
133         throws NoSuchItemFieldException, SystemException {
134         Session session = null;
135 
136         try {
137             session = openSession();
138 
139             ShoppingItemField shoppingItemField = (ShoppingItemField)session.get(ShoppingItemFieldImpl.class,
140                     new Long(itemFieldId));
141 
142             if (shoppingItemField == null) {
143                 if (_log.isWarnEnabled()) {
144                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + itemFieldId);
145                 }
146 
147                 throw new NoSuchItemFieldException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
148                     itemFieldId);
149             }
150 
151             return remove(shoppingItemField);
152         }
153         catch (NoSuchItemFieldException nsee) {
154             throw nsee;
155         }
156         catch (Exception e) {
157             throw processException(e);
158         }
159         finally {
160             closeSession(session);
161         }
162     }
163 
164     public ShoppingItemField remove(ShoppingItemField shoppingItemField)
165         throws SystemException {
166         for (ModelListener<ShoppingItemField> listener : listeners) {
167             listener.onBeforeRemove(shoppingItemField);
168         }
169 
170         shoppingItemField = removeImpl(shoppingItemField);
171 
172         for (ModelListener<ShoppingItemField> listener : listeners) {
173             listener.onAfterRemove(shoppingItemField);
174         }
175 
176         return shoppingItemField;
177     }
178 
179     protected ShoppingItemField removeImpl(ShoppingItemField shoppingItemField)
180         throws SystemException {
181         shoppingItemField = toUnwrappedModel(shoppingItemField);
182 
183         Session session = null;
184 
185         try {
186             session = openSession();
187 
188             if (shoppingItemField.isCachedModel() ||
189                     BatchSessionUtil.isEnabled()) {
190                 Object staleObject = session.get(ShoppingItemFieldImpl.class,
191                         shoppingItemField.getPrimaryKeyObj());
192 
193                 if (staleObject != null) {
194                     session.evict(staleObject);
195                 }
196             }
197 
198             session.delete(shoppingItemField);
199 
200             session.flush();
201         }
202         catch (Exception e) {
203             throw processException(e);
204         }
205         finally {
206             closeSession(session);
207         }
208 
209         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
210 
211         EntityCacheUtil.removeResult(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
212             ShoppingItemFieldImpl.class, shoppingItemField.getPrimaryKey());
213 
214         return shoppingItemField;
215     }
216 
217     public ShoppingItemField updateImpl(
218         com.liferay.portlet.shopping.model.ShoppingItemField shoppingItemField,
219         boolean merge) throws SystemException {
220         shoppingItemField = toUnwrappedModel(shoppingItemField);
221 
222         Session session = null;
223 
224         try {
225             session = openSession();
226 
227             BatchSessionUtil.update(session, shoppingItemField, merge);
228 
229             shoppingItemField.setNew(false);
230         }
231         catch (Exception e) {
232             throw processException(e);
233         }
234         finally {
235             closeSession(session);
236         }
237 
238         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
239 
240         EntityCacheUtil.putResult(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
241             ShoppingItemFieldImpl.class, shoppingItemField.getPrimaryKey(),
242             shoppingItemField);
243 
244         return shoppingItemField;
245     }
246 
247     protected ShoppingItemField toUnwrappedModel(
248         ShoppingItemField shoppingItemField) {
249         if (shoppingItemField instanceof ShoppingItemFieldImpl) {
250             return shoppingItemField;
251         }
252 
253         ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
254 
255         shoppingItemFieldImpl.setNew(shoppingItemField.isNew());
256         shoppingItemFieldImpl.setPrimaryKey(shoppingItemField.getPrimaryKey());
257 
258         shoppingItemFieldImpl.setItemFieldId(shoppingItemField.getItemFieldId());
259         shoppingItemFieldImpl.setItemId(shoppingItemField.getItemId());
260         shoppingItemFieldImpl.setName(shoppingItemField.getName());
261         shoppingItemFieldImpl.setValues(shoppingItemField.getValues());
262         shoppingItemFieldImpl.setDescription(shoppingItemField.getDescription());
263 
264         return shoppingItemFieldImpl;
265     }
266 
267     public ShoppingItemField findByPrimaryKey(Serializable primaryKey)
268         throws NoSuchModelException, SystemException {
269         return findByPrimaryKey(((Long)primaryKey).longValue());
270     }
271 
272     public ShoppingItemField findByPrimaryKey(long itemFieldId)
273         throws NoSuchItemFieldException, SystemException {
274         ShoppingItemField shoppingItemField = fetchByPrimaryKey(itemFieldId);
275 
276         if (shoppingItemField == null) {
277             if (_log.isWarnEnabled()) {
278                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + itemFieldId);
279             }
280 
281             throw new NoSuchItemFieldException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
282                 itemFieldId);
283         }
284 
285         return shoppingItemField;
286     }
287 
288     public ShoppingItemField fetchByPrimaryKey(Serializable primaryKey)
289         throws SystemException {
290         return fetchByPrimaryKey(((Long)primaryKey).longValue());
291     }
292 
293     public ShoppingItemField fetchByPrimaryKey(long itemFieldId)
294         throws SystemException {
295         ShoppingItemField shoppingItemField = (ShoppingItemField)EntityCacheUtil.getResult(ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
296                 ShoppingItemFieldImpl.class, itemFieldId, this);
297 
298         if (shoppingItemField == null) {
299             Session session = null;
300 
301             try {
302                 session = openSession();
303 
304                 shoppingItemField = (ShoppingItemField)session.get(ShoppingItemFieldImpl.class,
305                         new Long(itemFieldId));
306             }
307             catch (Exception e) {
308                 throw processException(e);
309             }
310             finally {
311                 if (shoppingItemField != null) {
312                     cacheResult(shoppingItemField);
313                 }
314 
315                 closeSession(session);
316             }
317         }
318 
319         return shoppingItemField;
320     }
321 
322     public List<ShoppingItemField> findByItemId(long itemId)
323         throws SystemException {
324         Object[] finderArgs = new Object[] { new Long(itemId) };
325 
326         List<ShoppingItemField> list = (List<ShoppingItemField>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ITEMID,
327                 finderArgs, this);
328 
329         if (list == null) {
330             Session session = null;
331 
332             try {
333                 session = openSession();
334 
335                 StringBundler query = new StringBundler(3);
336 
337                 query.append(_SQL_SELECT_SHOPPINGITEMFIELD_WHERE);
338 
339                 query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
340 
341                 query.append(ShoppingItemFieldModelImpl.ORDER_BY_JPQL);
342 
343                 String sql = query.toString();
344 
345                 Query q = session.createQuery(sql);
346 
347                 QueryPos qPos = QueryPos.getInstance(q);
348 
349                 qPos.add(itemId);
350 
351                 list = q.list();
352             }
353             catch (Exception e) {
354                 throw processException(e);
355             }
356             finally {
357                 if (list == null) {
358                     list = new ArrayList<ShoppingItemField>();
359                 }
360 
361                 cacheResult(list);
362 
363                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ITEMID,
364                     finderArgs, list);
365 
366                 closeSession(session);
367             }
368         }
369 
370         return list;
371     }
372 
373     public List<ShoppingItemField> findByItemId(long itemId, int start, int end)
374         throws SystemException {
375         return findByItemId(itemId, start, end, null);
376     }
377 
378     public List<ShoppingItemField> findByItemId(long itemId, int start,
379         int end, OrderByComparator orderByComparator) throws SystemException {
380         Object[] finderArgs = new Object[] {
381                 new Long(itemId),
382                 
383                 String.valueOf(start), String.valueOf(end),
384                 String.valueOf(orderByComparator)
385             };
386 
387         List<ShoppingItemField> list = (List<ShoppingItemField>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ITEMID,
388                 finderArgs, this);
389 
390         if (list == null) {
391             Session session = null;
392 
393             try {
394                 session = openSession();
395 
396                 StringBundler query = null;
397 
398                 if (orderByComparator != null) {
399                     query = new StringBundler(3 +
400                             (orderByComparator.getOrderByFields().length * 3));
401                 }
402                 else {
403                     query = new StringBundler(3);
404                 }
405 
406                 query.append(_SQL_SELECT_SHOPPINGITEMFIELD_WHERE);
407 
408                 query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
409 
410                 if (orderByComparator != null) {
411                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
412                         orderByComparator);
413                 }
414 
415                 else {
416                     query.append(ShoppingItemFieldModelImpl.ORDER_BY_JPQL);
417                 }
418 
419                 String sql = query.toString();
420 
421                 Query q = session.createQuery(sql);
422 
423                 QueryPos qPos = QueryPos.getInstance(q);
424 
425                 qPos.add(itemId);
426 
427                 list = (List<ShoppingItemField>)QueryUtil.list(q, getDialect(),
428                         start, end);
429             }
430             catch (Exception e) {
431                 throw processException(e);
432             }
433             finally {
434                 if (list == null) {
435                     list = new ArrayList<ShoppingItemField>();
436                 }
437 
438                 cacheResult(list);
439 
440                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ITEMID,
441                     finderArgs, list);
442 
443                 closeSession(session);
444             }
445         }
446 
447         return list;
448     }
449 
450     public ShoppingItemField findByItemId_First(long itemId,
451         OrderByComparator orderByComparator)
452         throws NoSuchItemFieldException, SystemException {
453         List<ShoppingItemField> list = findByItemId(itemId, 0, 1,
454                 orderByComparator);
455 
456         if (list.isEmpty()) {
457             StringBundler msg = new StringBundler(4);
458 
459             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
460 
461             msg.append("itemId=");
462             msg.append(itemId);
463 
464             msg.append(StringPool.CLOSE_CURLY_BRACE);
465 
466             throw new NoSuchItemFieldException(msg.toString());
467         }
468         else {
469             return list.get(0);
470         }
471     }
472 
473     public ShoppingItemField findByItemId_Last(long itemId,
474         OrderByComparator orderByComparator)
475         throws NoSuchItemFieldException, SystemException {
476         int count = countByItemId(itemId);
477 
478         List<ShoppingItemField> list = findByItemId(itemId, count - 1, count,
479                 orderByComparator);
480 
481         if (list.isEmpty()) {
482             StringBundler msg = new StringBundler(4);
483 
484             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
485 
486             msg.append("itemId=");
487             msg.append(itemId);
488 
489             msg.append(StringPool.CLOSE_CURLY_BRACE);
490 
491             throw new NoSuchItemFieldException(msg.toString());
492         }
493         else {
494             return list.get(0);
495         }
496     }
497 
498     public ShoppingItemField[] findByItemId_PrevAndNext(long itemFieldId,
499         long itemId, OrderByComparator orderByComparator)
500         throws NoSuchItemFieldException, SystemException {
501         ShoppingItemField shoppingItemField = findByPrimaryKey(itemFieldId);
502 
503         int count = countByItemId(itemId);
504 
505         Session session = null;
506 
507         try {
508             session = openSession();
509 
510             StringBundler query = null;
511 
512             if (orderByComparator != null) {
513                 query = new StringBundler(3 +
514                         (orderByComparator.getOrderByFields().length * 3));
515             }
516             else {
517                 query = new StringBundler(3);
518             }
519 
520             query.append(_SQL_SELECT_SHOPPINGITEMFIELD_WHERE);
521 
522             query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
523 
524             if (orderByComparator != null) {
525                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
526                     orderByComparator);
527             }
528 
529             else {
530                 query.append(ShoppingItemFieldModelImpl.ORDER_BY_JPQL);
531             }
532 
533             String sql = query.toString();
534 
535             Query q = session.createQuery(sql);
536 
537             QueryPos qPos = QueryPos.getInstance(q);
538 
539             qPos.add(itemId);
540 
541             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
542                     orderByComparator, shoppingItemField);
543 
544             ShoppingItemField[] array = new ShoppingItemFieldImpl[3];
545 
546             array[0] = (ShoppingItemField)objArray[0];
547             array[1] = (ShoppingItemField)objArray[1];
548             array[2] = (ShoppingItemField)objArray[2];
549 
550             return array;
551         }
552         catch (Exception e) {
553             throw processException(e);
554         }
555         finally {
556             closeSession(session);
557         }
558     }
559 
560     public List<ShoppingItemField> findAll() throws SystemException {
561         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
562     }
563 
564     public List<ShoppingItemField> findAll(int start, int end)
565         throws SystemException {
566         return findAll(start, end, null);
567     }
568 
569     public List<ShoppingItemField> findAll(int start, int end,
570         OrderByComparator orderByComparator) throws SystemException {
571         Object[] finderArgs = new Object[] {
572                 String.valueOf(start), String.valueOf(end),
573                 String.valueOf(orderByComparator)
574             };
575 
576         List<ShoppingItemField> list = (List<ShoppingItemField>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
577                 finderArgs, this);
578 
579         if (list == null) {
580             Session session = null;
581 
582             try {
583                 session = openSession();
584 
585                 StringBundler query = null;
586                 String sql = null;
587 
588                 if (orderByComparator != null) {
589                     query = new StringBundler(2 +
590                             (orderByComparator.getOrderByFields().length * 3));
591 
592                     query.append(_SQL_SELECT_SHOPPINGITEMFIELD);
593 
594                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
595                         orderByComparator);
596 
597                     sql = query.toString();
598                 }
599 
600                 else {
601                     sql = _SQL_SELECT_SHOPPINGITEMFIELD.concat(ShoppingItemFieldModelImpl.ORDER_BY_JPQL);
602                 }
603 
604                 Query q = session.createQuery(sql);
605 
606                 if (orderByComparator == null) {
607                     list = (List<ShoppingItemField>)QueryUtil.list(q,
608                             getDialect(), start, end, false);
609 
610                     Collections.sort(list);
611                 }
612                 else {
613                     list = (List<ShoppingItemField>)QueryUtil.list(q,
614                             getDialect(), start, end);
615                 }
616             }
617             catch (Exception e) {
618                 throw processException(e);
619             }
620             finally {
621                 if (list == null) {
622                     list = new ArrayList<ShoppingItemField>();
623                 }
624 
625                 cacheResult(list);
626 
627                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
628 
629                 closeSession(session);
630             }
631         }
632 
633         return list;
634     }
635 
636     public void removeByItemId(long itemId) throws SystemException {
637         for (ShoppingItemField shoppingItemField : findByItemId(itemId)) {
638             remove(shoppingItemField);
639         }
640     }
641 
642     public void removeAll() throws SystemException {
643         for (ShoppingItemField shoppingItemField : findAll()) {
644             remove(shoppingItemField);
645         }
646     }
647 
648     public int countByItemId(long itemId) throws SystemException {
649         Object[] finderArgs = new Object[] { new Long(itemId) };
650 
651         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ITEMID,
652                 finderArgs, this);
653 
654         if (count == null) {
655             Session session = null;
656 
657             try {
658                 session = openSession();
659 
660                 StringBundler query = new StringBundler(2);
661 
662                 query.append(_SQL_COUNT_SHOPPINGITEMFIELD_WHERE);
663 
664                 query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
665 
666                 String sql = query.toString();
667 
668                 Query q = session.createQuery(sql);
669 
670                 QueryPos qPos = QueryPos.getInstance(q);
671 
672                 qPos.add(itemId);
673 
674                 count = (Long)q.uniqueResult();
675             }
676             catch (Exception e) {
677                 throw processException(e);
678             }
679             finally {
680                 if (count == null) {
681                     count = Long.valueOf(0);
682                 }
683 
684                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ITEMID,
685                     finderArgs, count);
686 
687                 closeSession(session);
688             }
689         }
690 
691         return count.intValue();
692     }
693 
694     public int countAll() throws SystemException {
695         Object[] finderArgs = new Object[0];
696 
697         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
698                 finderArgs, this);
699 
700         if (count == null) {
701             Session session = null;
702 
703             try {
704                 session = openSession();
705 
706                 Query q = session.createQuery(_SQL_COUNT_SHOPPINGITEMFIELD);
707 
708                 count = (Long)q.uniqueResult();
709             }
710             catch (Exception e) {
711                 throw processException(e);
712             }
713             finally {
714                 if (count == null) {
715                     count = Long.valueOf(0);
716                 }
717 
718                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
719                     count);
720 
721                 closeSession(session);
722             }
723         }
724 
725         return count.intValue();
726     }
727 
728     public void afterPropertiesSet() {
729         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
730                     com.liferay.portal.util.PropsUtil.get(
731                         "value.object.listener.com.liferay.portlet.shopping.model.ShoppingItemField")));
732 
733         if (listenerClassNames.length > 0) {
734             try {
735                 List<ModelListener<ShoppingItemField>> listenersList = new ArrayList<ModelListener<ShoppingItemField>>();
736 
737                 for (String listenerClassName : listenerClassNames) {
738                     listenersList.add((ModelListener<ShoppingItemField>)Class.forName(
739                             listenerClassName).newInstance());
740                 }
741 
742                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
743             }
744             catch (Exception e) {
745                 _log.error(e);
746             }
747         }
748     }
749 
750     @BeanReference(type = ShoppingCartPersistence.class)
751     protected ShoppingCartPersistence shoppingCartPersistence;
752     @BeanReference(type = ShoppingCategoryPersistence.class)
753     protected ShoppingCategoryPersistence shoppingCategoryPersistence;
754     @BeanReference(type = ShoppingCouponPersistence.class)
755     protected ShoppingCouponPersistence shoppingCouponPersistence;
756     @BeanReference(type = ShoppingItemPersistence.class)
757     protected ShoppingItemPersistence shoppingItemPersistence;
758     @BeanReference(type = ShoppingItemFieldPersistence.class)
759     protected ShoppingItemFieldPersistence shoppingItemFieldPersistence;
760     @BeanReference(type = ShoppingItemPricePersistence.class)
761     protected ShoppingItemPricePersistence shoppingItemPricePersistence;
762     @BeanReference(type = ShoppingOrderPersistence.class)
763     protected ShoppingOrderPersistence shoppingOrderPersistence;
764     @BeanReference(type = ShoppingOrderItemPersistence.class)
765     protected ShoppingOrderItemPersistence shoppingOrderItemPersistence;
766     @BeanReference(type = ResourcePersistence.class)
767     protected ResourcePersistence resourcePersistence;
768     @BeanReference(type = UserPersistence.class)
769     protected UserPersistence userPersistence;
770     private static final String _SQL_SELECT_SHOPPINGITEMFIELD = "SELECT shoppingItemField FROM ShoppingItemField shoppingItemField";
771     private static final String _SQL_SELECT_SHOPPINGITEMFIELD_WHERE = "SELECT shoppingItemField FROM ShoppingItemField shoppingItemField WHERE ";
772     private static final String _SQL_COUNT_SHOPPINGITEMFIELD = "SELECT COUNT(shoppingItemField) FROM ShoppingItemField shoppingItemField";
773     private static final String _SQL_COUNT_SHOPPINGITEMFIELD_WHERE = "SELECT COUNT(shoppingItemField) FROM ShoppingItemField shoppingItemField WHERE ";
774     private static final String _FINDER_COLUMN_ITEMID_ITEMID_2 = "shoppingItemField.itemId = ?";
775     private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingItemField.";
776     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingItemField exists with the primary key ";
777     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingItemField exists with the key {";
778     private static Log _log = LogFactoryUtil.getLog(ShoppingItemFieldPersistenceImpl.class);
779 }