001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    import com.liferay.portal.kernel.util.StringBundler;
031    import com.liferay.portal.kernel.util.StringPool;
032    import com.liferay.portal.model.CacheModel;
033    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
034    
035    import com.liferay.portlet.shopping.NoSuchItemPriceException;
036    import com.liferay.portlet.shopping.model.ShoppingItemPrice;
037    import com.liferay.portlet.shopping.model.impl.ShoppingItemPriceImpl;
038    import com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl;
039    import com.liferay.portlet.shopping.service.persistence.ShoppingItemPricePersistence;
040    
041    import java.io.Serializable;
042    
043    import java.util.Collections;
044    import java.util.HashMap;
045    import java.util.HashSet;
046    import java.util.Iterator;
047    import java.util.List;
048    import java.util.Map;
049    import java.util.Set;
050    
051    /**
052     * The persistence implementation for the shopping item price service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see ShoppingItemPricePersistence
060     * @see ShoppingItemPriceUtil
061     * @generated
062     */
063    @ProviderType
064    public class ShoppingItemPricePersistenceImpl extends BasePersistenceImpl<ShoppingItemPrice>
065            implements ShoppingItemPricePersistence {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link ShoppingItemPriceUtil} to access the shopping item price persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
070             */
071            public static final String FINDER_CLASS_NAME_ENTITY = ShoppingItemPriceImpl.class.getName();
072            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List1";
074            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List2";
076            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
077                            ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
078                            ShoppingItemPriceImpl.class,
079                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
080            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
081                            ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
082                            ShoppingItemPriceImpl.class,
083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
084            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
085                            ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED, Long.class,
086                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ITEMID = new FinderPath(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
088                            ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
089                            ShoppingItemPriceImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByItemId",
091                            new String[] {
092                                    Long.class.getName(),
093                                    
094                            Integer.class.getName(), Integer.class.getName(),
095                                    OrderByComparator.class.getName()
096                            });
097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID =
098                    new FinderPath(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
099                            ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED,
100                            ShoppingItemPriceImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByItemId",
102                            new String[] { Long.class.getName() },
103                            ShoppingItemPriceModelImpl.ITEMID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_ITEMID = new FinderPath(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
105                            ShoppingItemPriceModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByItemId",
107                            new String[] { Long.class.getName() });
108    
109            /**
110             * Returns all the shopping item prices where itemId = &#63;.
111             *
112             * @param itemId the item ID
113             * @return the matching shopping item prices
114             */
115            @Override
116            public List<ShoppingItemPrice> findByItemId(long itemId) {
117                    return findByItemId(itemId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
118            }
119    
120            /**
121             * Returns a range of all the shopping item prices where itemId = &#63;.
122             *
123             * <p>
124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
125             * </p>
126             *
127             * @param itemId the item ID
128             * @param start the lower bound of the range of shopping item prices
129             * @param end the upper bound of the range of shopping item prices (not inclusive)
130             * @return the range of matching shopping item prices
131             */
132            @Override
133            public List<ShoppingItemPrice> findByItemId(long itemId, int start, int end) {
134                    return findByItemId(itemId, start, end, null);
135            }
136    
137            /**
138             * Returns an ordered range of all the shopping item prices where itemId = &#63;.
139             *
140             * <p>
141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
142             * </p>
143             *
144             * @param itemId the item ID
145             * @param start the lower bound of the range of shopping item prices
146             * @param end the upper bound of the range of shopping item prices (not inclusive)
147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
148             * @return the ordered range of matching shopping item prices
149             */
150            @Override
151            public List<ShoppingItemPrice> findByItemId(long itemId, int start,
152                    int end, OrderByComparator<ShoppingItemPrice> orderByComparator) {
153                    boolean pagination = true;
154                    FinderPath finderPath = null;
155                    Object[] finderArgs = null;
156    
157                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
158                                    (orderByComparator == null)) {
159                            pagination = false;
160                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID;
161                            finderArgs = new Object[] { itemId };
162                    }
163                    else {
164                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ITEMID;
165                            finderArgs = new Object[] { itemId, start, end, orderByComparator };
166                    }
167    
168                    List<ShoppingItemPrice> list = (List<ShoppingItemPrice>)FinderCacheUtil.getResult(finderPath,
169                                    finderArgs, this);
170    
171                    if ((list != null) && !list.isEmpty()) {
172                            for (ShoppingItemPrice shoppingItemPrice : list) {
173                                    if ((itemId != shoppingItemPrice.getItemId())) {
174                                            list = null;
175    
176                                            break;
177                                    }
178                            }
179                    }
180    
181                    if (list == null) {
182                            StringBundler query = null;
183    
184                            if (orderByComparator != null) {
185                                    query = new StringBundler(3 +
186                                                    (orderByComparator.getOrderByFields().length * 3));
187                            }
188                            else {
189                                    query = new StringBundler(3);
190                            }
191    
192                            query.append(_SQL_SELECT_SHOPPINGITEMPRICE_WHERE);
193    
194                            query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
195    
196                            if (orderByComparator != null) {
197                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
198                                            orderByComparator);
199                            }
200                            else
201                             if (pagination) {
202                                    query.append(ShoppingItemPriceModelImpl.ORDER_BY_JPQL);
203                            }
204    
205                            String sql = query.toString();
206    
207                            Session session = null;
208    
209                            try {
210                                    session = openSession();
211    
212                                    Query q = session.createQuery(sql);
213    
214                                    QueryPos qPos = QueryPos.getInstance(q);
215    
216                                    qPos.add(itemId);
217    
218                                    if (!pagination) {
219                                            list = (List<ShoppingItemPrice>)QueryUtil.list(q,
220                                                            getDialect(), start, end, false);
221    
222                                            Collections.sort(list);
223    
224                                            list = Collections.unmodifiableList(list);
225                                    }
226                                    else {
227                                            list = (List<ShoppingItemPrice>)QueryUtil.list(q,
228                                                            getDialect(), start, end);
229                                    }
230    
231                                    cacheResult(list);
232    
233                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
234                            }
235                            catch (Exception e) {
236                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
237    
238                                    throw processException(e);
239                            }
240                            finally {
241                                    closeSession(session);
242                            }
243                    }
244    
245                    return list;
246            }
247    
248            /**
249             * Returns the first shopping item price in the ordered set where itemId = &#63;.
250             *
251             * @param itemId the item ID
252             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
253             * @return the first matching shopping item price
254             * @throws com.liferay.portlet.shopping.NoSuchItemPriceException if a matching shopping item price could not be found
255             */
256            @Override
257            public ShoppingItemPrice findByItemId_First(long itemId,
258                    OrderByComparator<ShoppingItemPrice> orderByComparator)
259                    throws NoSuchItemPriceException {
260                    ShoppingItemPrice shoppingItemPrice = fetchByItemId_First(itemId,
261                                    orderByComparator);
262    
263                    if (shoppingItemPrice != null) {
264                            return shoppingItemPrice;
265                    }
266    
267                    StringBundler msg = new StringBundler(4);
268    
269                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
270    
271                    msg.append("itemId=");
272                    msg.append(itemId);
273    
274                    msg.append(StringPool.CLOSE_CURLY_BRACE);
275    
276                    throw new NoSuchItemPriceException(msg.toString());
277            }
278    
279            /**
280             * Returns the first shopping item price in the ordered set where itemId = &#63;.
281             *
282             * @param itemId the item ID
283             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
284             * @return the first matching shopping item price, or <code>null</code> if a matching shopping item price could not be found
285             */
286            @Override
287            public ShoppingItemPrice fetchByItemId_First(long itemId,
288                    OrderByComparator<ShoppingItemPrice> orderByComparator) {
289                    List<ShoppingItemPrice> list = findByItemId(itemId, 0, 1,
290                                    orderByComparator);
291    
292                    if (!list.isEmpty()) {
293                            return list.get(0);
294                    }
295    
296                    return null;
297            }
298    
299            /**
300             * Returns the last shopping item price in the ordered set where itemId = &#63;.
301             *
302             * @param itemId the item ID
303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
304             * @return the last matching shopping item price
305             * @throws com.liferay.portlet.shopping.NoSuchItemPriceException if a matching shopping item price could not be found
306             */
307            @Override
308            public ShoppingItemPrice findByItemId_Last(long itemId,
309                    OrderByComparator<ShoppingItemPrice> orderByComparator)
310                    throws NoSuchItemPriceException {
311                    ShoppingItemPrice shoppingItemPrice = fetchByItemId_Last(itemId,
312                                    orderByComparator);
313    
314                    if (shoppingItemPrice != null) {
315                            return shoppingItemPrice;
316                    }
317    
318                    StringBundler msg = new StringBundler(4);
319    
320                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
321    
322                    msg.append("itemId=");
323                    msg.append(itemId);
324    
325                    msg.append(StringPool.CLOSE_CURLY_BRACE);
326    
327                    throw new NoSuchItemPriceException(msg.toString());
328            }
329    
330            /**
331             * Returns the last shopping item price in the ordered set where itemId = &#63;.
332             *
333             * @param itemId the item ID
334             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
335             * @return the last matching shopping item price, or <code>null</code> if a matching shopping item price could not be found
336             */
337            @Override
338            public ShoppingItemPrice fetchByItemId_Last(long itemId,
339                    OrderByComparator<ShoppingItemPrice> orderByComparator) {
340                    int count = countByItemId(itemId);
341    
342                    if (count == 0) {
343                            return null;
344                    }
345    
346                    List<ShoppingItemPrice> list = findByItemId(itemId, count - 1, count,
347                                    orderByComparator);
348    
349                    if (!list.isEmpty()) {
350                            return list.get(0);
351                    }
352    
353                    return null;
354            }
355    
356            /**
357             * Returns the shopping item prices before and after the current shopping item price in the ordered set where itemId = &#63;.
358             *
359             * @param itemPriceId the primary key of the current shopping item price
360             * @param itemId the item ID
361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
362             * @return the previous, current, and next shopping item price
363             * @throws com.liferay.portlet.shopping.NoSuchItemPriceException if a shopping item price with the primary key could not be found
364             */
365            @Override
366            public ShoppingItemPrice[] findByItemId_PrevAndNext(long itemPriceId,
367                    long itemId, OrderByComparator<ShoppingItemPrice> orderByComparator)
368                    throws NoSuchItemPriceException {
369                    ShoppingItemPrice shoppingItemPrice = findByPrimaryKey(itemPriceId);
370    
371                    Session session = null;
372    
373                    try {
374                            session = openSession();
375    
376                            ShoppingItemPrice[] array = new ShoppingItemPriceImpl[3];
377    
378                            array[0] = getByItemId_PrevAndNext(session, shoppingItemPrice,
379                                            itemId, orderByComparator, true);
380    
381                            array[1] = shoppingItemPrice;
382    
383                            array[2] = getByItemId_PrevAndNext(session, shoppingItemPrice,
384                                            itemId, orderByComparator, false);
385    
386                            return array;
387                    }
388                    catch (Exception e) {
389                            throw processException(e);
390                    }
391                    finally {
392                            closeSession(session);
393                    }
394            }
395    
396            protected ShoppingItemPrice getByItemId_PrevAndNext(Session session,
397                    ShoppingItemPrice shoppingItemPrice, long itemId,
398                    OrderByComparator<ShoppingItemPrice> orderByComparator, boolean previous) {
399                    StringBundler query = null;
400    
401                    if (orderByComparator != null) {
402                            query = new StringBundler(6 +
403                                            (orderByComparator.getOrderByFields().length * 6));
404                    }
405                    else {
406                            query = new StringBundler(3);
407                    }
408    
409                    query.append(_SQL_SELECT_SHOPPINGITEMPRICE_WHERE);
410    
411                    query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
412    
413                    if (orderByComparator != null) {
414                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
415    
416                            if (orderByConditionFields.length > 0) {
417                                    query.append(WHERE_AND);
418                            }
419    
420                            for (int i = 0; i < orderByConditionFields.length; i++) {
421                                    query.append(_ORDER_BY_ENTITY_ALIAS);
422                                    query.append(orderByConditionFields[i]);
423    
424                                    if ((i + 1) < orderByConditionFields.length) {
425                                            if (orderByComparator.isAscending() ^ previous) {
426                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
427                                            }
428                                            else {
429                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
430                                            }
431                                    }
432                                    else {
433                                            if (orderByComparator.isAscending() ^ previous) {
434                                                    query.append(WHERE_GREATER_THAN);
435                                            }
436                                            else {
437                                                    query.append(WHERE_LESSER_THAN);
438                                            }
439                                    }
440                            }
441    
442                            query.append(ORDER_BY_CLAUSE);
443    
444                            String[] orderByFields = orderByComparator.getOrderByFields();
445    
446                            for (int i = 0; i < orderByFields.length; i++) {
447                                    query.append(_ORDER_BY_ENTITY_ALIAS);
448                                    query.append(orderByFields[i]);
449    
450                                    if ((i + 1) < orderByFields.length) {
451                                            if (orderByComparator.isAscending() ^ previous) {
452                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
453                                            }
454                                            else {
455                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
456                                            }
457                                    }
458                                    else {
459                                            if (orderByComparator.isAscending() ^ previous) {
460                                                    query.append(ORDER_BY_ASC);
461                                            }
462                                            else {
463                                                    query.append(ORDER_BY_DESC);
464                                            }
465                                    }
466                            }
467                    }
468                    else {
469                            query.append(ShoppingItemPriceModelImpl.ORDER_BY_JPQL);
470                    }
471    
472                    String sql = query.toString();
473    
474                    Query q = session.createQuery(sql);
475    
476                    q.setFirstResult(0);
477                    q.setMaxResults(2);
478    
479                    QueryPos qPos = QueryPos.getInstance(q);
480    
481                    qPos.add(itemId);
482    
483                    if (orderByComparator != null) {
484                            Object[] values = orderByComparator.getOrderByConditionValues(shoppingItemPrice);
485    
486                            for (Object value : values) {
487                                    qPos.add(value);
488                            }
489                    }
490    
491                    List<ShoppingItemPrice> list = q.list();
492    
493                    if (list.size() == 2) {
494                            return list.get(1);
495                    }
496                    else {
497                            return null;
498                    }
499            }
500    
501            /**
502             * Removes all the shopping item prices where itemId = &#63; from the database.
503             *
504             * @param itemId the item ID
505             */
506            @Override
507            public void removeByItemId(long itemId) {
508                    for (ShoppingItemPrice shoppingItemPrice : findByItemId(itemId,
509                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
510                            remove(shoppingItemPrice);
511                    }
512            }
513    
514            /**
515             * Returns the number of shopping item prices where itemId = &#63;.
516             *
517             * @param itemId the item ID
518             * @return the number of matching shopping item prices
519             */
520            @Override
521            public int countByItemId(long itemId) {
522                    FinderPath finderPath = FINDER_PATH_COUNT_BY_ITEMID;
523    
524                    Object[] finderArgs = new Object[] { itemId };
525    
526                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
527                                    this);
528    
529                    if (count == null) {
530                            StringBundler query = new StringBundler(2);
531    
532                            query.append(_SQL_COUNT_SHOPPINGITEMPRICE_WHERE);
533    
534                            query.append(_FINDER_COLUMN_ITEMID_ITEMID_2);
535    
536                            String sql = query.toString();
537    
538                            Session session = null;
539    
540                            try {
541                                    session = openSession();
542    
543                                    Query q = session.createQuery(sql);
544    
545                                    QueryPos qPos = QueryPos.getInstance(q);
546    
547                                    qPos.add(itemId);
548    
549                                    count = (Long)q.uniqueResult();
550    
551                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
552                            }
553                            catch (Exception e) {
554                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
555    
556                                    throw processException(e);
557                            }
558                            finally {
559                                    closeSession(session);
560                            }
561                    }
562    
563                    return count.intValue();
564            }
565    
566            private static final String _FINDER_COLUMN_ITEMID_ITEMID_2 = "shoppingItemPrice.itemId = ?";
567    
568            public ShoppingItemPricePersistenceImpl() {
569                    setModelClass(ShoppingItemPrice.class);
570            }
571    
572            /**
573             * Caches the shopping item price in the entity cache if it is enabled.
574             *
575             * @param shoppingItemPrice the shopping item price
576             */
577            @Override
578            public void cacheResult(ShoppingItemPrice shoppingItemPrice) {
579                    EntityCacheUtil.putResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
580                            ShoppingItemPriceImpl.class, shoppingItemPrice.getPrimaryKey(),
581                            shoppingItemPrice);
582    
583                    shoppingItemPrice.resetOriginalValues();
584            }
585    
586            /**
587             * Caches the shopping item prices in the entity cache if it is enabled.
588             *
589             * @param shoppingItemPrices the shopping item prices
590             */
591            @Override
592            public void cacheResult(List<ShoppingItemPrice> shoppingItemPrices) {
593                    for (ShoppingItemPrice shoppingItemPrice : shoppingItemPrices) {
594                            if (EntityCacheUtil.getResult(
595                                                    ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
596                                                    ShoppingItemPriceImpl.class,
597                                                    shoppingItemPrice.getPrimaryKey()) == null) {
598                                    cacheResult(shoppingItemPrice);
599                            }
600                            else {
601                                    shoppingItemPrice.resetOriginalValues();
602                            }
603                    }
604            }
605    
606            /**
607             * Clears the cache for all shopping item prices.
608             *
609             * <p>
610             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
611             * </p>
612             */
613            @Override
614            public void clearCache() {
615                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
616                            CacheRegistryUtil.clear(ShoppingItemPriceImpl.class.getName());
617                    }
618    
619                    EntityCacheUtil.clearCache(ShoppingItemPriceImpl.class);
620    
621                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
622                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
623                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
624            }
625    
626            /**
627             * Clears the cache for the shopping item price.
628             *
629             * <p>
630             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
631             * </p>
632             */
633            @Override
634            public void clearCache(ShoppingItemPrice shoppingItemPrice) {
635                    EntityCacheUtil.removeResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
636                            ShoppingItemPriceImpl.class, shoppingItemPrice.getPrimaryKey());
637    
638                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
639                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
640            }
641    
642            @Override
643            public void clearCache(List<ShoppingItemPrice> shoppingItemPrices) {
644                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
645                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
646    
647                    for (ShoppingItemPrice shoppingItemPrice : shoppingItemPrices) {
648                            EntityCacheUtil.removeResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
649                                    ShoppingItemPriceImpl.class, shoppingItemPrice.getPrimaryKey());
650                    }
651            }
652    
653            /**
654             * Creates a new shopping item price with the primary key. Does not add the shopping item price to the database.
655             *
656             * @param itemPriceId the primary key for the new shopping item price
657             * @return the new shopping item price
658             */
659            @Override
660            public ShoppingItemPrice create(long itemPriceId) {
661                    ShoppingItemPrice shoppingItemPrice = new ShoppingItemPriceImpl();
662    
663                    shoppingItemPrice.setNew(true);
664                    shoppingItemPrice.setPrimaryKey(itemPriceId);
665    
666                    return shoppingItemPrice;
667            }
668    
669            /**
670             * Removes the shopping item price with the primary key from the database. Also notifies the appropriate model listeners.
671             *
672             * @param itemPriceId the primary key of the shopping item price
673             * @return the shopping item price that was removed
674             * @throws com.liferay.portlet.shopping.NoSuchItemPriceException if a shopping item price with the primary key could not be found
675             */
676            @Override
677            public ShoppingItemPrice remove(long itemPriceId)
678                    throws NoSuchItemPriceException {
679                    return remove((Serializable)itemPriceId);
680            }
681    
682            /**
683             * Removes the shopping item price with the primary key from the database. Also notifies the appropriate model listeners.
684             *
685             * @param primaryKey the primary key of the shopping item price
686             * @return the shopping item price that was removed
687             * @throws com.liferay.portlet.shopping.NoSuchItemPriceException if a shopping item price with the primary key could not be found
688             */
689            @Override
690            public ShoppingItemPrice remove(Serializable primaryKey)
691                    throws NoSuchItemPriceException {
692                    Session session = null;
693    
694                    try {
695                            session = openSession();
696    
697                            ShoppingItemPrice shoppingItemPrice = (ShoppingItemPrice)session.get(ShoppingItemPriceImpl.class,
698                                            primaryKey);
699    
700                            if (shoppingItemPrice == null) {
701                                    if (_log.isWarnEnabled()) {
702                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
703                                    }
704    
705                                    throw new NoSuchItemPriceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
706                                            primaryKey);
707                            }
708    
709                            return remove(shoppingItemPrice);
710                    }
711                    catch (NoSuchItemPriceException nsee) {
712                            throw nsee;
713                    }
714                    catch (Exception e) {
715                            throw processException(e);
716                    }
717                    finally {
718                            closeSession(session);
719                    }
720            }
721    
722            @Override
723            protected ShoppingItemPrice removeImpl(ShoppingItemPrice shoppingItemPrice) {
724                    shoppingItemPrice = toUnwrappedModel(shoppingItemPrice);
725    
726                    Session session = null;
727    
728                    try {
729                            session = openSession();
730    
731                            if (!session.contains(shoppingItemPrice)) {
732                                    shoppingItemPrice = (ShoppingItemPrice)session.get(ShoppingItemPriceImpl.class,
733                                                    shoppingItemPrice.getPrimaryKeyObj());
734                            }
735    
736                            if (shoppingItemPrice != null) {
737                                    session.delete(shoppingItemPrice);
738                            }
739                    }
740                    catch (Exception e) {
741                            throw processException(e);
742                    }
743                    finally {
744                            closeSession(session);
745                    }
746    
747                    if (shoppingItemPrice != null) {
748                            clearCache(shoppingItemPrice);
749                    }
750    
751                    return shoppingItemPrice;
752            }
753    
754            @Override
755            public ShoppingItemPrice updateImpl(
756                    com.liferay.portlet.shopping.model.ShoppingItemPrice shoppingItemPrice) {
757                    shoppingItemPrice = toUnwrappedModel(shoppingItemPrice);
758    
759                    boolean isNew = shoppingItemPrice.isNew();
760    
761                    ShoppingItemPriceModelImpl shoppingItemPriceModelImpl = (ShoppingItemPriceModelImpl)shoppingItemPrice;
762    
763                    Session session = null;
764    
765                    try {
766                            session = openSession();
767    
768                            if (shoppingItemPrice.isNew()) {
769                                    session.save(shoppingItemPrice);
770    
771                                    shoppingItemPrice.setNew(false);
772                            }
773                            else {
774                                    session.merge(shoppingItemPrice);
775                            }
776                    }
777                    catch (Exception e) {
778                            throw processException(e);
779                    }
780                    finally {
781                            closeSession(session);
782                    }
783    
784                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
785    
786                    if (isNew || !ShoppingItemPriceModelImpl.COLUMN_BITMASK_ENABLED) {
787                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
788                    }
789    
790                    else {
791                            if ((shoppingItemPriceModelImpl.getColumnBitmask() &
792                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID.getColumnBitmask()) != 0) {
793                                    Object[] args = new Object[] {
794                                                    shoppingItemPriceModelImpl.getOriginalItemId()
795                                            };
796    
797                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ITEMID, args);
798                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID,
799                                            args);
800    
801                                    args = new Object[] { shoppingItemPriceModelImpl.getItemId() };
802    
803                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ITEMID, args);
804                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID,
805                                            args);
806                            }
807                    }
808    
809                    EntityCacheUtil.putResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
810                            ShoppingItemPriceImpl.class, shoppingItemPrice.getPrimaryKey(),
811                            shoppingItemPrice, false);
812    
813                    shoppingItemPrice.resetOriginalValues();
814    
815                    return shoppingItemPrice;
816            }
817    
818            protected ShoppingItemPrice toUnwrappedModel(
819                    ShoppingItemPrice shoppingItemPrice) {
820                    if (shoppingItemPrice instanceof ShoppingItemPriceImpl) {
821                            return shoppingItemPrice;
822                    }
823    
824                    ShoppingItemPriceImpl shoppingItemPriceImpl = new ShoppingItemPriceImpl();
825    
826                    shoppingItemPriceImpl.setNew(shoppingItemPrice.isNew());
827                    shoppingItemPriceImpl.setPrimaryKey(shoppingItemPrice.getPrimaryKey());
828    
829                    shoppingItemPriceImpl.setItemPriceId(shoppingItemPrice.getItemPriceId());
830                    shoppingItemPriceImpl.setItemId(shoppingItemPrice.getItemId());
831                    shoppingItemPriceImpl.setMinQuantity(shoppingItemPrice.getMinQuantity());
832                    shoppingItemPriceImpl.setMaxQuantity(shoppingItemPrice.getMaxQuantity());
833                    shoppingItemPriceImpl.setPrice(shoppingItemPrice.getPrice());
834                    shoppingItemPriceImpl.setDiscount(shoppingItemPrice.getDiscount());
835                    shoppingItemPriceImpl.setTaxable(shoppingItemPrice.isTaxable());
836                    shoppingItemPriceImpl.setShipping(shoppingItemPrice.getShipping());
837                    shoppingItemPriceImpl.setUseShippingFormula(shoppingItemPrice.isUseShippingFormula());
838                    shoppingItemPriceImpl.setStatus(shoppingItemPrice.getStatus());
839    
840                    return shoppingItemPriceImpl;
841            }
842    
843            /**
844             * Returns the shopping item price with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
845             *
846             * @param primaryKey the primary key of the shopping item price
847             * @return the shopping item price
848             * @throws com.liferay.portlet.shopping.NoSuchItemPriceException if a shopping item price with the primary key could not be found
849             */
850            @Override
851            public ShoppingItemPrice findByPrimaryKey(Serializable primaryKey)
852                    throws NoSuchItemPriceException {
853                    ShoppingItemPrice shoppingItemPrice = fetchByPrimaryKey(primaryKey);
854    
855                    if (shoppingItemPrice == null) {
856                            if (_log.isWarnEnabled()) {
857                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
858                            }
859    
860                            throw new NoSuchItemPriceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
861                                    primaryKey);
862                    }
863    
864                    return shoppingItemPrice;
865            }
866    
867            /**
868             * Returns the shopping item price with the primary key or throws a {@link com.liferay.portlet.shopping.NoSuchItemPriceException} if it could not be found.
869             *
870             * @param itemPriceId the primary key of the shopping item price
871             * @return the shopping item price
872             * @throws com.liferay.portlet.shopping.NoSuchItemPriceException if a shopping item price with the primary key could not be found
873             */
874            @Override
875            public ShoppingItemPrice findByPrimaryKey(long itemPriceId)
876                    throws NoSuchItemPriceException {
877                    return findByPrimaryKey((Serializable)itemPriceId);
878            }
879    
880            /**
881             * Returns the shopping item price with the primary key or returns <code>null</code> if it could not be found.
882             *
883             * @param primaryKey the primary key of the shopping item price
884             * @return the shopping item price, or <code>null</code> if a shopping item price with the primary key could not be found
885             */
886            @Override
887            public ShoppingItemPrice fetchByPrimaryKey(Serializable primaryKey) {
888                    ShoppingItemPrice shoppingItemPrice = (ShoppingItemPrice)EntityCacheUtil.getResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
889                                    ShoppingItemPriceImpl.class, primaryKey);
890    
891                    if (shoppingItemPrice == _nullShoppingItemPrice) {
892                            return null;
893                    }
894    
895                    if (shoppingItemPrice == null) {
896                            Session session = null;
897    
898                            try {
899                                    session = openSession();
900    
901                                    shoppingItemPrice = (ShoppingItemPrice)session.get(ShoppingItemPriceImpl.class,
902                                                    primaryKey);
903    
904                                    if (shoppingItemPrice != null) {
905                                            cacheResult(shoppingItemPrice);
906                                    }
907                                    else {
908                                            EntityCacheUtil.putResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
909                                                    ShoppingItemPriceImpl.class, primaryKey,
910                                                    _nullShoppingItemPrice);
911                                    }
912                            }
913                            catch (Exception e) {
914                                    EntityCacheUtil.removeResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
915                                            ShoppingItemPriceImpl.class, primaryKey);
916    
917                                    throw processException(e);
918                            }
919                            finally {
920                                    closeSession(session);
921                            }
922                    }
923    
924                    return shoppingItemPrice;
925            }
926    
927            /**
928             * Returns the shopping item price with the primary key or returns <code>null</code> if it could not be found.
929             *
930             * @param itemPriceId the primary key of the shopping item price
931             * @return the shopping item price, or <code>null</code> if a shopping item price with the primary key could not be found
932             */
933            @Override
934            public ShoppingItemPrice fetchByPrimaryKey(long itemPriceId) {
935                    return fetchByPrimaryKey((Serializable)itemPriceId);
936            }
937    
938            @Override
939            public Map<Serializable, ShoppingItemPrice> fetchByPrimaryKeys(
940                    Set<Serializable> primaryKeys) {
941                    if (primaryKeys.isEmpty()) {
942                            return Collections.emptyMap();
943                    }
944    
945                    Map<Serializable, ShoppingItemPrice> map = new HashMap<Serializable, ShoppingItemPrice>();
946    
947                    if (primaryKeys.size() == 1) {
948                            Iterator<Serializable> iterator = primaryKeys.iterator();
949    
950                            Serializable primaryKey = iterator.next();
951    
952                            ShoppingItemPrice shoppingItemPrice = fetchByPrimaryKey(primaryKey);
953    
954                            if (shoppingItemPrice != null) {
955                                    map.put(primaryKey, shoppingItemPrice);
956                            }
957    
958                            return map;
959                    }
960    
961                    Set<Serializable> uncachedPrimaryKeys = null;
962    
963                    for (Serializable primaryKey : primaryKeys) {
964                            ShoppingItemPrice shoppingItemPrice = (ShoppingItemPrice)EntityCacheUtil.getResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
965                                            ShoppingItemPriceImpl.class, primaryKey);
966    
967                            if (shoppingItemPrice == null) {
968                                    if (uncachedPrimaryKeys == null) {
969                                            uncachedPrimaryKeys = new HashSet<Serializable>();
970                                    }
971    
972                                    uncachedPrimaryKeys.add(primaryKey);
973                            }
974                            else {
975                                    map.put(primaryKey, shoppingItemPrice);
976                            }
977                    }
978    
979                    if (uncachedPrimaryKeys == null) {
980                            return map;
981                    }
982    
983                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
984                                    1);
985    
986                    query.append(_SQL_SELECT_SHOPPINGITEMPRICE_WHERE_PKS_IN);
987    
988                    for (Serializable primaryKey : uncachedPrimaryKeys) {
989                            query.append(String.valueOf(primaryKey));
990    
991                            query.append(StringPool.COMMA);
992                    }
993    
994                    query.setIndex(query.index() - 1);
995    
996                    query.append(StringPool.CLOSE_PARENTHESIS);
997    
998                    String sql = query.toString();
999    
1000                    Session session = null;
1001    
1002                    try {
1003                            session = openSession();
1004    
1005                            Query q = session.createQuery(sql);
1006    
1007                            for (ShoppingItemPrice shoppingItemPrice : (List<ShoppingItemPrice>)q.list()) {
1008                                    map.put(shoppingItemPrice.getPrimaryKeyObj(), shoppingItemPrice);
1009    
1010                                    cacheResult(shoppingItemPrice);
1011    
1012                                    uncachedPrimaryKeys.remove(shoppingItemPrice.getPrimaryKeyObj());
1013                            }
1014    
1015                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1016                                    EntityCacheUtil.putResult(ShoppingItemPriceModelImpl.ENTITY_CACHE_ENABLED,
1017                                            ShoppingItemPriceImpl.class, primaryKey,
1018                                            _nullShoppingItemPrice);
1019                            }
1020                    }
1021                    catch (Exception e) {
1022                            throw processException(e);
1023                    }
1024                    finally {
1025                            closeSession(session);
1026                    }
1027    
1028                    return map;
1029            }
1030    
1031            /**
1032             * Returns all the shopping item prices.
1033             *
1034             * @return the shopping item prices
1035             */
1036            @Override
1037            public List<ShoppingItemPrice> findAll() {
1038                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1039            }
1040    
1041            /**
1042             * Returns a range of all the shopping item prices.
1043             *
1044             * <p>
1045             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1046             * </p>
1047             *
1048             * @param start the lower bound of the range of shopping item prices
1049             * @param end the upper bound of the range of shopping item prices (not inclusive)
1050             * @return the range of shopping item prices
1051             */
1052            @Override
1053            public List<ShoppingItemPrice> findAll(int start, int end) {
1054                    return findAll(start, end, null);
1055            }
1056    
1057            /**
1058             * Returns an ordered range of all the shopping item prices.
1059             *
1060             * <p>
1061             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.shopping.model.impl.ShoppingItemPriceModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1062             * </p>
1063             *
1064             * @param start the lower bound of the range of shopping item prices
1065             * @param end the upper bound of the range of shopping item prices (not inclusive)
1066             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1067             * @return the ordered range of shopping item prices
1068             */
1069            @Override
1070            public List<ShoppingItemPrice> findAll(int start, int end,
1071                    OrderByComparator<ShoppingItemPrice> orderByComparator) {
1072                    boolean pagination = true;
1073                    FinderPath finderPath = null;
1074                    Object[] finderArgs = null;
1075    
1076                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1077                                    (orderByComparator == null)) {
1078                            pagination = false;
1079                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1080                            finderArgs = FINDER_ARGS_EMPTY;
1081                    }
1082                    else {
1083                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1084                            finderArgs = new Object[] { start, end, orderByComparator };
1085                    }
1086    
1087                    List<ShoppingItemPrice> list = (List<ShoppingItemPrice>)FinderCacheUtil.getResult(finderPath,
1088                                    finderArgs, this);
1089    
1090                    if (list == null) {
1091                            StringBundler query = null;
1092                            String sql = null;
1093    
1094                            if (orderByComparator != null) {
1095                                    query = new StringBundler(2 +
1096                                                    (orderByComparator.getOrderByFields().length * 3));
1097    
1098                                    query.append(_SQL_SELECT_SHOPPINGITEMPRICE);
1099    
1100                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1101                                            orderByComparator);
1102    
1103                                    sql = query.toString();
1104                            }
1105                            else {
1106                                    sql = _SQL_SELECT_SHOPPINGITEMPRICE;
1107    
1108                                    if (pagination) {
1109                                            sql = sql.concat(ShoppingItemPriceModelImpl.ORDER_BY_JPQL);
1110                                    }
1111                            }
1112    
1113                            Session session = null;
1114    
1115                            try {
1116                                    session = openSession();
1117    
1118                                    Query q = session.createQuery(sql);
1119    
1120                                    if (!pagination) {
1121                                            list = (List<ShoppingItemPrice>)QueryUtil.list(q,
1122                                                            getDialect(), start, end, false);
1123    
1124                                            Collections.sort(list);
1125    
1126                                            list = Collections.unmodifiableList(list);
1127                                    }
1128                                    else {
1129                                            list = (List<ShoppingItemPrice>)QueryUtil.list(q,
1130                                                            getDialect(), start, end);
1131                                    }
1132    
1133                                    cacheResult(list);
1134    
1135                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1136                            }
1137                            catch (Exception e) {
1138                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1139    
1140                                    throw processException(e);
1141                            }
1142                            finally {
1143                                    closeSession(session);
1144                            }
1145                    }
1146    
1147                    return list;
1148            }
1149    
1150            /**
1151             * Removes all the shopping item prices from the database.
1152             *
1153             */
1154            @Override
1155            public void removeAll() {
1156                    for (ShoppingItemPrice shoppingItemPrice : findAll()) {
1157                            remove(shoppingItemPrice);
1158                    }
1159            }
1160    
1161            /**
1162             * Returns the number of shopping item prices.
1163             *
1164             * @return the number of shopping item prices
1165             */
1166            @Override
1167            public int countAll() {
1168                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1169                                    FINDER_ARGS_EMPTY, this);
1170    
1171                    if (count == null) {
1172                            Session session = null;
1173    
1174                            try {
1175                                    session = openSession();
1176    
1177                                    Query q = session.createQuery(_SQL_COUNT_SHOPPINGITEMPRICE);
1178    
1179                                    count = (Long)q.uniqueResult();
1180    
1181                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1182                                            FINDER_ARGS_EMPTY, count);
1183                            }
1184                            catch (Exception e) {
1185                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1186                                            FINDER_ARGS_EMPTY);
1187    
1188                                    throw processException(e);
1189                            }
1190                            finally {
1191                                    closeSession(session);
1192                            }
1193                    }
1194    
1195                    return count.intValue();
1196            }
1197    
1198            /**
1199             * Initializes the shopping item price persistence.
1200             */
1201            public void afterPropertiesSet() {
1202            }
1203    
1204            public void destroy() {
1205                    EntityCacheUtil.removeCache(ShoppingItemPriceImpl.class.getName());
1206                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1207                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1208                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1209            }
1210    
1211            private static final String _SQL_SELECT_SHOPPINGITEMPRICE = "SELECT shoppingItemPrice FROM ShoppingItemPrice shoppingItemPrice";
1212            private static final String _SQL_SELECT_SHOPPINGITEMPRICE_WHERE_PKS_IN = "SELECT shoppingItemPrice FROM ShoppingItemPrice shoppingItemPrice WHERE itemPriceId IN (";
1213            private static final String _SQL_SELECT_SHOPPINGITEMPRICE_WHERE = "SELECT shoppingItemPrice FROM ShoppingItemPrice shoppingItemPrice WHERE ";
1214            private static final String _SQL_COUNT_SHOPPINGITEMPRICE = "SELECT COUNT(shoppingItemPrice) FROM ShoppingItemPrice shoppingItemPrice";
1215            private static final String _SQL_COUNT_SHOPPINGITEMPRICE_WHERE = "SELECT COUNT(shoppingItemPrice) FROM ShoppingItemPrice shoppingItemPrice WHERE ";
1216            private static final String _ORDER_BY_ENTITY_ALIAS = "shoppingItemPrice.";
1217            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShoppingItemPrice exists with the primary key ";
1218            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShoppingItemPrice exists with the key {";
1219            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1220            private static final Log _log = LogFactoryUtil.getLog(ShoppingItemPricePersistenceImpl.class);
1221            private static final ShoppingItemPrice _nullShoppingItemPrice = new ShoppingItemPriceImpl() {
1222                            @Override
1223                            public Object clone() {
1224                                    return this;
1225                            }
1226    
1227                            @Override
1228                            public CacheModel<ShoppingItemPrice> toCacheModel() {
1229                                    return _nullShoppingItemPriceCacheModel;
1230                            }
1231                    };
1232    
1233            private static final CacheModel<ShoppingItemPrice> _nullShoppingItemPriceCacheModel =
1234                    new CacheModel<ShoppingItemPrice>() {
1235                            @Override
1236                            public ShoppingItemPrice toEntityModel() {
1237                                    return _nullShoppingItemPrice;
1238                            }
1239                    };
1240    }