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.mobiledevicerules.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
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.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.BatchSessionUtil;
041    import com.liferay.portal.service.persistence.ResourcePersistence;
042    import com.liferay.portal.service.persistence.UserPersistence;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.mobiledevicerules.NoSuchActionException;
046    import com.liferay.portlet.mobiledevicerules.model.MDRAction;
047    import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionImpl;
048    import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionModelImpl;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    
056    /**
057     * The persistence implementation for the m d r action service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Edward C. Han
064     * @see MDRActionPersistence
065     * @see MDRActionUtil
066     * @generated
067     */
068    public class MDRActionPersistenceImpl extends BasePersistenceImpl<MDRAction>
069            implements MDRActionPersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link MDRActionUtil} to access the m d r action persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = MDRActionImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
081                            MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
082                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
083                            new String[] {
084                                    String.class.getName(),
085                                    
086                            "java.lang.Integer", "java.lang.Integer",
087                                    "com.liferay.portal.kernel.util.OrderByComparator"
088                            });
089            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
090                            MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
092                            new String[] { String.class.getName() },
093                            MDRActionModelImpl.UUID_COLUMN_BITMASK);
094            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
095                            MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
097                            new String[] { String.class.getName() });
098            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
099                            MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
100                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
101                            new String[] { String.class.getName(), Long.class.getName() },
102                            MDRActionModelImpl.UUID_COLUMN_BITMASK |
103                            MDRActionModelImpl.GROUPID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
105                            MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
107                            new String[] { String.class.getName(), Long.class.getName() });
108            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
109                    new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
110                            MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
111                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
112                            "findByRuleGroupInstanceId",
113                            new String[] {
114                                    Long.class.getName(),
115                                    
116                            "java.lang.Integer", "java.lang.Integer",
117                                    "com.liferay.portal.kernel.util.OrderByComparator"
118                            });
119            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
120                    new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
121                            MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
123                            "findByRuleGroupInstanceId", new String[] { Long.class.getName() },
124                            MDRActionModelImpl.RULEGROUPINSTANCEID_COLUMN_BITMASK);
125            public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
126                            MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
127                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
128                            "countByRuleGroupInstanceId", new String[] { Long.class.getName() });
129            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
130                            MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
131                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
132            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
133                            MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
134                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
135            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
136                            MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
137                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
138    
139            /**
140             * Caches the m d r action in the entity cache if it is enabled.
141             *
142             * @param mdrAction the m d r action
143             */
144            public void cacheResult(MDRAction mdrAction) {
145                    EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
146                            MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
147    
148                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
149                            new Object[] {
150                                    mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
151                            }, mdrAction);
152    
153                    mdrAction.resetOriginalValues();
154            }
155    
156            /**
157             * Caches the m d r actions in the entity cache if it is enabled.
158             *
159             * @param mdrActions the m d r actions
160             */
161            public void cacheResult(List<MDRAction> mdrActions) {
162                    for (MDRAction mdrAction : mdrActions) {
163                            if (EntityCacheUtil.getResult(
164                                                    MDRActionModelImpl.ENTITY_CACHE_ENABLED,
165                                                    MDRActionImpl.class, mdrAction.getPrimaryKey()) == null) {
166                                    cacheResult(mdrAction);
167                            }
168                            else {
169                                    mdrAction.resetOriginalValues();
170                            }
171                    }
172            }
173    
174            /**
175             * Clears the cache for all m d r actions.
176             *
177             * <p>
178             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
179             * </p>
180             */
181            @Override
182            public void clearCache() {
183                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
184                            CacheRegistryUtil.clear(MDRActionImpl.class.getName());
185                    }
186    
187                    EntityCacheUtil.clearCache(MDRActionImpl.class.getName());
188    
189                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
190                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
191                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
192            }
193    
194            /**
195             * Clears the cache for the m d r action.
196             *
197             * <p>
198             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
199             * </p>
200             */
201            @Override
202            public void clearCache(MDRAction mdrAction) {
203                    EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
204                            MDRActionImpl.class, mdrAction.getPrimaryKey());
205    
206                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
207                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
208    
209                    clearUniqueFindersCache(mdrAction);
210            }
211    
212            @Override
213            public void clearCache(List<MDRAction> mdrActions) {
214                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
215                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
216    
217                    for (MDRAction mdrAction : mdrActions) {
218                            EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
219                                    MDRActionImpl.class, mdrAction.getPrimaryKey());
220    
221                            clearUniqueFindersCache(mdrAction);
222                    }
223            }
224    
225            protected void clearUniqueFindersCache(MDRAction mdrAction) {
226                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
227                            new Object[] {
228                                    mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
229                            });
230            }
231    
232            /**
233             * Creates a new m d r action with the primary key. Does not add the m d r action to the database.
234             *
235             * @param actionId the primary key for the new m d r action
236             * @return the new m d r action
237             */
238            public MDRAction create(long actionId) {
239                    MDRAction mdrAction = new MDRActionImpl();
240    
241                    mdrAction.setNew(true);
242                    mdrAction.setPrimaryKey(actionId);
243    
244                    String uuid = PortalUUIDUtil.generate();
245    
246                    mdrAction.setUuid(uuid);
247    
248                    return mdrAction;
249            }
250    
251            /**
252             * Removes the m d r action with the primary key from the database. Also notifies the appropriate model listeners.
253             *
254             * @param actionId the primary key of the m d r action
255             * @return the m d r action that was removed
256             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a m d r action with the primary key could not be found
257             * @throws SystemException if a system exception occurred
258             */
259            public MDRAction remove(long actionId)
260                    throws NoSuchActionException, SystemException {
261                    return remove(Long.valueOf(actionId));
262            }
263    
264            /**
265             * Removes the m d r action with the primary key from the database. Also notifies the appropriate model listeners.
266             *
267             * @param primaryKey the primary key of the m d r action
268             * @return the m d r action that was removed
269             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a m d r action with the primary key could not be found
270             * @throws SystemException if a system exception occurred
271             */
272            @Override
273            public MDRAction remove(Serializable primaryKey)
274                    throws NoSuchActionException, SystemException {
275                    Session session = null;
276    
277                    try {
278                            session = openSession();
279    
280                            MDRAction mdrAction = (MDRAction)session.get(MDRActionImpl.class,
281                                            primaryKey);
282    
283                            if (mdrAction == null) {
284                                    if (_log.isWarnEnabled()) {
285                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
286                                    }
287    
288                                    throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
289                                            primaryKey);
290                            }
291    
292                            return remove(mdrAction);
293                    }
294                    catch (NoSuchActionException nsee) {
295                            throw nsee;
296                    }
297                    catch (Exception e) {
298                            throw processException(e);
299                    }
300                    finally {
301                            closeSession(session);
302                    }
303            }
304    
305            @Override
306            protected MDRAction removeImpl(MDRAction mdrAction)
307                    throws SystemException {
308                    mdrAction = toUnwrappedModel(mdrAction);
309    
310                    Session session = null;
311    
312                    try {
313                            session = openSession();
314    
315                            BatchSessionUtil.delete(session, mdrAction);
316                    }
317                    catch (Exception e) {
318                            throw processException(e);
319                    }
320                    finally {
321                            closeSession(session);
322                    }
323    
324                    clearCache(mdrAction);
325    
326                    return mdrAction;
327            }
328    
329            @Override
330            public MDRAction updateImpl(
331                    com.liferay.portlet.mobiledevicerules.model.MDRAction mdrAction,
332                    boolean merge) throws SystemException {
333                    mdrAction = toUnwrappedModel(mdrAction);
334    
335                    boolean isNew = mdrAction.isNew();
336    
337                    MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
338    
339                    if (Validator.isNull(mdrAction.getUuid())) {
340                            String uuid = PortalUUIDUtil.generate();
341    
342                            mdrAction.setUuid(uuid);
343                    }
344    
345                    Session session = null;
346    
347                    try {
348                            session = openSession();
349    
350                            BatchSessionUtil.update(session, mdrAction, merge);
351    
352                            mdrAction.setNew(false);
353                    }
354                    catch (Exception e) {
355                            throw processException(e);
356                    }
357                    finally {
358                            closeSession(session);
359                    }
360    
361                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
362    
363                    if (isNew || !MDRActionModelImpl.COLUMN_BITMASK_ENABLED) {
364                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
365                    }
366    
367                    else {
368                            if ((mdrActionModelImpl.getColumnBitmask() &
369                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
370                                    Object[] args = new Object[] {
371                                                    mdrActionModelImpl.getOriginalUuid()
372                                            };
373    
374                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
375                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
376                                            args);
377    
378                                    args = new Object[] { mdrActionModelImpl.getUuid() };
379    
380                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
381                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
382                                            args);
383                            }
384    
385                            if ((mdrActionModelImpl.getColumnBitmask() &
386                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID.getColumnBitmask()) != 0) {
387                                    Object[] args = new Object[] {
388                                                    Long.valueOf(mdrActionModelImpl.getOriginalRuleGroupInstanceId())
389                                            };
390    
391                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
392                                            args);
393                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
394                                            args);
395    
396                                    args = new Object[] {
397                                                    Long.valueOf(mdrActionModelImpl.getRuleGroupInstanceId())
398                                            };
399    
400                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
401                                            args);
402                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
403                                            args);
404                            }
405                    }
406    
407                    EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
408                            MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
409    
410                    if (isNew) {
411                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
412                                    new Object[] {
413                                            mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
414                                    }, mdrAction);
415                    }
416                    else {
417                            if ((mdrActionModelImpl.getColumnBitmask() &
418                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
419                                    Object[] args = new Object[] {
420                                                    mdrActionModelImpl.getOriginalUuid(),
421                                                    Long.valueOf(mdrActionModelImpl.getOriginalGroupId())
422                                            };
423    
424                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
425                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
426    
427                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
428                                            new Object[] {
429                                                    mdrAction.getUuid(),
430                                                    Long.valueOf(mdrAction.getGroupId())
431                                            }, mdrAction);
432                            }
433                    }
434    
435                    return mdrAction;
436            }
437    
438            protected MDRAction toUnwrappedModel(MDRAction mdrAction) {
439                    if (mdrAction instanceof MDRActionImpl) {
440                            return mdrAction;
441                    }
442    
443                    MDRActionImpl mdrActionImpl = new MDRActionImpl();
444    
445                    mdrActionImpl.setNew(mdrAction.isNew());
446                    mdrActionImpl.setPrimaryKey(mdrAction.getPrimaryKey());
447    
448                    mdrActionImpl.setUuid(mdrAction.getUuid());
449                    mdrActionImpl.setActionId(mdrAction.getActionId());
450                    mdrActionImpl.setGroupId(mdrAction.getGroupId());
451                    mdrActionImpl.setCompanyId(mdrAction.getCompanyId());
452                    mdrActionImpl.setUserId(mdrAction.getUserId());
453                    mdrActionImpl.setUserName(mdrAction.getUserName());
454                    mdrActionImpl.setCreateDate(mdrAction.getCreateDate());
455                    mdrActionImpl.setModifiedDate(mdrAction.getModifiedDate());
456                    mdrActionImpl.setClassNameId(mdrAction.getClassNameId());
457                    mdrActionImpl.setClassPK(mdrAction.getClassPK());
458                    mdrActionImpl.setRuleGroupInstanceId(mdrAction.getRuleGroupInstanceId());
459                    mdrActionImpl.setName(mdrAction.getName());
460                    mdrActionImpl.setDescription(mdrAction.getDescription());
461                    mdrActionImpl.setType(mdrAction.getType());
462                    mdrActionImpl.setTypeSettings(mdrAction.getTypeSettings());
463    
464                    return mdrActionImpl;
465            }
466    
467            /**
468             * Returns the m d r action with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
469             *
470             * @param primaryKey the primary key of the m d r action
471             * @return the m d r action
472             * @throws com.liferay.portal.NoSuchModelException if a m d r action with the primary key could not be found
473             * @throws SystemException if a system exception occurred
474             */
475            @Override
476            public MDRAction findByPrimaryKey(Serializable primaryKey)
477                    throws NoSuchModelException, SystemException {
478                    return findByPrimaryKey(((Long)primaryKey).longValue());
479            }
480    
481            /**
482             * Returns the m d r action with the primary key or throws a {@link com.liferay.portlet.mobiledevicerules.NoSuchActionException} if it could not be found.
483             *
484             * @param actionId the primary key of the m d r action
485             * @return the m d r action
486             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a m d r action with the primary key could not be found
487             * @throws SystemException if a system exception occurred
488             */
489            public MDRAction findByPrimaryKey(long actionId)
490                    throws NoSuchActionException, SystemException {
491                    MDRAction mdrAction = fetchByPrimaryKey(actionId);
492    
493                    if (mdrAction == null) {
494                            if (_log.isWarnEnabled()) {
495                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + actionId);
496                            }
497    
498                            throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
499                                    actionId);
500                    }
501    
502                    return mdrAction;
503            }
504    
505            /**
506             * Returns the m d r action with the primary key or returns <code>null</code> if it could not be found.
507             *
508             * @param primaryKey the primary key of the m d r action
509             * @return the m d r action, or <code>null</code> if a m d r action with the primary key could not be found
510             * @throws SystemException if a system exception occurred
511             */
512            @Override
513            public MDRAction fetchByPrimaryKey(Serializable primaryKey)
514                    throws SystemException {
515                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
516            }
517    
518            /**
519             * Returns the m d r action with the primary key or returns <code>null</code> if it could not be found.
520             *
521             * @param actionId the primary key of the m d r action
522             * @return the m d r action, or <code>null</code> if a m d r action with the primary key could not be found
523             * @throws SystemException if a system exception occurred
524             */
525            public MDRAction fetchByPrimaryKey(long actionId) throws SystemException {
526                    MDRAction mdrAction = (MDRAction)EntityCacheUtil.getResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
527                                    MDRActionImpl.class, actionId);
528    
529                    if (mdrAction == _nullMDRAction) {
530                            return null;
531                    }
532    
533                    if (mdrAction == null) {
534                            Session session = null;
535    
536                            boolean hasException = false;
537    
538                            try {
539                                    session = openSession();
540    
541                                    mdrAction = (MDRAction)session.get(MDRActionImpl.class,
542                                                    Long.valueOf(actionId));
543                            }
544                            catch (Exception e) {
545                                    hasException = true;
546    
547                                    throw processException(e);
548                            }
549                            finally {
550                                    if (mdrAction != null) {
551                                            cacheResult(mdrAction);
552                                    }
553                                    else if (!hasException) {
554                                            EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
555                                                    MDRActionImpl.class, actionId, _nullMDRAction);
556                                    }
557    
558                                    closeSession(session);
559                            }
560                    }
561    
562                    return mdrAction;
563            }
564    
565            /**
566             * Returns all the m d r actions where uuid = &#63;.
567             *
568             * @param uuid the uuid
569             * @return the matching m d r actions
570             * @throws SystemException if a system exception occurred
571             */
572            public List<MDRAction> findByUuid(String uuid) throws SystemException {
573                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
574            }
575    
576            /**
577             * Returns a range of all the m d r actions where uuid = &#63;.
578             *
579             * <p>
580             * 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.
581             * </p>
582             *
583             * @param uuid the uuid
584             * @param start the lower bound of the range of m d r actions
585             * @param end the upper bound of the range of m d r actions (not inclusive)
586             * @return the range of matching m d r actions
587             * @throws SystemException if a system exception occurred
588             */
589            public List<MDRAction> findByUuid(String uuid, int start, int end)
590                    throws SystemException {
591                    return findByUuid(uuid, start, end, null);
592            }
593    
594            /**
595             * Returns an ordered range of all the m d r actions where uuid = &#63;.
596             *
597             * <p>
598             * 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.
599             * </p>
600             *
601             * @param uuid the uuid
602             * @param start the lower bound of the range of m d r actions
603             * @param end the upper bound of the range of m d r actions (not inclusive)
604             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
605             * @return the ordered range of matching m d r actions
606             * @throws SystemException if a system exception occurred
607             */
608            public List<MDRAction> findByUuid(String uuid, int start, int end,
609                    OrderByComparator orderByComparator) throws SystemException {
610                    FinderPath finderPath = null;
611                    Object[] finderArgs = null;
612    
613                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
614                                    (orderByComparator == null)) {
615                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
616                            finderArgs = new Object[] { uuid };
617                    }
618                    else {
619                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
620                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
621                    }
622    
623                    List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
624                                    finderArgs, this);
625    
626                    if (list == null) {
627                            StringBundler query = null;
628    
629                            if (orderByComparator != null) {
630                                    query = new StringBundler(3 +
631                                                    (orderByComparator.getOrderByFields().length * 3));
632                            }
633                            else {
634                                    query = new StringBundler(2);
635                            }
636    
637                            query.append(_SQL_SELECT_MDRACTION_WHERE);
638    
639                            if (uuid == null) {
640                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
641                            }
642                            else {
643                                    if (uuid.equals(StringPool.BLANK)) {
644                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
645                                    }
646                                    else {
647                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
648                                    }
649                            }
650    
651                            if (orderByComparator != null) {
652                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
653                                            orderByComparator);
654                            }
655    
656                            String sql = query.toString();
657    
658                            Session session = null;
659    
660                            try {
661                                    session = openSession();
662    
663                                    Query q = session.createQuery(sql);
664    
665                                    QueryPos qPos = QueryPos.getInstance(q);
666    
667                                    if (uuid != null) {
668                                            qPos.add(uuid);
669                                    }
670    
671                                    list = (List<MDRAction>)QueryUtil.list(q, getDialect(), start,
672                                                    end);
673                            }
674                            catch (Exception e) {
675                                    throw processException(e);
676                            }
677                            finally {
678                                    if (list == null) {
679                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
680                                    }
681                                    else {
682                                            cacheResult(list);
683    
684                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
685                                    }
686    
687                                    closeSession(session);
688                            }
689                    }
690    
691                    return list;
692            }
693    
694            /**
695             * Returns the first m d r action in the ordered set where uuid = &#63;.
696             *
697             * <p>
698             * 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.
699             * </p>
700             *
701             * @param uuid the uuid
702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
703             * @return the first matching m d r action
704             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a matching m d r action could not be found
705             * @throws SystemException if a system exception occurred
706             */
707            public MDRAction findByUuid_First(String uuid,
708                    OrderByComparator orderByComparator)
709                    throws NoSuchActionException, SystemException {
710                    List<MDRAction> list = findByUuid(uuid, 0, 1, orderByComparator);
711    
712                    if (list.isEmpty()) {
713                            StringBundler msg = new StringBundler(4);
714    
715                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
716    
717                            msg.append("uuid=");
718                            msg.append(uuid);
719    
720                            msg.append(StringPool.CLOSE_CURLY_BRACE);
721    
722                            throw new NoSuchActionException(msg.toString());
723                    }
724                    else {
725                            return list.get(0);
726                    }
727            }
728    
729            /**
730             * Returns the last m d r action in the ordered set where uuid = &#63;.
731             *
732             * <p>
733             * 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.
734             * </p>
735             *
736             * @param uuid the uuid
737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
738             * @return the last matching m d r action
739             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a matching m d r action could not be found
740             * @throws SystemException if a system exception occurred
741             */
742            public MDRAction findByUuid_Last(String uuid,
743                    OrderByComparator orderByComparator)
744                    throws NoSuchActionException, SystemException {
745                    int count = countByUuid(uuid);
746    
747                    List<MDRAction> list = findByUuid(uuid, count - 1, count,
748                                    orderByComparator);
749    
750                    if (list.isEmpty()) {
751                            StringBundler msg = new StringBundler(4);
752    
753                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
754    
755                            msg.append("uuid=");
756                            msg.append(uuid);
757    
758                            msg.append(StringPool.CLOSE_CURLY_BRACE);
759    
760                            throw new NoSuchActionException(msg.toString());
761                    }
762                    else {
763                            return list.get(0);
764                    }
765            }
766    
767            /**
768             * Returns the m d r actions before and after the current m d r action in the ordered set where uuid = &#63;.
769             *
770             * <p>
771             * 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.
772             * </p>
773             *
774             * @param actionId the primary key of the current m d r action
775             * @param uuid the uuid
776             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
777             * @return the previous, current, and next m d r action
778             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a m d r action with the primary key could not be found
779             * @throws SystemException if a system exception occurred
780             */
781            public MDRAction[] findByUuid_PrevAndNext(long actionId, String uuid,
782                    OrderByComparator orderByComparator)
783                    throws NoSuchActionException, SystemException {
784                    MDRAction mdrAction = findByPrimaryKey(actionId);
785    
786                    Session session = null;
787    
788                    try {
789                            session = openSession();
790    
791                            MDRAction[] array = new MDRActionImpl[3];
792    
793                            array[0] = getByUuid_PrevAndNext(session, mdrAction, uuid,
794                                            orderByComparator, true);
795    
796                            array[1] = mdrAction;
797    
798                            array[2] = getByUuid_PrevAndNext(session, mdrAction, uuid,
799                                            orderByComparator, false);
800    
801                            return array;
802                    }
803                    catch (Exception e) {
804                            throw processException(e);
805                    }
806                    finally {
807                            closeSession(session);
808                    }
809            }
810    
811            protected MDRAction getByUuid_PrevAndNext(Session session,
812                    MDRAction mdrAction, String uuid, OrderByComparator orderByComparator,
813                    boolean previous) {
814                    StringBundler query = null;
815    
816                    if (orderByComparator != null) {
817                            query = new StringBundler(6 +
818                                            (orderByComparator.getOrderByFields().length * 6));
819                    }
820                    else {
821                            query = new StringBundler(3);
822                    }
823    
824                    query.append(_SQL_SELECT_MDRACTION_WHERE);
825    
826                    if (uuid == null) {
827                            query.append(_FINDER_COLUMN_UUID_UUID_1);
828                    }
829                    else {
830                            if (uuid.equals(StringPool.BLANK)) {
831                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
832                            }
833                            else {
834                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
835                            }
836                    }
837    
838                    if (orderByComparator != null) {
839                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
840    
841                            if (orderByConditionFields.length > 0) {
842                                    query.append(WHERE_AND);
843                            }
844    
845                            for (int i = 0; i < orderByConditionFields.length; i++) {
846                                    query.append(_ORDER_BY_ENTITY_ALIAS);
847                                    query.append(orderByConditionFields[i]);
848    
849                                    if ((i + 1) < orderByConditionFields.length) {
850                                            if (orderByComparator.isAscending() ^ previous) {
851                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
852                                            }
853                                            else {
854                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
855                                            }
856                                    }
857                                    else {
858                                            if (orderByComparator.isAscending() ^ previous) {
859                                                    query.append(WHERE_GREATER_THAN);
860                                            }
861                                            else {
862                                                    query.append(WHERE_LESSER_THAN);
863                                            }
864                                    }
865                            }
866    
867                            query.append(ORDER_BY_CLAUSE);
868    
869                            String[] orderByFields = orderByComparator.getOrderByFields();
870    
871                            for (int i = 0; i < orderByFields.length; i++) {
872                                    query.append(_ORDER_BY_ENTITY_ALIAS);
873                                    query.append(orderByFields[i]);
874    
875                                    if ((i + 1) < orderByFields.length) {
876                                            if (orderByComparator.isAscending() ^ previous) {
877                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
878                                            }
879                                            else {
880                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
881                                            }
882                                    }
883                                    else {
884                                            if (orderByComparator.isAscending() ^ previous) {
885                                                    query.append(ORDER_BY_ASC);
886                                            }
887                                            else {
888                                                    query.append(ORDER_BY_DESC);
889                                            }
890                                    }
891                            }
892                    }
893    
894                    String sql = query.toString();
895    
896                    Query q = session.createQuery(sql);
897    
898                    q.setFirstResult(0);
899                    q.setMaxResults(2);
900    
901                    QueryPos qPos = QueryPos.getInstance(q);
902    
903                    if (uuid != null) {
904                            qPos.add(uuid);
905                    }
906    
907                    if (orderByComparator != null) {
908                            Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
909    
910                            for (Object value : values) {
911                                    qPos.add(value);
912                            }
913                    }
914    
915                    List<MDRAction> list = q.list();
916    
917                    if (list.size() == 2) {
918                            return list.get(1);
919                    }
920                    else {
921                            return null;
922                    }
923            }
924    
925            /**
926             * Returns the m d r action where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.mobiledevicerules.NoSuchActionException} if it could not be found.
927             *
928             * @param uuid the uuid
929             * @param groupId the group ID
930             * @return the matching m d r action
931             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a matching m d r action could not be found
932             * @throws SystemException if a system exception occurred
933             */
934            public MDRAction findByUUID_G(String uuid, long groupId)
935                    throws NoSuchActionException, SystemException {
936                    MDRAction mdrAction = fetchByUUID_G(uuid, groupId);
937    
938                    if (mdrAction == null) {
939                            StringBundler msg = new StringBundler(6);
940    
941                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
942    
943                            msg.append("uuid=");
944                            msg.append(uuid);
945    
946                            msg.append(", groupId=");
947                            msg.append(groupId);
948    
949                            msg.append(StringPool.CLOSE_CURLY_BRACE);
950    
951                            if (_log.isWarnEnabled()) {
952                                    _log.warn(msg.toString());
953                            }
954    
955                            throw new NoSuchActionException(msg.toString());
956                    }
957    
958                    return mdrAction;
959            }
960    
961            /**
962             * Returns the m d r action where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
963             *
964             * @param uuid the uuid
965             * @param groupId the group ID
966             * @return the matching m d r action, or <code>null</code> if a matching m d r action could not be found
967             * @throws SystemException if a system exception occurred
968             */
969            public MDRAction fetchByUUID_G(String uuid, long groupId)
970                    throws SystemException {
971                    return fetchByUUID_G(uuid, groupId, true);
972            }
973    
974            /**
975             * Returns the m d r action where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
976             *
977             * @param uuid the uuid
978             * @param groupId the group ID
979             * @param retrieveFromCache whether to use the finder cache
980             * @return the matching m d r action, or <code>null</code> if a matching m d r action could not be found
981             * @throws SystemException if a system exception occurred
982             */
983            public MDRAction fetchByUUID_G(String uuid, long groupId,
984                    boolean retrieveFromCache) throws SystemException {
985                    Object[] finderArgs = new Object[] { uuid, groupId };
986    
987                    Object result = null;
988    
989                    if (retrieveFromCache) {
990                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
991                                            finderArgs, this);
992                    }
993    
994                    if (result == null) {
995                            StringBundler query = new StringBundler(3);
996    
997                            query.append(_SQL_SELECT_MDRACTION_WHERE);
998    
999                            if (uuid == null) {
1000                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1001                            }
1002                            else {
1003                                    if (uuid.equals(StringPool.BLANK)) {
1004                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1005                                    }
1006                                    else {
1007                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1008                                    }
1009                            }
1010    
1011                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1012    
1013                            String sql = query.toString();
1014    
1015                            Session session = null;
1016    
1017                            try {
1018                                    session = openSession();
1019    
1020                                    Query q = session.createQuery(sql);
1021    
1022                                    QueryPos qPos = QueryPos.getInstance(q);
1023    
1024                                    if (uuid != null) {
1025                                            qPos.add(uuid);
1026                                    }
1027    
1028                                    qPos.add(groupId);
1029    
1030                                    List<MDRAction> list = q.list();
1031    
1032                                    result = list;
1033    
1034                                    MDRAction mdrAction = null;
1035    
1036                                    if (list.isEmpty()) {
1037                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1038                                                    finderArgs, list);
1039                                    }
1040                                    else {
1041                                            mdrAction = list.get(0);
1042    
1043                                            cacheResult(mdrAction);
1044    
1045                                            if ((mdrAction.getUuid() == null) ||
1046                                                            !mdrAction.getUuid().equals(uuid) ||
1047                                                            (mdrAction.getGroupId() != groupId)) {
1048                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1049                                                            finderArgs, mdrAction);
1050                                            }
1051                                    }
1052    
1053                                    return mdrAction;
1054                            }
1055                            catch (Exception e) {
1056                                    throw processException(e);
1057                            }
1058                            finally {
1059                                    if (result == null) {
1060                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1061                                                    finderArgs);
1062                                    }
1063    
1064                                    closeSession(session);
1065                            }
1066                    }
1067                    else {
1068                            if (result instanceof List<?>) {
1069                                    return null;
1070                            }
1071                            else {
1072                                    return (MDRAction)result;
1073                            }
1074                    }
1075            }
1076    
1077            /**
1078             * Returns all the m d r actions where ruleGroupInstanceId = &#63;.
1079             *
1080             * @param ruleGroupInstanceId the rule group instance ID
1081             * @return the matching m d r actions
1082             * @throws SystemException if a system exception occurred
1083             */
1084            public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId)
1085                    throws SystemException {
1086                    return findByRuleGroupInstanceId(ruleGroupInstanceId,
1087                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1088            }
1089    
1090            /**
1091             * Returns a range of all the m d r actions where ruleGroupInstanceId = &#63;.
1092             *
1093             * <p>
1094             * 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.
1095             * </p>
1096             *
1097             * @param ruleGroupInstanceId the rule group instance ID
1098             * @param start the lower bound of the range of m d r actions
1099             * @param end the upper bound of the range of m d r actions (not inclusive)
1100             * @return the range of matching m d r actions
1101             * @throws SystemException if a system exception occurred
1102             */
1103            public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1104                    int start, int end) throws SystemException {
1105                    return findByRuleGroupInstanceId(ruleGroupInstanceId, start, end, null);
1106            }
1107    
1108            /**
1109             * Returns an ordered range of all the m d r actions where ruleGroupInstanceId = &#63;.
1110             *
1111             * <p>
1112             * 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.
1113             * </p>
1114             *
1115             * @param ruleGroupInstanceId the rule group instance ID
1116             * @param start the lower bound of the range of m d r actions
1117             * @param end the upper bound of the range of m d r actions (not inclusive)
1118             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1119             * @return the ordered range of matching m d r actions
1120             * @throws SystemException if a system exception occurred
1121             */
1122            public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1123                    int start, int end, OrderByComparator orderByComparator)
1124                    throws SystemException {
1125                    FinderPath finderPath = null;
1126                    Object[] finderArgs = null;
1127    
1128                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1129                                    (orderByComparator == null)) {
1130                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1131                            finderArgs = new Object[] { ruleGroupInstanceId };
1132                    }
1133                    else {
1134                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1135                            finderArgs = new Object[] {
1136                                            ruleGroupInstanceId,
1137                                            
1138                                            start, end, orderByComparator
1139                                    };
1140                    }
1141    
1142                    List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1143                                    finderArgs, this);
1144    
1145                    if (list == null) {
1146                            StringBundler query = null;
1147    
1148                            if (orderByComparator != null) {
1149                                    query = new StringBundler(3 +
1150                                                    (orderByComparator.getOrderByFields().length * 3));
1151                            }
1152                            else {
1153                                    query = new StringBundler(2);
1154                            }
1155    
1156                            query.append(_SQL_SELECT_MDRACTION_WHERE);
1157    
1158                            query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1159    
1160                            if (orderByComparator != null) {
1161                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1162                                            orderByComparator);
1163                            }
1164    
1165                            String sql = query.toString();
1166    
1167                            Session session = null;
1168    
1169                            try {
1170                                    session = openSession();
1171    
1172                                    Query q = session.createQuery(sql);
1173    
1174                                    QueryPos qPos = QueryPos.getInstance(q);
1175    
1176                                    qPos.add(ruleGroupInstanceId);
1177    
1178                                    list = (List<MDRAction>)QueryUtil.list(q, getDialect(), start,
1179                                                    end);
1180                            }
1181                            catch (Exception e) {
1182                                    throw processException(e);
1183                            }
1184                            finally {
1185                                    if (list == null) {
1186                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1187                                    }
1188                                    else {
1189                                            cacheResult(list);
1190    
1191                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1192                                    }
1193    
1194                                    closeSession(session);
1195                            }
1196                    }
1197    
1198                    return list;
1199            }
1200    
1201            /**
1202             * Returns the first m d r action in the ordered set where ruleGroupInstanceId = &#63;.
1203             *
1204             * <p>
1205             * 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.
1206             * </p>
1207             *
1208             * @param ruleGroupInstanceId the rule group instance ID
1209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1210             * @return the first matching m d r action
1211             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a matching m d r action could not be found
1212             * @throws SystemException if a system exception occurred
1213             */
1214            public MDRAction findByRuleGroupInstanceId_First(long ruleGroupInstanceId,
1215                    OrderByComparator orderByComparator)
1216                    throws NoSuchActionException, SystemException {
1217                    List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1218                                    0, 1, orderByComparator);
1219    
1220                    if (list.isEmpty()) {
1221                            StringBundler msg = new StringBundler(4);
1222    
1223                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1224    
1225                            msg.append("ruleGroupInstanceId=");
1226                            msg.append(ruleGroupInstanceId);
1227    
1228                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1229    
1230                            throw new NoSuchActionException(msg.toString());
1231                    }
1232                    else {
1233                            return list.get(0);
1234                    }
1235            }
1236    
1237            /**
1238             * Returns the last m d r action in the ordered set where ruleGroupInstanceId = &#63;.
1239             *
1240             * <p>
1241             * 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.
1242             * </p>
1243             *
1244             * @param ruleGroupInstanceId the rule group instance ID
1245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1246             * @return the last matching m d r action
1247             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a matching m d r action could not be found
1248             * @throws SystemException if a system exception occurred
1249             */
1250            public MDRAction findByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1251                    OrderByComparator orderByComparator)
1252                    throws NoSuchActionException, SystemException {
1253                    int count = countByRuleGroupInstanceId(ruleGroupInstanceId);
1254    
1255                    List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1256                                    count - 1, count, orderByComparator);
1257    
1258                    if (list.isEmpty()) {
1259                            StringBundler msg = new StringBundler(4);
1260    
1261                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1262    
1263                            msg.append("ruleGroupInstanceId=");
1264                            msg.append(ruleGroupInstanceId);
1265    
1266                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1267    
1268                            throw new NoSuchActionException(msg.toString());
1269                    }
1270                    else {
1271                            return list.get(0);
1272                    }
1273            }
1274    
1275            /**
1276             * Returns the m d r actions before and after the current m d r action in the ordered set where ruleGroupInstanceId = &#63;.
1277             *
1278             * <p>
1279             * 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.
1280             * </p>
1281             *
1282             * @param actionId the primary key of the current m d r action
1283             * @param ruleGroupInstanceId the rule group instance ID
1284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1285             * @return the previous, current, and next m d r action
1286             * @throws com.liferay.portlet.mobiledevicerules.NoSuchActionException if a m d r action with the primary key could not be found
1287             * @throws SystemException if a system exception occurred
1288             */
1289            public MDRAction[] findByRuleGroupInstanceId_PrevAndNext(long actionId,
1290                    long ruleGroupInstanceId, OrderByComparator orderByComparator)
1291                    throws NoSuchActionException, SystemException {
1292                    MDRAction mdrAction = findByPrimaryKey(actionId);
1293    
1294                    Session session = null;
1295    
1296                    try {
1297                            session = openSession();
1298    
1299                            MDRAction[] array = new MDRActionImpl[3];
1300    
1301                            array[0] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1302                                            ruleGroupInstanceId, orderByComparator, true);
1303    
1304                            array[1] = mdrAction;
1305    
1306                            array[2] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1307                                            ruleGroupInstanceId, orderByComparator, false);
1308    
1309                            return array;
1310                    }
1311                    catch (Exception e) {
1312                            throw processException(e);
1313                    }
1314                    finally {
1315                            closeSession(session);
1316                    }
1317            }
1318    
1319            protected MDRAction getByRuleGroupInstanceId_PrevAndNext(Session session,
1320                    MDRAction mdrAction, long ruleGroupInstanceId,
1321                    OrderByComparator orderByComparator, boolean previous) {
1322                    StringBundler query = null;
1323    
1324                    if (orderByComparator != null) {
1325                            query = new StringBundler(6 +
1326                                            (orderByComparator.getOrderByFields().length * 6));
1327                    }
1328                    else {
1329                            query = new StringBundler(3);
1330                    }
1331    
1332                    query.append(_SQL_SELECT_MDRACTION_WHERE);
1333    
1334                    query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1335    
1336                    if (orderByComparator != null) {
1337                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1338    
1339                            if (orderByConditionFields.length > 0) {
1340                                    query.append(WHERE_AND);
1341                            }
1342    
1343                            for (int i = 0; i < orderByConditionFields.length; i++) {
1344                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1345                                    query.append(orderByConditionFields[i]);
1346    
1347                                    if ((i + 1) < orderByConditionFields.length) {
1348                                            if (orderByComparator.isAscending() ^ previous) {
1349                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1350                                            }
1351                                            else {
1352                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1353                                            }
1354                                    }
1355                                    else {
1356                                            if (orderByComparator.isAscending() ^ previous) {
1357                                                    query.append(WHERE_GREATER_THAN);
1358                                            }
1359                                            else {
1360                                                    query.append(WHERE_LESSER_THAN);
1361                                            }
1362                                    }
1363                            }
1364    
1365                            query.append(ORDER_BY_CLAUSE);
1366    
1367                            String[] orderByFields = orderByComparator.getOrderByFields();
1368    
1369                            for (int i = 0; i < orderByFields.length; i++) {
1370                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1371                                    query.append(orderByFields[i]);
1372    
1373                                    if ((i + 1) < orderByFields.length) {
1374                                            if (orderByComparator.isAscending() ^ previous) {
1375                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1376                                            }
1377                                            else {
1378                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1379                                            }
1380                                    }
1381                                    else {
1382                                            if (orderByComparator.isAscending() ^ previous) {
1383                                                    query.append(ORDER_BY_ASC);
1384                                            }
1385                                            else {
1386                                                    query.append(ORDER_BY_DESC);
1387                                            }
1388                                    }
1389                            }
1390                    }
1391    
1392                    String sql = query.toString();
1393    
1394                    Query q = session.createQuery(sql);
1395    
1396                    q.setFirstResult(0);
1397                    q.setMaxResults(2);
1398    
1399                    QueryPos qPos = QueryPos.getInstance(q);
1400    
1401                    qPos.add(ruleGroupInstanceId);
1402    
1403                    if (orderByComparator != null) {
1404                            Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1405    
1406                            for (Object value : values) {
1407                                    qPos.add(value);
1408                            }
1409                    }
1410    
1411                    List<MDRAction> list = q.list();
1412    
1413                    if (list.size() == 2) {
1414                            return list.get(1);
1415                    }
1416                    else {
1417                            return null;
1418                    }
1419            }
1420    
1421            /**
1422             * Returns all the m d r actions.
1423             *
1424             * @return the m d r actions
1425             * @throws SystemException if a system exception occurred
1426             */
1427            public List<MDRAction> findAll() throws SystemException {
1428                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1429            }
1430    
1431            /**
1432             * Returns a range of all the m d r actions.
1433             *
1434             * <p>
1435             * 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.
1436             * </p>
1437             *
1438             * @param start the lower bound of the range of m d r actions
1439             * @param end the upper bound of the range of m d r actions (not inclusive)
1440             * @return the range of m d r actions
1441             * @throws SystemException if a system exception occurred
1442             */
1443            public List<MDRAction> findAll(int start, int end)
1444                    throws SystemException {
1445                    return findAll(start, end, null);
1446            }
1447    
1448            /**
1449             * Returns an ordered range of all the m d r actions.
1450             *
1451             * <p>
1452             * 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.
1453             * </p>
1454             *
1455             * @param start the lower bound of the range of m d r actions
1456             * @param end the upper bound of the range of m d r actions (not inclusive)
1457             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1458             * @return the ordered range of m d r actions
1459             * @throws SystemException if a system exception occurred
1460             */
1461            public List<MDRAction> findAll(int start, int end,
1462                    OrderByComparator orderByComparator) throws SystemException {
1463                    FinderPath finderPath = null;
1464                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1465    
1466                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1467                                    (orderByComparator == null)) {
1468                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1469                            finderArgs = FINDER_ARGS_EMPTY;
1470                    }
1471                    else {
1472                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1473                            finderArgs = new Object[] { start, end, orderByComparator };
1474                    }
1475    
1476                    List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1477                                    finderArgs, this);
1478    
1479                    if (list == null) {
1480                            StringBundler query = null;
1481                            String sql = null;
1482    
1483                            if (orderByComparator != null) {
1484                                    query = new StringBundler(2 +
1485                                                    (orderByComparator.getOrderByFields().length * 3));
1486    
1487                                    query.append(_SQL_SELECT_MDRACTION);
1488    
1489                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1490                                            orderByComparator);
1491    
1492                                    sql = query.toString();
1493                            }
1494                            else {
1495                                    sql = _SQL_SELECT_MDRACTION;
1496                            }
1497    
1498                            Session session = null;
1499    
1500                            try {
1501                                    session = openSession();
1502    
1503                                    Query q = session.createQuery(sql);
1504    
1505                                    if (orderByComparator == null) {
1506                                            list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1507                                                            start, end, false);
1508    
1509                                            Collections.sort(list);
1510                                    }
1511                                    else {
1512                                            list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1513                                                            start, end);
1514                                    }
1515                            }
1516                            catch (Exception e) {
1517                                    throw processException(e);
1518                            }
1519                            finally {
1520                                    if (list == null) {
1521                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1522                                    }
1523                                    else {
1524                                            cacheResult(list);
1525    
1526                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1527                                    }
1528    
1529                                    closeSession(session);
1530                            }
1531                    }
1532    
1533                    return list;
1534            }
1535    
1536            /**
1537             * Removes all the m d r actions where uuid = &#63; from the database.
1538             *
1539             * @param uuid the uuid
1540             * @throws SystemException if a system exception occurred
1541             */
1542            public void removeByUuid(String uuid) throws SystemException {
1543                    for (MDRAction mdrAction : findByUuid(uuid)) {
1544                            remove(mdrAction);
1545                    }
1546            }
1547    
1548            /**
1549             * Removes the m d r action where uuid = &#63; and groupId = &#63; from the database.
1550             *
1551             * @param uuid the uuid
1552             * @param groupId the group ID
1553             * @throws SystemException if a system exception occurred
1554             */
1555            public void removeByUUID_G(String uuid, long groupId)
1556                    throws NoSuchActionException, SystemException {
1557                    MDRAction mdrAction = findByUUID_G(uuid, groupId);
1558    
1559                    remove(mdrAction);
1560            }
1561    
1562            /**
1563             * Removes all the m d r actions where ruleGroupInstanceId = &#63; from the database.
1564             *
1565             * @param ruleGroupInstanceId the rule group instance ID
1566             * @throws SystemException if a system exception occurred
1567             */
1568            public void removeByRuleGroupInstanceId(long ruleGroupInstanceId)
1569                    throws SystemException {
1570                    for (MDRAction mdrAction : findByRuleGroupInstanceId(
1571                                    ruleGroupInstanceId)) {
1572                            remove(mdrAction);
1573                    }
1574            }
1575    
1576            /**
1577             * Removes all the m d r actions from the database.
1578             *
1579             * @throws SystemException if a system exception occurred
1580             */
1581            public void removeAll() throws SystemException {
1582                    for (MDRAction mdrAction : findAll()) {
1583                            remove(mdrAction);
1584                    }
1585            }
1586    
1587            /**
1588             * Returns the number of m d r actions where uuid = &#63;.
1589             *
1590             * @param uuid the uuid
1591             * @return the number of matching m d r actions
1592             * @throws SystemException if a system exception occurred
1593             */
1594            public int countByUuid(String uuid) throws SystemException {
1595                    Object[] finderArgs = new Object[] { uuid };
1596    
1597                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1598                                    finderArgs, this);
1599    
1600                    if (count == null) {
1601                            StringBundler query = new StringBundler(2);
1602    
1603                            query.append(_SQL_COUNT_MDRACTION_WHERE);
1604    
1605                            if (uuid == null) {
1606                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1607                            }
1608                            else {
1609                                    if (uuid.equals(StringPool.BLANK)) {
1610                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1611                                    }
1612                                    else {
1613                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1614                                    }
1615                            }
1616    
1617                            String sql = query.toString();
1618    
1619                            Session session = null;
1620    
1621                            try {
1622                                    session = openSession();
1623    
1624                                    Query q = session.createQuery(sql);
1625    
1626                                    QueryPos qPos = QueryPos.getInstance(q);
1627    
1628                                    if (uuid != null) {
1629                                            qPos.add(uuid);
1630                                    }
1631    
1632                                    count = (Long)q.uniqueResult();
1633                            }
1634                            catch (Exception e) {
1635                                    throw processException(e);
1636                            }
1637                            finally {
1638                                    if (count == null) {
1639                                            count = Long.valueOf(0);
1640                                    }
1641    
1642                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1643                                            finderArgs, count);
1644    
1645                                    closeSession(session);
1646                            }
1647                    }
1648    
1649                    return count.intValue();
1650            }
1651    
1652            /**
1653             * Returns the number of m d r actions where uuid = &#63; and groupId = &#63;.
1654             *
1655             * @param uuid the uuid
1656             * @param groupId the group ID
1657             * @return the number of matching m d r actions
1658             * @throws SystemException if a system exception occurred
1659             */
1660            public int countByUUID_G(String uuid, long groupId)
1661                    throws SystemException {
1662                    Object[] finderArgs = new Object[] { uuid, groupId };
1663    
1664                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1665                                    finderArgs, this);
1666    
1667                    if (count == null) {
1668                            StringBundler query = new StringBundler(3);
1669    
1670                            query.append(_SQL_COUNT_MDRACTION_WHERE);
1671    
1672                            if (uuid == null) {
1673                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1674                            }
1675                            else {
1676                                    if (uuid.equals(StringPool.BLANK)) {
1677                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1678                                    }
1679                                    else {
1680                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1681                                    }
1682                            }
1683    
1684                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1685    
1686                            String sql = query.toString();
1687    
1688                            Session session = null;
1689    
1690                            try {
1691                                    session = openSession();
1692    
1693                                    Query q = session.createQuery(sql);
1694    
1695                                    QueryPos qPos = QueryPos.getInstance(q);
1696    
1697                                    if (uuid != null) {
1698                                            qPos.add(uuid);
1699                                    }
1700    
1701                                    qPos.add(groupId);
1702    
1703                                    count = (Long)q.uniqueResult();
1704                            }
1705                            catch (Exception e) {
1706                                    throw processException(e);
1707                            }
1708                            finally {
1709                                    if (count == null) {
1710                                            count = Long.valueOf(0);
1711                                    }
1712    
1713                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1714                                            finderArgs, count);
1715    
1716                                    closeSession(session);
1717                            }
1718                    }
1719    
1720                    return count.intValue();
1721            }
1722    
1723            /**
1724             * Returns the number of m d r actions where ruleGroupInstanceId = &#63;.
1725             *
1726             * @param ruleGroupInstanceId the rule group instance ID
1727             * @return the number of matching m d r actions
1728             * @throws SystemException if a system exception occurred
1729             */
1730            public int countByRuleGroupInstanceId(long ruleGroupInstanceId)
1731                    throws SystemException {
1732                    Object[] finderArgs = new Object[] { ruleGroupInstanceId };
1733    
1734                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
1735                                    finderArgs, this);
1736    
1737                    if (count == null) {
1738                            StringBundler query = new StringBundler(2);
1739    
1740                            query.append(_SQL_COUNT_MDRACTION_WHERE);
1741    
1742                            query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1743    
1744                            String sql = query.toString();
1745    
1746                            Session session = null;
1747    
1748                            try {
1749                                    session = openSession();
1750    
1751                                    Query q = session.createQuery(sql);
1752    
1753                                    QueryPos qPos = QueryPos.getInstance(q);
1754    
1755                                    qPos.add(ruleGroupInstanceId);
1756    
1757                                    count = (Long)q.uniqueResult();
1758                            }
1759                            catch (Exception e) {
1760                                    throw processException(e);
1761                            }
1762                            finally {
1763                                    if (count == null) {
1764                                            count = Long.valueOf(0);
1765                                    }
1766    
1767                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
1768                                            finderArgs, count);
1769    
1770                                    closeSession(session);
1771                            }
1772                    }
1773    
1774                    return count.intValue();
1775            }
1776    
1777            /**
1778             * Returns the number of m d r actions.
1779             *
1780             * @return the number of m d r actions
1781             * @throws SystemException if a system exception occurred
1782             */
1783            public int countAll() throws SystemException {
1784                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1785                                    FINDER_ARGS_EMPTY, this);
1786    
1787                    if (count == null) {
1788                            Session session = null;
1789    
1790                            try {
1791                                    session = openSession();
1792    
1793                                    Query q = session.createQuery(_SQL_COUNT_MDRACTION);
1794    
1795                                    count = (Long)q.uniqueResult();
1796                            }
1797                            catch (Exception e) {
1798                                    throw processException(e);
1799                            }
1800                            finally {
1801                                    if (count == null) {
1802                                            count = Long.valueOf(0);
1803                                    }
1804    
1805                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1806                                            FINDER_ARGS_EMPTY, count);
1807    
1808                                    closeSession(session);
1809                            }
1810                    }
1811    
1812                    return count.intValue();
1813            }
1814    
1815            /**
1816             * Initializes the m d r action persistence.
1817             */
1818            public void afterPropertiesSet() {
1819                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1820                                            com.liferay.portal.util.PropsUtil.get(
1821                                                    "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRAction")));
1822    
1823                    if (listenerClassNames.length > 0) {
1824                            try {
1825                                    List<ModelListener<MDRAction>> listenersList = new ArrayList<ModelListener<MDRAction>>();
1826    
1827                                    for (String listenerClassName : listenerClassNames) {
1828                                            listenersList.add((ModelListener<MDRAction>)InstanceFactory.newInstance(
1829                                                            listenerClassName));
1830                                    }
1831    
1832                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1833                            }
1834                            catch (Exception e) {
1835                                    _log.error(e);
1836                            }
1837                    }
1838            }
1839    
1840            public void destroy() {
1841                    EntityCacheUtil.removeCache(MDRActionImpl.class.getName());
1842                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1843                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1844            }
1845    
1846            @BeanReference(type = MDRActionPersistence.class)
1847            protected MDRActionPersistence mdrActionPersistence;
1848            @BeanReference(type = MDRRulePersistence.class)
1849            protected MDRRulePersistence mdrRulePersistence;
1850            @BeanReference(type = MDRRuleGroupPersistence.class)
1851            protected MDRRuleGroupPersistence mdrRuleGroupPersistence;
1852            @BeanReference(type = MDRRuleGroupInstancePersistence.class)
1853            protected MDRRuleGroupInstancePersistence mdrRuleGroupInstancePersistence;
1854            @BeanReference(type = ResourcePersistence.class)
1855            protected ResourcePersistence resourcePersistence;
1856            @BeanReference(type = UserPersistence.class)
1857            protected UserPersistence userPersistence;
1858            private static final String _SQL_SELECT_MDRACTION = "SELECT mdrAction FROM MDRAction mdrAction";
1859            private static final String _SQL_SELECT_MDRACTION_WHERE = "SELECT mdrAction FROM MDRAction mdrAction WHERE ";
1860            private static final String _SQL_COUNT_MDRACTION = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction";
1861            private static final String _SQL_COUNT_MDRACTION_WHERE = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction WHERE ";
1862            private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrAction.uuid IS NULL";
1863            private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrAction.uuid = ?";
1864            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?)";
1865            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrAction.uuid IS NULL AND ";
1866            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrAction.uuid = ? AND ";
1867            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?) AND ";
1868            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrAction.groupId = ?";
1869            private static final String _FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2 =
1870                    "mdrAction.ruleGroupInstanceId = ?";
1871            private static final String _ORDER_BY_ENTITY_ALIAS = "mdrAction.";
1872            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRAction exists with the primary key ";
1873            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRAction exists with the key {";
1874            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1875            private static Log _log = LogFactoryUtil.getLog(MDRActionPersistenceImpl.class);
1876            private static MDRAction _nullMDRAction = new MDRActionImpl() {
1877                            @Override
1878                            public Object clone() {
1879                                    return this;
1880                            }
1881    
1882                            @Override
1883                            public CacheModel<MDRAction> toCacheModel() {
1884                                    return _nullMDRActionCacheModel;
1885                            }
1886                    };
1887    
1888            private static CacheModel<MDRAction> _nullMDRActionCacheModel = new CacheModel<MDRAction>() {
1889                            public MDRAction toEntityModel() {
1890                                    return _nullMDRAction;
1891                            }
1892                    };
1893    }