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