001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.mobiledevicerules.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.ArrayUtil;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
039    import com.liferay.portal.service.ServiceContext;
040    import com.liferay.portal.service.ServiceContextThreadLocal;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupException;
044    import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroup;
045    import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupImpl;
046    import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupModelImpl;
047    import com.liferay.portlet.mobiledevicerules.service.persistence.MDRRuleGroupPersistence;
048    
049    import java.io.Serializable;
050    
051    import java.util.Collections;
052    import java.util.Date;
053    import java.util.HashMap;
054    import java.util.HashSet;
055    import java.util.Iterator;
056    import java.util.List;
057    import java.util.Map;
058    import java.util.Set;
059    
060    /**
061     * The persistence implementation for the m d r rule group service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Edward C. Han
068     * @see MDRRuleGroupPersistence
069     * @see com.liferay.portlet.mobiledevicerules.service.persistence.MDRRuleGroupUtil
070     * @generated
071     */
072    @ProviderType
073    public class MDRRuleGroupPersistenceImpl extends BasePersistenceImpl<MDRRuleGroup>
074            implements MDRRuleGroupPersistence {
075            /*
076             * NOTE FOR DEVELOPERS:
077             *
078             * Never modify or reference this class directly. Always use {@link MDRRuleGroupUtil} to access the m d r rule group persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
079             */
080            public static final String FINDER_CLASS_NAME_ENTITY = MDRRuleGroupImpl.class.getName();
081            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List1";
083            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List2";
085            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
086                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
089                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
092                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
095                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
097                            new String[] {
098                                    String.class.getName(),
099                                    
100                            Integer.class.getName(), Integer.class.getName(),
101                                    OrderByComparator.class.getName()
102                            });
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
104                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
106                            new String[] { String.class.getName() },
107                            MDRRuleGroupModelImpl.UUID_COLUMN_BITMASK);
108            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
109                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111                            new String[] { String.class.getName() });
112    
113            /**
114             * Returns all the m d r rule groups where uuid = &#63;.
115             *
116             * @param uuid the uuid
117             * @return the matching m d r rule groups
118             */
119            @Override
120            public List<MDRRuleGroup> findByUuid(String uuid) {
121                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122            }
123    
124            /**
125             * Returns a range of all the m d r rule groups where uuid = &#63;.
126             *
127             * <p>
128             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
129             * </p>
130             *
131             * @param uuid the uuid
132             * @param start the lower bound of the range of m d r rule groups
133             * @param end the upper bound of the range of m d r rule groups (not inclusive)
134             * @return the range of matching m d r rule groups
135             */
136            @Override
137            public List<MDRRuleGroup> findByUuid(String uuid, int start, int end) {
138                    return findByUuid(uuid, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the m d r rule groups where uuid = &#63;.
143             *
144             * <p>
145             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
146             * </p>
147             *
148             * @param uuid the uuid
149             * @param start the lower bound of the range of m d r rule groups
150             * @param end the upper bound of the range of m d r rule groups (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching m d r rule groups
153             */
154            @Override
155            public List<MDRRuleGroup> findByUuid(String uuid, int start, int end,
156                    OrderByComparator<MDRRuleGroup> orderByComparator) {
157                    boolean pagination = true;
158                    FinderPath finderPath = null;
159                    Object[] finderArgs = null;
160    
161                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
162                                    (orderByComparator == null)) {
163                            pagination = false;
164                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
165                            finderArgs = new Object[] { uuid };
166                    }
167                    else {
168                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
169                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
170                    }
171    
172                    List<MDRRuleGroup> list = (List<MDRRuleGroup>)FinderCacheUtil.getResult(finderPath,
173                                    finderArgs, this);
174    
175                    if ((list != null) && !list.isEmpty()) {
176                            for (MDRRuleGroup mdrRuleGroup : list) {
177                                    if (!Validator.equals(uuid, mdrRuleGroup.getUuid())) {
178                                            list = null;
179    
180                                            break;
181                                    }
182                            }
183                    }
184    
185                    if (list == null) {
186                            StringBundler query = null;
187    
188                            if (orderByComparator != null) {
189                                    query = new StringBundler(3 +
190                                                    (orderByComparator.getOrderByFields().length * 3));
191                            }
192                            else {
193                                    query = new StringBundler(3);
194                            }
195    
196                            query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
197    
198                            boolean bindUuid = false;
199    
200                            if (uuid == null) {
201                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
202                            }
203                            else if (uuid.equals(StringPool.BLANK)) {
204                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
205                            }
206                            else {
207                                    bindUuid = true;
208    
209                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
210                            }
211    
212                            if (orderByComparator != null) {
213                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
214                                            orderByComparator);
215                            }
216                            else
217                             if (pagination) {
218                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
219                            }
220    
221                            String sql = query.toString();
222    
223                            Session session = null;
224    
225                            try {
226                                    session = openSession();
227    
228                                    Query q = session.createQuery(sql);
229    
230                                    QueryPos qPos = QueryPos.getInstance(q);
231    
232                                    if (bindUuid) {
233                                            qPos.add(uuid);
234                                    }
235    
236                                    if (!pagination) {
237                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
238                                                            start, end, false);
239    
240                                            Collections.sort(list);
241    
242                                            list = Collections.unmodifiableList(list);
243                                    }
244                                    else {
245                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
246                                                            start, end);
247                                    }
248    
249                                    cacheResult(list);
250    
251                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
252                            }
253                            catch (Exception e) {
254                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
255    
256                                    throw processException(e);
257                            }
258                            finally {
259                                    closeSession(session);
260                            }
261                    }
262    
263                    return list;
264            }
265    
266            /**
267             * Returns the first m d r rule group in the ordered set where uuid = &#63;.
268             *
269             * @param uuid the uuid
270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
271             * @return the first matching m d r rule group
272             * @throws NoSuchRuleGroupException if a matching m d r rule group could not be found
273             */
274            @Override
275            public MDRRuleGroup findByUuid_First(String uuid,
276                    OrderByComparator<MDRRuleGroup> orderByComparator)
277                    throws NoSuchRuleGroupException {
278                    MDRRuleGroup mdrRuleGroup = fetchByUuid_First(uuid, orderByComparator);
279    
280                    if (mdrRuleGroup != null) {
281                            return mdrRuleGroup;
282                    }
283    
284                    StringBundler msg = new StringBundler(4);
285    
286                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
287    
288                    msg.append("uuid=");
289                    msg.append(uuid);
290    
291                    msg.append(StringPool.CLOSE_CURLY_BRACE);
292    
293                    throw new NoSuchRuleGroupException(msg.toString());
294            }
295    
296            /**
297             * Returns the first m d r rule group in the ordered set where uuid = &#63;.
298             *
299             * @param uuid the uuid
300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
301             * @return the first matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
302             */
303            @Override
304            public MDRRuleGroup fetchByUuid_First(String uuid,
305                    OrderByComparator<MDRRuleGroup> orderByComparator) {
306                    List<MDRRuleGroup> list = findByUuid(uuid, 0, 1, orderByComparator);
307    
308                    if (!list.isEmpty()) {
309                            return list.get(0);
310                    }
311    
312                    return null;
313            }
314    
315            /**
316             * Returns the last m d r rule group in the ordered set where uuid = &#63;.
317             *
318             * @param uuid the uuid
319             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
320             * @return the last matching m d r rule group
321             * @throws NoSuchRuleGroupException if a matching m d r rule group could not be found
322             */
323            @Override
324            public MDRRuleGroup findByUuid_Last(String uuid,
325                    OrderByComparator<MDRRuleGroup> orderByComparator)
326                    throws NoSuchRuleGroupException {
327                    MDRRuleGroup mdrRuleGroup = fetchByUuid_Last(uuid, orderByComparator);
328    
329                    if (mdrRuleGroup != null) {
330                            return mdrRuleGroup;
331                    }
332    
333                    StringBundler msg = new StringBundler(4);
334    
335                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336    
337                    msg.append("uuid=");
338                    msg.append(uuid);
339    
340                    msg.append(StringPool.CLOSE_CURLY_BRACE);
341    
342                    throw new NoSuchRuleGroupException(msg.toString());
343            }
344    
345            /**
346             * Returns the last m d r rule group in the ordered set where uuid = &#63;.
347             *
348             * @param uuid the uuid
349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
350             * @return the last matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
351             */
352            @Override
353            public MDRRuleGroup fetchByUuid_Last(String uuid,
354                    OrderByComparator<MDRRuleGroup> orderByComparator) {
355                    int count = countByUuid(uuid);
356    
357                    if (count == 0) {
358                            return null;
359                    }
360    
361                    List<MDRRuleGroup> list = findByUuid(uuid, count - 1, count,
362                                    orderByComparator);
363    
364                    if (!list.isEmpty()) {
365                            return list.get(0);
366                    }
367    
368                    return null;
369            }
370    
371            /**
372             * Returns the m d r rule groups before and after the current m d r rule group in the ordered set where uuid = &#63;.
373             *
374             * @param ruleGroupId the primary key of the current m d r rule group
375             * @param uuid the uuid
376             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
377             * @return the previous, current, and next m d r rule group
378             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
379             */
380            @Override
381            public MDRRuleGroup[] findByUuid_PrevAndNext(long ruleGroupId, String uuid,
382                    OrderByComparator<MDRRuleGroup> orderByComparator)
383                    throws NoSuchRuleGroupException {
384                    MDRRuleGroup mdrRuleGroup = findByPrimaryKey(ruleGroupId);
385    
386                    Session session = null;
387    
388                    try {
389                            session = openSession();
390    
391                            MDRRuleGroup[] array = new MDRRuleGroupImpl[3];
392    
393                            array[0] = getByUuid_PrevAndNext(session, mdrRuleGroup, uuid,
394                                            orderByComparator, true);
395    
396                            array[1] = mdrRuleGroup;
397    
398                            array[2] = getByUuid_PrevAndNext(session, mdrRuleGroup, uuid,
399                                            orderByComparator, false);
400    
401                            return array;
402                    }
403                    catch (Exception e) {
404                            throw processException(e);
405                    }
406                    finally {
407                            closeSession(session);
408                    }
409            }
410    
411            protected MDRRuleGroup getByUuid_PrevAndNext(Session session,
412                    MDRRuleGroup mdrRuleGroup, String uuid,
413                    OrderByComparator<MDRRuleGroup> orderByComparator, boolean previous) {
414                    StringBundler query = null;
415    
416                    if (orderByComparator != null) {
417                            query = new StringBundler(6 +
418                                            (orderByComparator.getOrderByFields().length * 6));
419                    }
420                    else {
421                            query = new StringBundler(3);
422                    }
423    
424                    query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
425    
426                    boolean bindUuid = false;
427    
428                    if (uuid == null) {
429                            query.append(_FINDER_COLUMN_UUID_UUID_1);
430                    }
431                    else if (uuid.equals(StringPool.BLANK)) {
432                            query.append(_FINDER_COLUMN_UUID_UUID_3);
433                    }
434                    else {
435                            bindUuid = true;
436    
437                            query.append(_FINDER_COLUMN_UUID_UUID_2);
438                    }
439    
440                    if (orderByComparator != null) {
441                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
442    
443                            if (orderByConditionFields.length > 0) {
444                                    query.append(WHERE_AND);
445                            }
446    
447                            for (int i = 0; i < orderByConditionFields.length; i++) {
448                                    query.append(_ORDER_BY_ENTITY_ALIAS);
449                                    query.append(orderByConditionFields[i]);
450    
451                                    if ((i + 1) < orderByConditionFields.length) {
452                                            if (orderByComparator.isAscending() ^ previous) {
453                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
454                                            }
455                                            else {
456                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
457                                            }
458                                    }
459                                    else {
460                                            if (orderByComparator.isAscending() ^ previous) {
461                                                    query.append(WHERE_GREATER_THAN);
462                                            }
463                                            else {
464                                                    query.append(WHERE_LESSER_THAN);
465                                            }
466                                    }
467                            }
468    
469                            query.append(ORDER_BY_CLAUSE);
470    
471                            String[] orderByFields = orderByComparator.getOrderByFields();
472    
473                            for (int i = 0; i < orderByFields.length; i++) {
474                                    query.append(_ORDER_BY_ENTITY_ALIAS);
475                                    query.append(orderByFields[i]);
476    
477                                    if ((i + 1) < orderByFields.length) {
478                                            if (orderByComparator.isAscending() ^ previous) {
479                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
480                                            }
481                                            else {
482                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
483                                            }
484                                    }
485                                    else {
486                                            if (orderByComparator.isAscending() ^ previous) {
487                                                    query.append(ORDER_BY_ASC);
488                                            }
489                                            else {
490                                                    query.append(ORDER_BY_DESC);
491                                            }
492                                    }
493                            }
494                    }
495                    else {
496                            query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
497                    }
498    
499                    String sql = query.toString();
500    
501                    Query q = session.createQuery(sql);
502    
503                    q.setFirstResult(0);
504                    q.setMaxResults(2);
505    
506                    QueryPos qPos = QueryPos.getInstance(q);
507    
508                    if (bindUuid) {
509                            qPos.add(uuid);
510                    }
511    
512                    if (orderByComparator != null) {
513                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroup);
514    
515                            for (Object value : values) {
516                                    qPos.add(value);
517                            }
518                    }
519    
520                    List<MDRRuleGroup> list = q.list();
521    
522                    if (list.size() == 2) {
523                            return list.get(1);
524                    }
525                    else {
526                            return null;
527                    }
528            }
529    
530            /**
531             * Removes all the m d r rule groups where uuid = &#63; from the database.
532             *
533             * @param uuid the uuid
534             */
535            @Override
536            public void removeByUuid(String uuid) {
537                    for (MDRRuleGroup mdrRuleGroup : findByUuid(uuid, QueryUtil.ALL_POS,
538                                    QueryUtil.ALL_POS, null)) {
539                            remove(mdrRuleGroup);
540                    }
541            }
542    
543            /**
544             * Returns the number of m d r rule groups where uuid = &#63;.
545             *
546             * @param uuid the uuid
547             * @return the number of matching m d r rule groups
548             */
549            @Override
550            public int countByUuid(String uuid) {
551                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
552    
553                    Object[] finderArgs = new Object[] { uuid };
554    
555                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
556                                    this);
557    
558                    if (count == null) {
559                            StringBundler query = new StringBundler(2);
560    
561                            query.append(_SQL_COUNT_MDRRULEGROUP_WHERE);
562    
563                            boolean bindUuid = false;
564    
565                            if (uuid == null) {
566                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
567                            }
568                            else if (uuid.equals(StringPool.BLANK)) {
569                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
570                            }
571                            else {
572                                    bindUuid = true;
573    
574                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
575                            }
576    
577                            String sql = query.toString();
578    
579                            Session session = null;
580    
581                            try {
582                                    session = openSession();
583    
584                                    Query q = session.createQuery(sql);
585    
586                                    QueryPos qPos = QueryPos.getInstance(q);
587    
588                                    if (bindUuid) {
589                                            qPos.add(uuid);
590                                    }
591    
592                                    count = (Long)q.uniqueResult();
593    
594                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
595                            }
596                            catch (Exception e) {
597                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
598    
599                                    throw processException(e);
600                            }
601                            finally {
602                                    closeSession(session);
603                            }
604                    }
605    
606                    return count.intValue();
607            }
608    
609            private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrRuleGroup.uuid IS NULL";
610            private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrRuleGroup.uuid = ?";
611            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrRuleGroup.uuid IS NULL OR mdrRuleGroup.uuid = '')";
612            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
613                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
614                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
615                            new String[] { String.class.getName(), Long.class.getName() },
616                            MDRRuleGroupModelImpl.UUID_COLUMN_BITMASK |
617                            MDRRuleGroupModelImpl.GROUPID_COLUMN_BITMASK);
618            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
619                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
620                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
621                            new String[] { String.class.getName(), Long.class.getName() });
622    
623            /**
624             * Returns the m d r rule group where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchRuleGroupException} if it could not be found.
625             *
626             * @param uuid the uuid
627             * @param groupId the group ID
628             * @return the matching m d r rule group
629             * @throws NoSuchRuleGroupException if a matching m d r rule group could not be found
630             */
631            @Override
632            public MDRRuleGroup findByUUID_G(String uuid, long groupId)
633                    throws NoSuchRuleGroupException {
634                    MDRRuleGroup mdrRuleGroup = fetchByUUID_G(uuid, groupId);
635    
636                    if (mdrRuleGroup == null) {
637                            StringBundler msg = new StringBundler(6);
638    
639                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
640    
641                            msg.append("uuid=");
642                            msg.append(uuid);
643    
644                            msg.append(", groupId=");
645                            msg.append(groupId);
646    
647                            msg.append(StringPool.CLOSE_CURLY_BRACE);
648    
649                            if (_log.isWarnEnabled()) {
650                                    _log.warn(msg.toString());
651                            }
652    
653                            throw new NoSuchRuleGroupException(msg.toString());
654                    }
655    
656                    return mdrRuleGroup;
657            }
658    
659            /**
660             * Returns the m d r rule group where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
661             *
662             * @param uuid the uuid
663             * @param groupId the group ID
664             * @return the matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
665             */
666            @Override
667            public MDRRuleGroup fetchByUUID_G(String uuid, long groupId) {
668                    return fetchByUUID_G(uuid, groupId, true);
669            }
670    
671            /**
672             * Returns the m d r rule group where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
673             *
674             * @param uuid the uuid
675             * @param groupId the group ID
676             * @param retrieveFromCache whether to use the finder cache
677             * @return the matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
678             */
679            @Override
680            public MDRRuleGroup fetchByUUID_G(String uuid, long groupId,
681                    boolean retrieveFromCache) {
682                    Object[] finderArgs = new Object[] { uuid, groupId };
683    
684                    Object result = null;
685    
686                    if (retrieveFromCache) {
687                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
688                                            finderArgs, this);
689                    }
690    
691                    if (result instanceof MDRRuleGroup) {
692                            MDRRuleGroup mdrRuleGroup = (MDRRuleGroup)result;
693    
694                            if (!Validator.equals(uuid, mdrRuleGroup.getUuid()) ||
695                                            (groupId != mdrRuleGroup.getGroupId())) {
696                                    result = null;
697                            }
698                    }
699    
700                    if (result == null) {
701                            StringBundler query = new StringBundler(4);
702    
703                            query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
704    
705                            boolean bindUuid = false;
706    
707                            if (uuid == null) {
708                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
709                            }
710                            else if (uuid.equals(StringPool.BLANK)) {
711                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
712                            }
713                            else {
714                                    bindUuid = true;
715    
716                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
717                            }
718    
719                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
720    
721                            String sql = query.toString();
722    
723                            Session session = null;
724    
725                            try {
726                                    session = openSession();
727    
728                                    Query q = session.createQuery(sql);
729    
730                                    QueryPos qPos = QueryPos.getInstance(q);
731    
732                                    if (bindUuid) {
733                                            qPos.add(uuid);
734                                    }
735    
736                                    qPos.add(groupId);
737    
738                                    List<MDRRuleGroup> list = q.list();
739    
740                                    if (list.isEmpty()) {
741                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
742                                                    finderArgs, list);
743                                    }
744                                    else {
745                                            MDRRuleGroup mdrRuleGroup = list.get(0);
746    
747                                            result = mdrRuleGroup;
748    
749                                            cacheResult(mdrRuleGroup);
750    
751                                            if ((mdrRuleGroup.getUuid() == null) ||
752                                                            !mdrRuleGroup.getUuid().equals(uuid) ||
753                                                            (mdrRuleGroup.getGroupId() != groupId)) {
754                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
755                                                            finderArgs, mdrRuleGroup);
756                                            }
757                                    }
758                            }
759                            catch (Exception e) {
760                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
761                                            finderArgs);
762    
763                                    throw processException(e);
764                            }
765                            finally {
766                                    closeSession(session);
767                            }
768                    }
769    
770                    if (result instanceof List<?>) {
771                            return null;
772                    }
773                    else {
774                            return (MDRRuleGroup)result;
775                    }
776            }
777    
778            /**
779             * Removes the m d r rule group where uuid = &#63; and groupId = &#63; from the database.
780             *
781             * @param uuid the uuid
782             * @param groupId the group ID
783             * @return the m d r rule group that was removed
784             */
785            @Override
786            public MDRRuleGroup removeByUUID_G(String uuid, long groupId)
787                    throws NoSuchRuleGroupException {
788                    MDRRuleGroup mdrRuleGroup = findByUUID_G(uuid, groupId);
789    
790                    return remove(mdrRuleGroup);
791            }
792    
793            /**
794             * Returns the number of m d r rule groups where uuid = &#63; and groupId = &#63;.
795             *
796             * @param uuid the uuid
797             * @param groupId the group ID
798             * @return the number of matching m d r rule groups
799             */
800            @Override
801            public int countByUUID_G(String uuid, long groupId) {
802                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
803    
804                    Object[] finderArgs = new Object[] { uuid, groupId };
805    
806                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
807                                    this);
808    
809                    if (count == null) {
810                            StringBundler query = new StringBundler(3);
811    
812                            query.append(_SQL_COUNT_MDRRULEGROUP_WHERE);
813    
814                            boolean bindUuid = false;
815    
816                            if (uuid == null) {
817                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
818                            }
819                            else if (uuid.equals(StringPool.BLANK)) {
820                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
821                            }
822                            else {
823                                    bindUuid = true;
824    
825                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
826                            }
827    
828                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
829    
830                            String sql = query.toString();
831    
832                            Session session = null;
833    
834                            try {
835                                    session = openSession();
836    
837                                    Query q = session.createQuery(sql);
838    
839                                    QueryPos qPos = QueryPos.getInstance(q);
840    
841                                    if (bindUuid) {
842                                            qPos.add(uuid);
843                                    }
844    
845                                    qPos.add(groupId);
846    
847                                    count = (Long)q.uniqueResult();
848    
849                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
850                            }
851                            catch (Exception e) {
852                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
853    
854                                    throw processException(e);
855                            }
856                            finally {
857                                    closeSession(session);
858                            }
859                    }
860    
861                    return count.intValue();
862            }
863    
864            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrRuleGroup.uuid IS NULL AND ";
865            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrRuleGroup.uuid = ? AND ";
866            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrRuleGroup.uuid IS NULL OR mdrRuleGroup.uuid = '') AND ";
867            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrRuleGroup.groupId = ?";
868            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
869                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
870                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
871                            new String[] {
872                                    String.class.getName(), Long.class.getName(),
873                                    
874                            Integer.class.getName(), Integer.class.getName(),
875                                    OrderByComparator.class.getName()
876                            });
877            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
878                    new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
879                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
880                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
881                            new String[] { String.class.getName(), Long.class.getName() },
882                            MDRRuleGroupModelImpl.UUID_COLUMN_BITMASK |
883                            MDRRuleGroupModelImpl.COMPANYID_COLUMN_BITMASK);
884            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
885                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
886                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
887                            new String[] { String.class.getName(), Long.class.getName() });
888    
889            /**
890             * Returns all the m d r rule groups where uuid = &#63; and companyId = &#63;.
891             *
892             * @param uuid the uuid
893             * @param companyId the company ID
894             * @return the matching m d r rule groups
895             */
896            @Override
897            public List<MDRRuleGroup> findByUuid_C(String uuid, long companyId) {
898                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
899                            QueryUtil.ALL_POS, null);
900            }
901    
902            /**
903             * Returns a range of all the m d r rule groups where uuid = &#63; and companyId = &#63;.
904             *
905             * <p>
906             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
907             * </p>
908             *
909             * @param uuid the uuid
910             * @param companyId the company ID
911             * @param start the lower bound of the range of m d r rule groups
912             * @param end the upper bound of the range of m d r rule groups (not inclusive)
913             * @return the range of matching m d r rule groups
914             */
915            @Override
916            public List<MDRRuleGroup> findByUuid_C(String uuid, long companyId,
917                    int start, int end) {
918                    return findByUuid_C(uuid, companyId, start, end, null);
919            }
920    
921            /**
922             * Returns an ordered range of all the m d r rule groups where uuid = &#63; and companyId = &#63;.
923             *
924             * <p>
925             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
926             * </p>
927             *
928             * @param uuid the uuid
929             * @param companyId the company ID
930             * @param start the lower bound of the range of m d r rule groups
931             * @param end the upper bound of the range of m d r rule groups (not inclusive)
932             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
933             * @return the ordered range of matching m d r rule groups
934             */
935            @Override
936            public List<MDRRuleGroup> findByUuid_C(String uuid, long companyId,
937                    int start, int end, OrderByComparator<MDRRuleGroup> orderByComparator) {
938                    boolean pagination = true;
939                    FinderPath finderPath = null;
940                    Object[] finderArgs = null;
941    
942                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
943                                    (orderByComparator == null)) {
944                            pagination = false;
945                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
946                            finderArgs = new Object[] { uuid, companyId };
947                    }
948                    else {
949                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
950                            finderArgs = new Object[] {
951                                            uuid, companyId,
952                                            
953                                            start, end, orderByComparator
954                                    };
955                    }
956    
957                    List<MDRRuleGroup> list = (List<MDRRuleGroup>)FinderCacheUtil.getResult(finderPath,
958                                    finderArgs, this);
959    
960                    if ((list != null) && !list.isEmpty()) {
961                            for (MDRRuleGroup mdrRuleGroup : list) {
962                                    if (!Validator.equals(uuid, mdrRuleGroup.getUuid()) ||
963                                                    (companyId != mdrRuleGroup.getCompanyId())) {
964                                            list = null;
965    
966                                            break;
967                                    }
968                            }
969                    }
970    
971                    if (list == null) {
972                            StringBundler query = null;
973    
974                            if (orderByComparator != null) {
975                                    query = new StringBundler(4 +
976                                                    (orderByComparator.getOrderByFields().length * 3));
977                            }
978                            else {
979                                    query = new StringBundler(4);
980                            }
981    
982                            query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
983    
984                            boolean bindUuid = false;
985    
986                            if (uuid == null) {
987                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
988                            }
989                            else if (uuid.equals(StringPool.BLANK)) {
990                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
991                            }
992                            else {
993                                    bindUuid = true;
994    
995                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
996                            }
997    
998                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
999    
1000                            if (orderByComparator != null) {
1001                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1002                                            orderByComparator);
1003                            }
1004                            else
1005                             if (pagination) {
1006                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
1007                            }
1008    
1009                            String sql = query.toString();
1010    
1011                            Session session = null;
1012    
1013                            try {
1014                                    session = openSession();
1015    
1016                                    Query q = session.createQuery(sql);
1017    
1018                                    QueryPos qPos = QueryPos.getInstance(q);
1019    
1020                                    if (bindUuid) {
1021                                            qPos.add(uuid);
1022                                    }
1023    
1024                                    qPos.add(companyId);
1025    
1026                                    if (!pagination) {
1027                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
1028                                                            start, end, false);
1029    
1030                                            Collections.sort(list);
1031    
1032                                            list = Collections.unmodifiableList(list);
1033                                    }
1034                                    else {
1035                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
1036                                                            start, end);
1037                                    }
1038    
1039                                    cacheResult(list);
1040    
1041                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1042                            }
1043                            catch (Exception e) {
1044                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1045    
1046                                    throw processException(e);
1047                            }
1048                            finally {
1049                                    closeSession(session);
1050                            }
1051                    }
1052    
1053                    return list;
1054            }
1055    
1056            /**
1057             * Returns the first m d r rule group in the ordered set where uuid = &#63; and companyId = &#63;.
1058             *
1059             * @param uuid the uuid
1060             * @param companyId the company ID
1061             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1062             * @return the first matching m d r rule group
1063             * @throws NoSuchRuleGroupException if a matching m d r rule group could not be found
1064             */
1065            @Override
1066            public MDRRuleGroup findByUuid_C_First(String uuid, long companyId,
1067                    OrderByComparator<MDRRuleGroup> orderByComparator)
1068                    throws NoSuchRuleGroupException {
1069                    MDRRuleGroup mdrRuleGroup = fetchByUuid_C_First(uuid, companyId,
1070                                    orderByComparator);
1071    
1072                    if (mdrRuleGroup != null) {
1073                            return mdrRuleGroup;
1074                    }
1075    
1076                    StringBundler msg = new StringBundler(6);
1077    
1078                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1079    
1080                    msg.append("uuid=");
1081                    msg.append(uuid);
1082    
1083                    msg.append(", companyId=");
1084                    msg.append(companyId);
1085    
1086                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1087    
1088                    throw new NoSuchRuleGroupException(msg.toString());
1089            }
1090    
1091            /**
1092             * Returns the first m d r rule group in the ordered set where uuid = &#63; and companyId = &#63;.
1093             *
1094             * @param uuid the uuid
1095             * @param companyId the company ID
1096             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1097             * @return the first matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
1098             */
1099            @Override
1100            public MDRRuleGroup fetchByUuid_C_First(String uuid, long companyId,
1101                    OrderByComparator<MDRRuleGroup> orderByComparator) {
1102                    List<MDRRuleGroup> list = findByUuid_C(uuid, companyId, 0, 1,
1103                                    orderByComparator);
1104    
1105                    if (!list.isEmpty()) {
1106                            return list.get(0);
1107                    }
1108    
1109                    return null;
1110            }
1111    
1112            /**
1113             * Returns the last m d r rule group in the ordered set where uuid = &#63; and companyId = &#63;.
1114             *
1115             * @param uuid the uuid
1116             * @param companyId the company ID
1117             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1118             * @return the last matching m d r rule group
1119             * @throws NoSuchRuleGroupException if a matching m d r rule group could not be found
1120             */
1121            @Override
1122            public MDRRuleGroup findByUuid_C_Last(String uuid, long companyId,
1123                    OrderByComparator<MDRRuleGroup> orderByComparator)
1124                    throws NoSuchRuleGroupException {
1125                    MDRRuleGroup mdrRuleGroup = fetchByUuid_C_Last(uuid, companyId,
1126                                    orderByComparator);
1127    
1128                    if (mdrRuleGroup != null) {
1129                            return mdrRuleGroup;
1130                    }
1131    
1132                    StringBundler msg = new StringBundler(6);
1133    
1134                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1135    
1136                    msg.append("uuid=");
1137                    msg.append(uuid);
1138    
1139                    msg.append(", companyId=");
1140                    msg.append(companyId);
1141    
1142                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1143    
1144                    throw new NoSuchRuleGroupException(msg.toString());
1145            }
1146    
1147            /**
1148             * Returns the last m d r rule group in the ordered set where uuid = &#63; and companyId = &#63;.
1149             *
1150             * @param uuid the uuid
1151             * @param companyId the company ID
1152             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1153             * @return the last matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
1154             */
1155            @Override
1156            public MDRRuleGroup fetchByUuid_C_Last(String uuid, long companyId,
1157                    OrderByComparator<MDRRuleGroup> orderByComparator) {
1158                    int count = countByUuid_C(uuid, companyId);
1159    
1160                    if (count == 0) {
1161                            return null;
1162                    }
1163    
1164                    List<MDRRuleGroup> list = findByUuid_C(uuid, companyId, count - 1,
1165                                    count, orderByComparator);
1166    
1167                    if (!list.isEmpty()) {
1168                            return list.get(0);
1169                    }
1170    
1171                    return null;
1172            }
1173    
1174            /**
1175             * Returns the m d r rule groups before and after the current m d r rule group in the ordered set where uuid = &#63; and companyId = &#63;.
1176             *
1177             * @param ruleGroupId the primary key of the current m d r rule group
1178             * @param uuid the uuid
1179             * @param companyId the company ID
1180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1181             * @return the previous, current, and next m d r rule group
1182             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
1183             */
1184            @Override
1185            public MDRRuleGroup[] findByUuid_C_PrevAndNext(long ruleGroupId,
1186                    String uuid, long companyId,
1187                    OrderByComparator<MDRRuleGroup> orderByComparator)
1188                    throws NoSuchRuleGroupException {
1189                    MDRRuleGroup mdrRuleGroup = findByPrimaryKey(ruleGroupId);
1190    
1191                    Session session = null;
1192    
1193                    try {
1194                            session = openSession();
1195    
1196                            MDRRuleGroup[] array = new MDRRuleGroupImpl[3];
1197    
1198                            array[0] = getByUuid_C_PrevAndNext(session, mdrRuleGroup, uuid,
1199                                            companyId, orderByComparator, true);
1200    
1201                            array[1] = mdrRuleGroup;
1202    
1203                            array[2] = getByUuid_C_PrevAndNext(session, mdrRuleGroup, uuid,
1204                                            companyId, orderByComparator, false);
1205    
1206                            return array;
1207                    }
1208                    catch (Exception e) {
1209                            throw processException(e);
1210                    }
1211                    finally {
1212                            closeSession(session);
1213                    }
1214            }
1215    
1216            protected MDRRuleGroup getByUuid_C_PrevAndNext(Session session,
1217                    MDRRuleGroup mdrRuleGroup, String uuid, long companyId,
1218                    OrderByComparator<MDRRuleGroup> orderByComparator, boolean previous) {
1219                    StringBundler query = null;
1220    
1221                    if (orderByComparator != null) {
1222                            query = new StringBundler(6 +
1223                                            (orderByComparator.getOrderByFields().length * 6));
1224                    }
1225                    else {
1226                            query = new StringBundler(3);
1227                    }
1228    
1229                    query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
1230    
1231                    boolean bindUuid = false;
1232    
1233                    if (uuid == null) {
1234                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1235                    }
1236                    else if (uuid.equals(StringPool.BLANK)) {
1237                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1238                    }
1239                    else {
1240                            bindUuid = true;
1241    
1242                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1243                    }
1244    
1245                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1246    
1247                    if (orderByComparator != null) {
1248                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1249    
1250                            if (orderByConditionFields.length > 0) {
1251                                    query.append(WHERE_AND);
1252                            }
1253    
1254                            for (int i = 0; i < orderByConditionFields.length; i++) {
1255                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1256                                    query.append(orderByConditionFields[i]);
1257    
1258                                    if ((i + 1) < orderByConditionFields.length) {
1259                                            if (orderByComparator.isAscending() ^ previous) {
1260                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1261                                            }
1262                                            else {
1263                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1264                                            }
1265                                    }
1266                                    else {
1267                                            if (orderByComparator.isAscending() ^ previous) {
1268                                                    query.append(WHERE_GREATER_THAN);
1269                                            }
1270                                            else {
1271                                                    query.append(WHERE_LESSER_THAN);
1272                                            }
1273                                    }
1274                            }
1275    
1276                            query.append(ORDER_BY_CLAUSE);
1277    
1278                            String[] orderByFields = orderByComparator.getOrderByFields();
1279    
1280                            for (int i = 0; i < orderByFields.length; i++) {
1281                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1282                                    query.append(orderByFields[i]);
1283    
1284                                    if ((i + 1) < orderByFields.length) {
1285                                            if (orderByComparator.isAscending() ^ previous) {
1286                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1287                                            }
1288                                            else {
1289                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1290                                            }
1291                                    }
1292                                    else {
1293                                            if (orderByComparator.isAscending() ^ previous) {
1294                                                    query.append(ORDER_BY_ASC);
1295                                            }
1296                                            else {
1297                                                    query.append(ORDER_BY_DESC);
1298                                            }
1299                                    }
1300                            }
1301                    }
1302                    else {
1303                            query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
1304                    }
1305    
1306                    String sql = query.toString();
1307    
1308                    Query q = session.createQuery(sql);
1309    
1310                    q.setFirstResult(0);
1311                    q.setMaxResults(2);
1312    
1313                    QueryPos qPos = QueryPos.getInstance(q);
1314    
1315                    if (bindUuid) {
1316                            qPos.add(uuid);
1317                    }
1318    
1319                    qPos.add(companyId);
1320    
1321                    if (orderByComparator != null) {
1322                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroup);
1323    
1324                            for (Object value : values) {
1325                                    qPos.add(value);
1326                            }
1327                    }
1328    
1329                    List<MDRRuleGroup> list = q.list();
1330    
1331                    if (list.size() == 2) {
1332                            return list.get(1);
1333                    }
1334                    else {
1335                            return null;
1336                    }
1337            }
1338    
1339            /**
1340             * Removes all the m d r rule groups where uuid = &#63; and companyId = &#63; from the database.
1341             *
1342             * @param uuid the uuid
1343             * @param companyId the company ID
1344             */
1345            @Override
1346            public void removeByUuid_C(String uuid, long companyId) {
1347                    for (MDRRuleGroup mdrRuleGroup : findByUuid_C(uuid, companyId,
1348                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1349                            remove(mdrRuleGroup);
1350                    }
1351            }
1352    
1353            /**
1354             * Returns the number of m d r rule groups where uuid = &#63; and companyId = &#63;.
1355             *
1356             * @param uuid the uuid
1357             * @param companyId the company ID
1358             * @return the number of matching m d r rule groups
1359             */
1360            @Override
1361            public int countByUuid_C(String uuid, long companyId) {
1362                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1363    
1364                    Object[] finderArgs = new Object[] { uuid, companyId };
1365    
1366                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1367                                    this);
1368    
1369                    if (count == null) {
1370                            StringBundler query = new StringBundler(3);
1371    
1372                            query.append(_SQL_COUNT_MDRRULEGROUP_WHERE);
1373    
1374                            boolean bindUuid = false;
1375    
1376                            if (uuid == null) {
1377                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1378                            }
1379                            else if (uuid.equals(StringPool.BLANK)) {
1380                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1381                            }
1382                            else {
1383                                    bindUuid = true;
1384    
1385                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1386                            }
1387    
1388                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1389    
1390                            String sql = query.toString();
1391    
1392                            Session session = null;
1393    
1394                            try {
1395                                    session = openSession();
1396    
1397                                    Query q = session.createQuery(sql);
1398    
1399                                    QueryPos qPos = QueryPos.getInstance(q);
1400    
1401                                    if (bindUuid) {
1402                                            qPos.add(uuid);
1403                                    }
1404    
1405                                    qPos.add(companyId);
1406    
1407                                    count = (Long)q.uniqueResult();
1408    
1409                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1410                            }
1411                            catch (Exception e) {
1412                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1413    
1414                                    throw processException(e);
1415                            }
1416                            finally {
1417                                    closeSession(session);
1418                            }
1419                    }
1420    
1421                    return count.intValue();
1422            }
1423    
1424            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mdrRuleGroup.uuid IS NULL AND ";
1425            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mdrRuleGroup.uuid = ? AND ";
1426            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mdrRuleGroup.uuid IS NULL OR mdrRuleGroup.uuid = '') AND ";
1427            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mdrRuleGroup.companyId = ?";
1428            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
1429                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
1430                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1431                            new String[] {
1432                                    Long.class.getName(),
1433                                    
1434                            Integer.class.getName(), Integer.class.getName(),
1435                                    OrderByComparator.class.getName()
1436                            });
1437            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1438                    new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
1439                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, MDRRuleGroupImpl.class,
1440                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1441                            new String[] { Long.class.getName() },
1442                            MDRRuleGroupModelImpl.GROUPID_COLUMN_BITMASK);
1443            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
1444                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
1445                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1446                            new String[] { Long.class.getName() });
1447            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID = new FinderPath(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
1448                            MDRRuleGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
1449                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByGroupId",
1450                            new String[] { Long.class.getName() });
1451    
1452            /**
1453             * Returns all the m d r rule groups where groupId = &#63;.
1454             *
1455             * @param groupId the group ID
1456             * @return the matching m d r rule groups
1457             */
1458            @Override
1459            public List<MDRRuleGroup> findByGroupId(long groupId) {
1460                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1461            }
1462    
1463            /**
1464             * Returns a range of all the m d r rule groups where groupId = &#63;.
1465             *
1466             * <p>
1467             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1468             * </p>
1469             *
1470             * @param groupId the group ID
1471             * @param start the lower bound of the range of m d r rule groups
1472             * @param end the upper bound of the range of m d r rule groups (not inclusive)
1473             * @return the range of matching m d r rule groups
1474             */
1475            @Override
1476            public List<MDRRuleGroup> findByGroupId(long groupId, int start, int end) {
1477                    return findByGroupId(groupId, start, end, null);
1478            }
1479    
1480            /**
1481             * Returns an ordered range of all the m d r rule groups where groupId = &#63;.
1482             *
1483             * <p>
1484             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1485             * </p>
1486             *
1487             * @param groupId the group ID
1488             * @param start the lower bound of the range of m d r rule groups
1489             * @param end the upper bound of the range of m d r rule groups (not inclusive)
1490             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1491             * @return the ordered range of matching m d r rule groups
1492             */
1493            @Override
1494            public List<MDRRuleGroup> findByGroupId(long groupId, int start, int end,
1495                    OrderByComparator<MDRRuleGroup> orderByComparator) {
1496                    boolean pagination = true;
1497                    FinderPath finderPath = null;
1498                    Object[] finderArgs = null;
1499    
1500                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1501                                    (orderByComparator == null)) {
1502                            pagination = false;
1503                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1504                            finderArgs = new Object[] { groupId };
1505                    }
1506                    else {
1507                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1508                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1509                    }
1510    
1511                    List<MDRRuleGroup> list = (List<MDRRuleGroup>)FinderCacheUtil.getResult(finderPath,
1512                                    finderArgs, this);
1513    
1514                    if ((list != null) && !list.isEmpty()) {
1515                            for (MDRRuleGroup mdrRuleGroup : list) {
1516                                    if ((groupId != mdrRuleGroup.getGroupId())) {
1517                                            list = null;
1518    
1519                                            break;
1520                                    }
1521                            }
1522                    }
1523    
1524                    if (list == null) {
1525                            StringBundler query = null;
1526    
1527                            if (orderByComparator != null) {
1528                                    query = new StringBundler(3 +
1529                                                    (orderByComparator.getOrderByFields().length * 3));
1530                            }
1531                            else {
1532                                    query = new StringBundler(3);
1533                            }
1534    
1535                            query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
1536    
1537                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1538    
1539                            if (orderByComparator != null) {
1540                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1541                                            orderByComparator);
1542                            }
1543                            else
1544                             if (pagination) {
1545                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
1546                            }
1547    
1548                            String sql = query.toString();
1549    
1550                            Session session = null;
1551    
1552                            try {
1553                                    session = openSession();
1554    
1555                                    Query q = session.createQuery(sql);
1556    
1557                                    QueryPos qPos = QueryPos.getInstance(q);
1558    
1559                                    qPos.add(groupId);
1560    
1561                                    if (!pagination) {
1562                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
1563                                                            start, end, false);
1564    
1565                                            Collections.sort(list);
1566    
1567                                            list = Collections.unmodifiableList(list);
1568                                    }
1569                                    else {
1570                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
1571                                                            start, end);
1572                                    }
1573    
1574                                    cacheResult(list);
1575    
1576                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1577                            }
1578                            catch (Exception e) {
1579                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1580    
1581                                    throw processException(e);
1582                            }
1583                            finally {
1584                                    closeSession(session);
1585                            }
1586                    }
1587    
1588                    return list;
1589            }
1590    
1591            /**
1592             * Returns the first m d r rule group in the ordered set where groupId = &#63;.
1593             *
1594             * @param groupId the group ID
1595             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1596             * @return the first matching m d r rule group
1597             * @throws NoSuchRuleGroupException if a matching m d r rule group could not be found
1598             */
1599            @Override
1600            public MDRRuleGroup findByGroupId_First(long groupId,
1601                    OrderByComparator<MDRRuleGroup> orderByComparator)
1602                    throws NoSuchRuleGroupException {
1603                    MDRRuleGroup mdrRuleGroup = fetchByGroupId_First(groupId,
1604                                    orderByComparator);
1605    
1606                    if (mdrRuleGroup != null) {
1607                            return mdrRuleGroup;
1608                    }
1609    
1610                    StringBundler msg = new StringBundler(4);
1611    
1612                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1613    
1614                    msg.append("groupId=");
1615                    msg.append(groupId);
1616    
1617                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1618    
1619                    throw new NoSuchRuleGroupException(msg.toString());
1620            }
1621    
1622            /**
1623             * Returns the first m d r rule group in the ordered set where groupId = &#63;.
1624             *
1625             * @param groupId the group ID
1626             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1627             * @return the first matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
1628             */
1629            @Override
1630            public MDRRuleGroup fetchByGroupId_First(long groupId,
1631                    OrderByComparator<MDRRuleGroup> orderByComparator) {
1632                    List<MDRRuleGroup> list = findByGroupId(groupId, 0, 1, orderByComparator);
1633    
1634                    if (!list.isEmpty()) {
1635                            return list.get(0);
1636                    }
1637    
1638                    return null;
1639            }
1640    
1641            /**
1642             * Returns the last m d r rule group in the ordered set where groupId = &#63;.
1643             *
1644             * @param groupId the group ID
1645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1646             * @return the last matching m d r rule group
1647             * @throws NoSuchRuleGroupException if a matching m d r rule group could not be found
1648             */
1649            @Override
1650            public MDRRuleGroup findByGroupId_Last(long groupId,
1651                    OrderByComparator<MDRRuleGroup> orderByComparator)
1652                    throws NoSuchRuleGroupException {
1653                    MDRRuleGroup mdrRuleGroup = fetchByGroupId_Last(groupId,
1654                                    orderByComparator);
1655    
1656                    if (mdrRuleGroup != null) {
1657                            return mdrRuleGroup;
1658                    }
1659    
1660                    StringBundler msg = new StringBundler(4);
1661    
1662                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1663    
1664                    msg.append("groupId=");
1665                    msg.append(groupId);
1666    
1667                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1668    
1669                    throw new NoSuchRuleGroupException(msg.toString());
1670            }
1671    
1672            /**
1673             * Returns the last m d r rule group in the ordered set where groupId = &#63;.
1674             *
1675             * @param groupId the group ID
1676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1677             * @return the last matching m d r rule group, or <code>null</code> if a matching m d r rule group could not be found
1678             */
1679            @Override
1680            public MDRRuleGroup fetchByGroupId_Last(long groupId,
1681                    OrderByComparator<MDRRuleGroup> orderByComparator) {
1682                    int count = countByGroupId(groupId);
1683    
1684                    if (count == 0) {
1685                            return null;
1686                    }
1687    
1688                    List<MDRRuleGroup> list = findByGroupId(groupId, count - 1, count,
1689                                    orderByComparator);
1690    
1691                    if (!list.isEmpty()) {
1692                            return list.get(0);
1693                    }
1694    
1695                    return null;
1696            }
1697    
1698            /**
1699             * Returns the m d r rule groups before and after the current m d r rule group in the ordered set where groupId = &#63;.
1700             *
1701             * @param ruleGroupId the primary key of the current m d r rule group
1702             * @param groupId the group ID
1703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1704             * @return the previous, current, and next m d r rule group
1705             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
1706             */
1707            @Override
1708            public MDRRuleGroup[] findByGroupId_PrevAndNext(long ruleGroupId,
1709                    long groupId, OrderByComparator<MDRRuleGroup> orderByComparator)
1710                    throws NoSuchRuleGroupException {
1711                    MDRRuleGroup mdrRuleGroup = findByPrimaryKey(ruleGroupId);
1712    
1713                    Session session = null;
1714    
1715                    try {
1716                            session = openSession();
1717    
1718                            MDRRuleGroup[] array = new MDRRuleGroupImpl[3];
1719    
1720                            array[0] = getByGroupId_PrevAndNext(session, mdrRuleGroup, groupId,
1721                                            orderByComparator, true);
1722    
1723                            array[1] = mdrRuleGroup;
1724    
1725                            array[2] = getByGroupId_PrevAndNext(session, mdrRuleGroup, groupId,
1726                                            orderByComparator, false);
1727    
1728                            return array;
1729                    }
1730                    catch (Exception e) {
1731                            throw processException(e);
1732                    }
1733                    finally {
1734                            closeSession(session);
1735                    }
1736            }
1737    
1738            protected MDRRuleGroup getByGroupId_PrevAndNext(Session session,
1739                    MDRRuleGroup mdrRuleGroup, long groupId,
1740                    OrderByComparator<MDRRuleGroup> orderByComparator, boolean previous) {
1741                    StringBundler query = null;
1742    
1743                    if (orderByComparator != null) {
1744                            query = new StringBundler(6 +
1745                                            (orderByComparator.getOrderByFields().length * 6));
1746                    }
1747                    else {
1748                            query = new StringBundler(3);
1749                    }
1750    
1751                    query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
1752    
1753                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1754    
1755                    if (orderByComparator != null) {
1756                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1757    
1758                            if (orderByConditionFields.length > 0) {
1759                                    query.append(WHERE_AND);
1760                            }
1761    
1762                            for (int i = 0; i < orderByConditionFields.length; i++) {
1763                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1764                                    query.append(orderByConditionFields[i]);
1765    
1766                                    if ((i + 1) < orderByConditionFields.length) {
1767                                            if (orderByComparator.isAscending() ^ previous) {
1768                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1769                                            }
1770                                            else {
1771                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1772                                            }
1773                                    }
1774                                    else {
1775                                            if (orderByComparator.isAscending() ^ previous) {
1776                                                    query.append(WHERE_GREATER_THAN);
1777                                            }
1778                                            else {
1779                                                    query.append(WHERE_LESSER_THAN);
1780                                            }
1781                                    }
1782                            }
1783    
1784                            query.append(ORDER_BY_CLAUSE);
1785    
1786                            String[] orderByFields = orderByComparator.getOrderByFields();
1787    
1788                            for (int i = 0; i < orderByFields.length; i++) {
1789                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1790                                    query.append(orderByFields[i]);
1791    
1792                                    if ((i + 1) < orderByFields.length) {
1793                                            if (orderByComparator.isAscending() ^ previous) {
1794                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1795                                            }
1796                                            else {
1797                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1798                                            }
1799                                    }
1800                                    else {
1801                                            if (orderByComparator.isAscending() ^ previous) {
1802                                                    query.append(ORDER_BY_ASC);
1803                                            }
1804                                            else {
1805                                                    query.append(ORDER_BY_DESC);
1806                                            }
1807                                    }
1808                            }
1809                    }
1810                    else {
1811                            query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
1812                    }
1813    
1814                    String sql = query.toString();
1815    
1816                    Query q = session.createQuery(sql);
1817    
1818                    q.setFirstResult(0);
1819                    q.setMaxResults(2);
1820    
1821                    QueryPos qPos = QueryPos.getInstance(q);
1822    
1823                    qPos.add(groupId);
1824    
1825                    if (orderByComparator != null) {
1826                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroup);
1827    
1828                            for (Object value : values) {
1829                                    qPos.add(value);
1830                            }
1831                    }
1832    
1833                    List<MDRRuleGroup> list = q.list();
1834    
1835                    if (list.size() == 2) {
1836                            return list.get(1);
1837                    }
1838                    else {
1839                            return null;
1840                    }
1841            }
1842    
1843            /**
1844             * Returns all the m d r rule groups that the user has permission to view where groupId = &#63;.
1845             *
1846             * @param groupId the group ID
1847             * @return the matching m d r rule groups that the user has permission to view
1848             */
1849            @Override
1850            public List<MDRRuleGroup> filterFindByGroupId(long groupId) {
1851                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1852                            QueryUtil.ALL_POS, null);
1853            }
1854    
1855            /**
1856             * Returns a range of all the m d r rule groups that the user has permission to view where groupId = &#63;.
1857             *
1858             * <p>
1859             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1860             * </p>
1861             *
1862             * @param groupId the group ID
1863             * @param start the lower bound of the range of m d r rule groups
1864             * @param end the upper bound of the range of m d r rule groups (not inclusive)
1865             * @return the range of matching m d r rule groups that the user has permission to view
1866             */
1867            @Override
1868            public List<MDRRuleGroup> filterFindByGroupId(long groupId, int start,
1869                    int end) {
1870                    return filterFindByGroupId(groupId, start, end, null);
1871            }
1872    
1873            /**
1874             * Returns an ordered range of all the m d r rule groups that the user has permissions to view where groupId = &#63;.
1875             *
1876             * <p>
1877             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1878             * </p>
1879             *
1880             * @param groupId the group ID
1881             * @param start the lower bound of the range of m d r rule groups
1882             * @param end the upper bound of the range of m d r rule groups (not inclusive)
1883             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1884             * @return the ordered range of matching m d r rule groups that the user has permission to view
1885             */
1886            @Override
1887            public List<MDRRuleGroup> filterFindByGroupId(long groupId, int start,
1888                    int end, OrderByComparator<MDRRuleGroup> orderByComparator) {
1889                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1890                            return findByGroupId(groupId, start, end, orderByComparator);
1891                    }
1892    
1893                    StringBundler query = null;
1894    
1895                    if (orderByComparator != null) {
1896                            query = new StringBundler(3 +
1897                                            (orderByComparator.getOrderByFields().length * 3));
1898                    }
1899                    else {
1900                            query = new StringBundler(3);
1901                    }
1902    
1903                    if (getDB().isSupportsInlineDistinct()) {
1904                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_WHERE);
1905                    }
1906                    else {
1907                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_1);
1908                    }
1909    
1910                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1911    
1912                    if (!getDB().isSupportsInlineDistinct()) {
1913                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_2);
1914                    }
1915    
1916                    if (orderByComparator != null) {
1917                            if (getDB().isSupportsInlineDistinct()) {
1918                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1919                                            orderByComparator, true);
1920                            }
1921                            else {
1922                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1923                                            orderByComparator, true);
1924                            }
1925                    }
1926                    else {
1927                            if (getDB().isSupportsInlineDistinct()) {
1928                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
1929                            }
1930                            else {
1931                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_SQL);
1932                            }
1933                    }
1934    
1935                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1936                                    MDRRuleGroup.class.getName(),
1937                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1938    
1939                    Session session = null;
1940    
1941                    try {
1942                            session = openSession();
1943    
1944                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1945    
1946                            if (getDB().isSupportsInlineDistinct()) {
1947                                    q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupImpl.class);
1948                            }
1949                            else {
1950                                    q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupImpl.class);
1951                            }
1952    
1953                            QueryPos qPos = QueryPos.getInstance(q);
1954    
1955                            qPos.add(groupId);
1956    
1957                            return (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(), start,
1958                                    end);
1959                    }
1960                    catch (Exception e) {
1961                            throw processException(e);
1962                    }
1963                    finally {
1964                            closeSession(session);
1965                    }
1966            }
1967    
1968            /**
1969             * Returns the m d r rule groups before and after the current m d r rule group in the ordered set of m d r rule groups that the user has permission to view where groupId = &#63;.
1970             *
1971             * @param ruleGroupId the primary key of the current m d r rule group
1972             * @param groupId the group ID
1973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1974             * @return the previous, current, and next m d r rule group
1975             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
1976             */
1977            @Override
1978            public MDRRuleGroup[] filterFindByGroupId_PrevAndNext(long ruleGroupId,
1979                    long groupId, OrderByComparator<MDRRuleGroup> orderByComparator)
1980                    throws NoSuchRuleGroupException {
1981                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1982                            return findByGroupId_PrevAndNext(ruleGroupId, groupId,
1983                                    orderByComparator);
1984                    }
1985    
1986                    MDRRuleGroup mdrRuleGroup = findByPrimaryKey(ruleGroupId);
1987    
1988                    Session session = null;
1989    
1990                    try {
1991                            session = openSession();
1992    
1993                            MDRRuleGroup[] array = new MDRRuleGroupImpl[3];
1994    
1995                            array[0] = filterGetByGroupId_PrevAndNext(session, mdrRuleGroup,
1996                                            groupId, orderByComparator, true);
1997    
1998                            array[1] = mdrRuleGroup;
1999    
2000                            array[2] = filterGetByGroupId_PrevAndNext(session, mdrRuleGroup,
2001                                            groupId, orderByComparator, false);
2002    
2003                            return array;
2004                    }
2005                    catch (Exception e) {
2006                            throw processException(e);
2007                    }
2008                    finally {
2009                            closeSession(session);
2010                    }
2011            }
2012    
2013            protected MDRRuleGroup filterGetByGroupId_PrevAndNext(Session session,
2014                    MDRRuleGroup mdrRuleGroup, long groupId,
2015                    OrderByComparator<MDRRuleGroup> orderByComparator, boolean previous) {
2016                    StringBundler query = null;
2017    
2018                    if (orderByComparator != null) {
2019                            query = new StringBundler(6 +
2020                                            (orderByComparator.getOrderByFields().length * 6));
2021                    }
2022                    else {
2023                            query = new StringBundler(3);
2024                    }
2025    
2026                    if (getDB().isSupportsInlineDistinct()) {
2027                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_WHERE);
2028                    }
2029                    else {
2030                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_1);
2031                    }
2032    
2033                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2034    
2035                    if (!getDB().isSupportsInlineDistinct()) {
2036                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_2);
2037                    }
2038    
2039                    if (orderByComparator != null) {
2040                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2041    
2042                            if (orderByConditionFields.length > 0) {
2043                                    query.append(WHERE_AND);
2044                            }
2045    
2046                            for (int i = 0; i < orderByConditionFields.length; i++) {
2047                                    if (getDB().isSupportsInlineDistinct()) {
2048                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2049                                    }
2050                                    else {
2051                                            query.append(_ORDER_BY_ENTITY_TABLE);
2052                                    }
2053    
2054                                    query.append(orderByConditionFields[i]);
2055    
2056                                    if ((i + 1) < orderByConditionFields.length) {
2057                                            if (orderByComparator.isAscending() ^ previous) {
2058                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2059                                            }
2060                                            else {
2061                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2062                                            }
2063                                    }
2064                                    else {
2065                                            if (orderByComparator.isAscending() ^ previous) {
2066                                                    query.append(WHERE_GREATER_THAN);
2067                                            }
2068                                            else {
2069                                                    query.append(WHERE_LESSER_THAN);
2070                                            }
2071                                    }
2072                            }
2073    
2074                            query.append(ORDER_BY_CLAUSE);
2075    
2076                            String[] orderByFields = orderByComparator.getOrderByFields();
2077    
2078                            for (int i = 0; i < orderByFields.length; i++) {
2079                                    if (getDB().isSupportsInlineDistinct()) {
2080                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2081                                    }
2082                                    else {
2083                                            query.append(_ORDER_BY_ENTITY_TABLE);
2084                                    }
2085    
2086                                    query.append(orderByFields[i]);
2087    
2088                                    if ((i + 1) < orderByFields.length) {
2089                                            if (orderByComparator.isAscending() ^ previous) {
2090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2091                                            }
2092                                            else {
2093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2094                                            }
2095                                    }
2096                                    else {
2097                                            if (orderByComparator.isAscending() ^ previous) {
2098                                                    query.append(ORDER_BY_ASC);
2099                                            }
2100                                            else {
2101                                                    query.append(ORDER_BY_DESC);
2102                                            }
2103                                    }
2104                            }
2105                    }
2106                    else {
2107                            if (getDB().isSupportsInlineDistinct()) {
2108                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
2109                            }
2110                            else {
2111                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_SQL);
2112                            }
2113                    }
2114    
2115                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2116                                    MDRRuleGroup.class.getName(),
2117                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2118    
2119                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2120    
2121                    q.setFirstResult(0);
2122                    q.setMaxResults(2);
2123    
2124                    if (getDB().isSupportsInlineDistinct()) {
2125                            q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupImpl.class);
2126                    }
2127                    else {
2128                            q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupImpl.class);
2129                    }
2130    
2131                    QueryPos qPos = QueryPos.getInstance(q);
2132    
2133                    qPos.add(groupId);
2134    
2135                    if (orderByComparator != null) {
2136                            Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroup);
2137    
2138                            for (Object value : values) {
2139                                    qPos.add(value);
2140                            }
2141                    }
2142    
2143                    List<MDRRuleGroup> list = q.list();
2144    
2145                    if (list.size() == 2) {
2146                            return list.get(1);
2147                    }
2148                    else {
2149                            return null;
2150                    }
2151            }
2152    
2153            /**
2154             * Returns all the m d r rule groups that the user has permission to view where groupId = any &#63;.
2155             *
2156             * @param groupIds the group IDs
2157             * @return the matching m d r rule groups that the user has permission to view
2158             */
2159            @Override
2160            public List<MDRRuleGroup> filterFindByGroupId(long[] groupIds) {
2161                    return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
2162                            QueryUtil.ALL_POS, null);
2163            }
2164    
2165            /**
2166             * Returns a range of all the m d r rule groups that the user has permission to view where groupId = any &#63;.
2167             *
2168             * <p>
2169             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2170             * </p>
2171             *
2172             * @param groupIds the group IDs
2173             * @param start the lower bound of the range of m d r rule groups
2174             * @param end the upper bound of the range of m d r rule groups (not inclusive)
2175             * @return the range of matching m d r rule groups that the user has permission to view
2176             */
2177            @Override
2178            public List<MDRRuleGroup> filterFindByGroupId(long[] groupIds, int start,
2179                    int end) {
2180                    return filterFindByGroupId(groupIds, start, end, null);
2181            }
2182    
2183            /**
2184             * Returns an ordered range of all the m d r rule groups that the user has permission to view where groupId = any &#63;.
2185             *
2186             * <p>
2187             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2188             * </p>
2189             *
2190             * @param groupIds the group IDs
2191             * @param start the lower bound of the range of m d r rule groups
2192             * @param end the upper bound of the range of m d r rule groups (not inclusive)
2193             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2194             * @return the ordered range of matching m d r rule groups that the user has permission to view
2195             */
2196            @Override
2197            public List<MDRRuleGroup> filterFindByGroupId(long[] groupIds, int start,
2198                    int end, OrderByComparator<MDRRuleGroup> orderByComparator) {
2199                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2200                            return findByGroupId(groupIds, start, end, orderByComparator);
2201                    }
2202    
2203                    if (groupIds == null) {
2204                            groupIds = new long[0];
2205                    }
2206                    else {
2207                            groupIds = ArrayUtil.unique(groupIds);
2208                    }
2209    
2210                    StringBundler query = new StringBundler();
2211    
2212                    if (getDB().isSupportsInlineDistinct()) {
2213                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_WHERE);
2214                    }
2215                    else {
2216                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_1);
2217                    }
2218    
2219                    if (groupIds.length > 0) {
2220                            query.append(StringPool.OPEN_PARENTHESIS);
2221    
2222                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2223    
2224                            query.append(StringUtil.merge(groupIds));
2225    
2226                            query.append(StringPool.CLOSE_PARENTHESIS);
2227    
2228                            query.append(StringPool.CLOSE_PARENTHESIS);
2229                    }
2230    
2231                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
2232                            query.index() - 1);
2233    
2234                    if (!getDB().isSupportsInlineDistinct()) {
2235                            query.append(_FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_2);
2236                    }
2237    
2238                    if (orderByComparator != null) {
2239                            if (getDB().isSupportsInlineDistinct()) {
2240                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2241                                            orderByComparator, true);
2242                            }
2243                            else {
2244                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2245                                            orderByComparator, true);
2246                            }
2247                    }
2248                    else {
2249                            if (getDB().isSupportsInlineDistinct()) {
2250                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
2251                            }
2252                            else {
2253                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_SQL);
2254                            }
2255                    }
2256    
2257                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2258                                    MDRRuleGroup.class.getName(),
2259                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2260    
2261                    Session session = null;
2262    
2263                    try {
2264                            session = openSession();
2265    
2266                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2267    
2268                            if (getDB().isSupportsInlineDistinct()) {
2269                                    q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupImpl.class);
2270                            }
2271                            else {
2272                                    q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupImpl.class);
2273                            }
2274    
2275                            return (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(), start,
2276                                    end);
2277                    }
2278                    catch (Exception e) {
2279                            throw processException(e);
2280                    }
2281                    finally {
2282                            closeSession(session);
2283                    }
2284            }
2285    
2286            /**
2287             * Returns all the m d r rule groups where groupId = any &#63;.
2288             *
2289             * <p>
2290             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2291             * </p>
2292             *
2293             * @param groupIds the group IDs
2294             * @return the matching m d r rule groups
2295             */
2296            @Override
2297            public List<MDRRuleGroup> findByGroupId(long[] groupIds) {
2298                    return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2299                            null);
2300            }
2301    
2302            /**
2303             * Returns a range of all the m d r rule groups where groupId = any &#63;.
2304             *
2305             * <p>
2306             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2307             * </p>
2308             *
2309             * @param groupIds the group IDs
2310             * @param start the lower bound of the range of m d r rule groups
2311             * @param end the upper bound of the range of m d r rule groups (not inclusive)
2312             * @return the range of matching m d r rule groups
2313             */
2314            @Override
2315            public List<MDRRuleGroup> findByGroupId(long[] groupIds, int start, int end) {
2316                    return findByGroupId(groupIds, start, end, null);
2317            }
2318    
2319            /**
2320             * Returns an ordered range of all the m d r rule groups where groupId = any &#63;.
2321             *
2322             * <p>
2323             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2324             * </p>
2325             *
2326             * @param groupIds the group IDs
2327             * @param start the lower bound of the range of m d r rule groups
2328             * @param end the upper bound of the range of m d r rule groups (not inclusive)
2329             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2330             * @return the ordered range of matching m d r rule groups
2331             */
2332            @Override
2333            public List<MDRRuleGroup> findByGroupId(long[] groupIds, int start,
2334                    int end, OrderByComparator<MDRRuleGroup> orderByComparator) {
2335                    if (groupIds == null) {
2336                            groupIds = new long[0];
2337                    }
2338                    else {
2339                            groupIds = ArrayUtil.unique(groupIds);
2340                    }
2341    
2342                    if (groupIds.length == 1) {
2343                            return findByGroupId(groupIds[0], start, end, orderByComparator);
2344                    }
2345    
2346                    boolean pagination = true;
2347                    Object[] finderArgs = null;
2348    
2349                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2350                                    (orderByComparator == null)) {
2351                            pagination = false;
2352                            finderArgs = new Object[] { StringUtil.merge(groupIds) };
2353                    }
2354                    else {
2355                            finderArgs = new Object[] {
2356                                            StringUtil.merge(groupIds),
2357                                            
2358                                            start, end, orderByComparator
2359                                    };
2360                    }
2361    
2362                    List<MDRRuleGroup> list = (List<MDRRuleGroup>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2363                                    finderArgs, this);
2364    
2365                    if ((list != null) && !list.isEmpty()) {
2366                            for (MDRRuleGroup mdrRuleGroup : list) {
2367                                    if (!ArrayUtil.contains(groupIds, mdrRuleGroup.getGroupId())) {
2368                                            list = null;
2369    
2370                                            break;
2371                                    }
2372                            }
2373                    }
2374    
2375                    if (list == null) {
2376                            StringBundler query = new StringBundler();
2377    
2378                            query.append(_SQL_SELECT_MDRRULEGROUP_WHERE);
2379    
2380                            if (groupIds.length > 0) {
2381                                    query.append(StringPool.OPEN_PARENTHESIS);
2382    
2383                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2384    
2385                                    query.append(StringUtil.merge(groupIds));
2386    
2387                                    query.append(StringPool.CLOSE_PARENTHESIS);
2388    
2389                                    query.append(StringPool.CLOSE_PARENTHESIS);
2390                            }
2391    
2392                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
2393                                                    1)), query.index() - 1);
2394    
2395                            if (orderByComparator != null) {
2396                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2397                                            orderByComparator);
2398                            }
2399                            else
2400                             if (pagination) {
2401                                    query.append(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
2402                            }
2403    
2404                            String sql = query.toString();
2405    
2406                            Session session = null;
2407    
2408                            try {
2409                                    session = openSession();
2410    
2411                                    Query q = session.createQuery(sql);
2412    
2413                                    if (!pagination) {
2414                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
2415                                                            start, end, false);
2416    
2417                                            Collections.sort(list);
2418    
2419                                            list = Collections.unmodifiableList(list);
2420                                    }
2421                                    else {
2422                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
2423                                                            start, end);
2424                                    }
2425    
2426                                    cacheResult(list);
2427    
2428                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2429                                            finderArgs, list);
2430                            }
2431                            catch (Exception e) {
2432                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2433                                            finderArgs);
2434    
2435                                    throw processException(e);
2436                            }
2437                            finally {
2438                                    closeSession(session);
2439                            }
2440                    }
2441    
2442                    return list;
2443            }
2444    
2445            /**
2446             * Removes all the m d r rule groups where groupId = &#63; from the database.
2447             *
2448             * @param groupId the group ID
2449             */
2450            @Override
2451            public void removeByGroupId(long groupId) {
2452                    for (MDRRuleGroup mdrRuleGroup : findByGroupId(groupId,
2453                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2454                            remove(mdrRuleGroup);
2455                    }
2456            }
2457    
2458            /**
2459             * Returns the number of m d r rule groups where groupId = &#63;.
2460             *
2461             * @param groupId the group ID
2462             * @return the number of matching m d r rule groups
2463             */
2464            @Override
2465            public int countByGroupId(long groupId) {
2466                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2467    
2468                    Object[] finderArgs = new Object[] { groupId };
2469    
2470                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2471                                    this);
2472    
2473                    if (count == null) {
2474                            StringBundler query = new StringBundler(2);
2475    
2476                            query.append(_SQL_COUNT_MDRRULEGROUP_WHERE);
2477    
2478                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2479    
2480                            String sql = query.toString();
2481    
2482                            Session session = null;
2483    
2484                            try {
2485                                    session = openSession();
2486    
2487                                    Query q = session.createQuery(sql);
2488    
2489                                    QueryPos qPos = QueryPos.getInstance(q);
2490    
2491                                    qPos.add(groupId);
2492    
2493                                    count = (Long)q.uniqueResult();
2494    
2495                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2496                            }
2497                            catch (Exception e) {
2498                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2499    
2500                                    throw processException(e);
2501                            }
2502                            finally {
2503                                    closeSession(session);
2504                            }
2505                    }
2506    
2507                    return count.intValue();
2508            }
2509    
2510            /**
2511             * Returns the number of m d r rule groups where groupId = any &#63;.
2512             *
2513             * @param groupIds the group IDs
2514             * @return the number of matching m d r rule groups
2515             */
2516            @Override
2517            public int countByGroupId(long[] groupIds) {
2518                    if (groupIds == null) {
2519                            groupIds = new long[0];
2520                    }
2521                    else {
2522                            groupIds = ArrayUtil.unique(groupIds);
2523                    }
2524    
2525                    Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
2526    
2527                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2528                                    finderArgs, this);
2529    
2530                    if (count == null) {
2531                            StringBundler query = new StringBundler();
2532    
2533                            query.append(_SQL_COUNT_MDRRULEGROUP_WHERE);
2534    
2535                            if (groupIds.length > 0) {
2536                                    query.append(StringPool.OPEN_PARENTHESIS);
2537    
2538                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2539    
2540                                    query.append(StringUtil.merge(groupIds));
2541    
2542                                    query.append(StringPool.CLOSE_PARENTHESIS);
2543    
2544                                    query.append(StringPool.CLOSE_PARENTHESIS);
2545                            }
2546    
2547                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
2548                                                    1)), query.index() - 1);
2549    
2550                            String sql = query.toString();
2551    
2552                            Session session = null;
2553    
2554                            try {
2555                                    session = openSession();
2556    
2557                                    Query q = session.createQuery(sql);
2558    
2559                                    count = (Long)q.uniqueResult();
2560    
2561                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2562                                            finderArgs, count);
2563                            }
2564                            catch (Exception e) {
2565                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2566                                            finderArgs);
2567    
2568                                    throw processException(e);
2569                            }
2570                            finally {
2571                                    closeSession(session);
2572                            }
2573                    }
2574    
2575                    return count.intValue();
2576            }
2577    
2578            /**
2579             * Returns the number of m d r rule groups that the user has permission to view where groupId = &#63;.
2580             *
2581             * @param groupId the group ID
2582             * @return the number of matching m d r rule groups that the user has permission to view
2583             */
2584            @Override
2585            public int filterCountByGroupId(long groupId) {
2586                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2587                            return countByGroupId(groupId);
2588                    }
2589    
2590                    StringBundler query = new StringBundler(2);
2591    
2592                    query.append(_FILTER_SQL_COUNT_MDRRULEGROUP_WHERE);
2593    
2594                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2595    
2596                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2597                                    MDRRuleGroup.class.getName(),
2598                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2599    
2600                    Session session = null;
2601    
2602                    try {
2603                            session = openSession();
2604    
2605                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2606    
2607                            q.addScalar(COUNT_COLUMN_NAME,
2608                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2609    
2610                            QueryPos qPos = QueryPos.getInstance(q);
2611    
2612                            qPos.add(groupId);
2613    
2614                            Long count = (Long)q.uniqueResult();
2615    
2616                            return count.intValue();
2617                    }
2618                    catch (Exception e) {
2619                            throw processException(e);
2620                    }
2621                    finally {
2622                            closeSession(session);
2623                    }
2624            }
2625    
2626            /**
2627             * Returns the number of m d r rule groups that the user has permission to view where groupId = any &#63;.
2628             *
2629             * @param groupIds the group IDs
2630             * @return the number of matching m d r rule groups that the user has permission to view
2631             */
2632            @Override
2633            public int filterCountByGroupId(long[] groupIds) {
2634                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2635                            return countByGroupId(groupIds);
2636                    }
2637    
2638                    if (groupIds == null) {
2639                            groupIds = new long[0];
2640                    }
2641                    else {
2642                            groupIds = ArrayUtil.unique(groupIds);
2643                    }
2644    
2645                    StringBundler query = new StringBundler();
2646    
2647                    query.append(_FILTER_SQL_COUNT_MDRRULEGROUP_WHERE);
2648    
2649                    if (groupIds.length > 0) {
2650                            query.append(StringPool.OPEN_PARENTHESIS);
2651    
2652                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2653    
2654                            query.append(StringUtil.merge(groupIds));
2655    
2656                            query.append(StringPool.CLOSE_PARENTHESIS);
2657    
2658                            query.append(StringPool.CLOSE_PARENTHESIS);
2659                    }
2660    
2661                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
2662                            query.index() - 1);
2663    
2664                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2665                                    MDRRuleGroup.class.getName(),
2666                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2667    
2668                    Session session = null;
2669    
2670                    try {
2671                            session = openSession();
2672    
2673                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2674    
2675                            q.addScalar(COUNT_COLUMN_NAME,
2676                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2677    
2678                            Long count = (Long)q.uniqueResult();
2679    
2680                            return count.intValue();
2681                    }
2682                    catch (Exception e) {
2683                            throw processException(e);
2684                    }
2685                    finally {
2686                            closeSession(session);
2687                    }
2688            }
2689    
2690            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mdrRuleGroup.groupId = ?";
2691            private static final String _FINDER_COLUMN_GROUPID_GROUPID_7 = "mdrRuleGroup.groupId IN (";
2692    
2693            public MDRRuleGroupPersistenceImpl() {
2694                    setModelClass(MDRRuleGroup.class);
2695            }
2696    
2697            /**
2698             * Caches the m d r rule group in the entity cache if it is enabled.
2699             *
2700             * @param mdrRuleGroup the m d r rule group
2701             */
2702            @Override
2703            public void cacheResult(MDRRuleGroup mdrRuleGroup) {
2704                    EntityCacheUtil.putResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
2705                            MDRRuleGroupImpl.class, mdrRuleGroup.getPrimaryKey(), mdrRuleGroup);
2706    
2707                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2708                            new Object[] { mdrRuleGroup.getUuid(), mdrRuleGroup.getGroupId() },
2709                            mdrRuleGroup);
2710    
2711                    mdrRuleGroup.resetOriginalValues();
2712            }
2713    
2714            /**
2715             * Caches the m d r rule groups in the entity cache if it is enabled.
2716             *
2717             * @param mdrRuleGroups the m d r rule groups
2718             */
2719            @Override
2720            public void cacheResult(List<MDRRuleGroup> mdrRuleGroups) {
2721                    for (MDRRuleGroup mdrRuleGroup : mdrRuleGroups) {
2722                            if (EntityCacheUtil.getResult(
2723                                                    MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
2724                                                    MDRRuleGroupImpl.class, mdrRuleGroup.getPrimaryKey()) == null) {
2725                                    cacheResult(mdrRuleGroup);
2726                            }
2727                            else {
2728                                    mdrRuleGroup.resetOriginalValues();
2729                            }
2730                    }
2731            }
2732    
2733            /**
2734             * Clears the cache for all m d r rule groups.
2735             *
2736             * <p>
2737             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2738             * </p>
2739             */
2740            @Override
2741            public void clearCache() {
2742                    EntityCacheUtil.clearCache(MDRRuleGroupImpl.class);
2743    
2744                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2745                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2746                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2747            }
2748    
2749            /**
2750             * Clears the cache for the m d r rule group.
2751             *
2752             * <p>
2753             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2754             * </p>
2755             */
2756            @Override
2757            public void clearCache(MDRRuleGroup mdrRuleGroup) {
2758                    EntityCacheUtil.removeResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
2759                            MDRRuleGroupImpl.class, mdrRuleGroup.getPrimaryKey());
2760    
2761                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2762                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2763    
2764                    clearUniqueFindersCache(mdrRuleGroup);
2765            }
2766    
2767            @Override
2768            public void clearCache(List<MDRRuleGroup> mdrRuleGroups) {
2769                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2770                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2771    
2772                    for (MDRRuleGroup mdrRuleGroup : mdrRuleGroups) {
2773                            EntityCacheUtil.removeResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
2774                                    MDRRuleGroupImpl.class, mdrRuleGroup.getPrimaryKey());
2775    
2776                            clearUniqueFindersCache(mdrRuleGroup);
2777                    }
2778            }
2779    
2780            protected void cacheUniqueFindersCache(MDRRuleGroup mdrRuleGroup) {
2781                    if (mdrRuleGroup.isNew()) {
2782                            Object[] args = new Object[] {
2783                                            mdrRuleGroup.getUuid(), mdrRuleGroup.getGroupId()
2784                                    };
2785    
2786                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2787                                    Long.valueOf(1));
2788                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2789                                    mdrRuleGroup);
2790                    }
2791                    else {
2792                            MDRRuleGroupModelImpl mdrRuleGroupModelImpl = (MDRRuleGroupModelImpl)mdrRuleGroup;
2793    
2794                            if ((mdrRuleGroupModelImpl.getColumnBitmask() &
2795                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2796                                    Object[] args = new Object[] {
2797                                                    mdrRuleGroup.getUuid(), mdrRuleGroup.getGroupId()
2798                                            };
2799    
2800                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2801                                            Long.valueOf(1));
2802                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2803                                            mdrRuleGroup);
2804                            }
2805                    }
2806            }
2807    
2808            protected void clearUniqueFindersCache(MDRRuleGroup mdrRuleGroup) {
2809                    MDRRuleGroupModelImpl mdrRuleGroupModelImpl = (MDRRuleGroupModelImpl)mdrRuleGroup;
2810    
2811                    Object[] args = new Object[] {
2812                                    mdrRuleGroup.getUuid(), mdrRuleGroup.getGroupId()
2813                            };
2814    
2815                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2816                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2817    
2818                    if ((mdrRuleGroupModelImpl.getColumnBitmask() &
2819                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2820                            args = new Object[] {
2821                                            mdrRuleGroupModelImpl.getOriginalUuid(),
2822                                            mdrRuleGroupModelImpl.getOriginalGroupId()
2823                                    };
2824    
2825                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2826                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2827                    }
2828            }
2829    
2830            /**
2831             * Creates a new m d r rule group with the primary key. Does not add the m d r rule group to the database.
2832             *
2833             * @param ruleGroupId the primary key for the new m d r rule group
2834             * @return the new m d r rule group
2835             */
2836            @Override
2837            public MDRRuleGroup create(long ruleGroupId) {
2838                    MDRRuleGroup mdrRuleGroup = new MDRRuleGroupImpl();
2839    
2840                    mdrRuleGroup.setNew(true);
2841                    mdrRuleGroup.setPrimaryKey(ruleGroupId);
2842    
2843                    String uuid = PortalUUIDUtil.generate();
2844    
2845                    mdrRuleGroup.setUuid(uuid);
2846    
2847                    return mdrRuleGroup;
2848            }
2849    
2850            /**
2851             * Removes the m d r rule group with the primary key from the database. Also notifies the appropriate model listeners.
2852             *
2853             * @param ruleGroupId the primary key of the m d r rule group
2854             * @return the m d r rule group that was removed
2855             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
2856             */
2857            @Override
2858            public MDRRuleGroup remove(long ruleGroupId)
2859                    throws NoSuchRuleGroupException {
2860                    return remove((Serializable)ruleGroupId);
2861            }
2862    
2863            /**
2864             * Removes the m d r rule group with the primary key from the database. Also notifies the appropriate model listeners.
2865             *
2866             * @param primaryKey the primary key of the m d r rule group
2867             * @return the m d r rule group that was removed
2868             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
2869             */
2870            @Override
2871            public MDRRuleGroup remove(Serializable primaryKey)
2872                    throws NoSuchRuleGroupException {
2873                    Session session = null;
2874    
2875                    try {
2876                            session = openSession();
2877    
2878                            MDRRuleGroup mdrRuleGroup = (MDRRuleGroup)session.get(MDRRuleGroupImpl.class,
2879                                            primaryKey);
2880    
2881                            if (mdrRuleGroup == null) {
2882                                    if (_log.isWarnEnabled()) {
2883                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2884                                    }
2885    
2886                                    throw new NoSuchRuleGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2887                                            primaryKey);
2888                            }
2889    
2890                            return remove(mdrRuleGroup);
2891                    }
2892                    catch (NoSuchRuleGroupException nsee) {
2893                            throw nsee;
2894                    }
2895                    catch (Exception e) {
2896                            throw processException(e);
2897                    }
2898                    finally {
2899                            closeSession(session);
2900                    }
2901            }
2902    
2903            @Override
2904            protected MDRRuleGroup removeImpl(MDRRuleGroup mdrRuleGroup) {
2905                    mdrRuleGroup = toUnwrappedModel(mdrRuleGroup);
2906    
2907                    Session session = null;
2908    
2909                    try {
2910                            session = openSession();
2911    
2912                            if (!session.contains(mdrRuleGroup)) {
2913                                    mdrRuleGroup = (MDRRuleGroup)session.get(MDRRuleGroupImpl.class,
2914                                                    mdrRuleGroup.getPrimaryKeyObj());
2915                            }
2916    
2917                            if (mdrRuleGroup != null) {
2918                                    session.delete(mdrRuleGroup);
2919                            }
2920                    }
2921                    catch (Exception e) {
2922                            throw processException(e);
2923                    }
2924                    finally {
2925                            closeSession(session);
2926                    }
2927    
2928                    if (mdrRuleGroup != null) {
2929                            clearCache(mdrRuleGroup);
2930                    }
2931    
2932                    return mdrRuleGroup;
2933            }
2934    
2935            @Override
2936            public MDRRuleGroup updateImpl(MDRRuleGroup mdrRuleGroup) {
2937                    mdrRuleGroup = toUnwrappedModel(mdrRuleGroup);
2938    
2939                    boolean isNew = mdrRuleGroup.isNew();
2940    
2941                    MDRRuleGroupModelImpl mdrRuleGroupModelImpl = (MDRRuleGroupModelImpl)mdrRuleGroup;
2942    
2943                    if (Validator.isNull(mdrRuleGroup.getUuid())) {
2944                            String uuid = PortalUUIDUtil.generate();
2945    
2946                            mdrRuleGroup.setUuid(uuid);
2947                    }
2948    
2949                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
2950    
2951                    Date now = new Date();
2952    
2953                    if (isNew && (mdrRuleGroup.getCreateDate() == null)) {
2954                            if (serviceContext == null) {
2955                                    mdrRuleGroup.setCreateDate(now);
2956                            }
2957                            else {
2958                                    mdrRuleGroup.setCreateDate(serviceContext.getCreateDate(now));
2959                            }
2960                    }
2961    
2962                    if (!mdrRuleGroupModelImpl.hasSetModifiedDate()) {
2963                            if (serviceContext == null) {
2964                                    mdrRuleGroup.setModifiedDate(now);
2965                            }
2966                            else {
2967                                    mdrRuleGroup.setModifiedDate(serviceContext.getModifiedDate(now));
2968                            }
2969                    }
2970    
2971                    Session session = null;
2972    
2973                    try {
2974                            session = openSession();
2975    
2976                            if (mdrRuleGroup.isNew()) {
2977                                    session.save(mdrRuleGroup);
2978    
2979                                    mdrRuleGroup.setNew(false);
2980                            }
2981                            else {
2982                                    session.merge(mdrRuleGroup);
2983                            }
2984                    }
2985                    catch (Exception e) {
2986                            throw processException(e);
2987                    }
2988                    finally {
2989                            closeSession(session);
2990                    }
2991    
2992                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2993    
2994                    if (isNew || !MDRRuleGroupModelImpl.COLUMN_BITMASK_ENABLED) {
2995                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2996                    }
2997    
2998                    else {
2999                            if ((mdrRuleGroupModelImpl.getColumnBitmask() &
3000                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3001                                    Object[] args = new Object[] {
3002                                                    mdrRuleGroupModelImpl.getOriginalUuid()
3003                                            };
3004    
3005                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3006                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3007                                            args);
3008    
3009                                    args = new Object[] { mdrRuleGroupModelImpl.getUuid() };
3010    
3011                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3012                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3013                                            args);
3014                            }
3015    
3016                            if ((mdrRuleGroupModelImpl.getColumnBitmask() &
3017                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3018                                    Object[] args = new Object[] {
3019                                                    mdrRuleGroupModelImpl.getOriginalUuid(),
3020                                                    mdrRuleGroupModelImpl.getOriginalCompanyId()
3021                                            };
3022    
3023                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3024                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3025                                            args);
3026    
3027                                    args = new Object[] {
3028                                                    mdrRuleGroupModelImpl.getUuid(),
3029                                                    mdrRuleGroupModelImpl.getCompanyId()
3030                                            };
3031    
3032                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3033                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3034                                            args);
3035                            }
3036    
3037                            if ((mdrRuleGroupModelImpl.getColumnBitmask() &
3038                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3039                                    Object[] args = new Object[] {
3040                                                    mdrRuleGroupModelImpl.getOriginalGroupId()
3041                                            };
3042    
3043                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3044                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3045                                            args);
3046    
3047                                    args = new Object[] { mdrRuleGroupModelImpl.getGroupId() };
3048    
3049                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3050                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3051                                            args);
3052                            }
3053                    }
3054    
3055                    EntityCacheUtil.putResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
3056                            MDRRuleGroupImpl.class, mdrRuleGroup.getPrimaryKey(), mdrRuleGroup,
3057                            false);
3058    
3059                    clearUniqueFindersCache(mdrRuleGroup);
3060                    cacheUniqueFindersCache(mdrRuleGroup);
3061    
3062                    mdrRuleGroup.resetOriginalValues();
3063    
3064                    return mdrRuleGroup;
3065            }
3066    
3067            protected MDRRuleGroup toUnwrappedModel(MDRRuleGroup mdrRuleGroup) {
3068                    if (mdrRuleGroup instanceof MDRRuleGroupImpl) {
3069                            return mdrRuleGroup;
3070                    }
3071    
3072                    MDRRuleGroupImpl mdrRuleGroupImpl = new MDRRuleGroupImpl();
3073    
3074                    mdrRuleGroupImpl.setNew(mdrRuleGroup.isNew());
3075                    mdrRuleGroupImpl.setPrimaryKey(mdrRuleGroup.getPrimaryKey());
3076    
3077                    mdrRuleGroupImpl.setUuid(mdrRuleGroup.getUuid());
3078                    mdrRuleGroupImpl.setRuleGroupId(mdrRuleGroup.getRuleGroupId());
3079                    mdrRuleGroupImpl.setGroupId(mdrRuleGroup.getGroupId());
3080                    mdrRuleGroupImpl.setCompanyId(mdrRuleGroup.getCompanyId());
3081                    mdrRuleGroupImpl.setUserId(mdrRuleGroup.getUserId());
3082                    mdrRuleGroupImpl.setUserName(mdrRuleGroup.getUserName());
3083                    mdrRuleGroupImpl.setCreateDate(mdrRuleGroup.getCreateDate());
3084                    mdrRuleGroupImpl.setModifiedDate(mdrRuleGroup.getModifiedDate());
3085                    mdrRuleGroupImpl.setName(mdrRuleGroup.getName());
3086                    mdrRuleGroupImpl.setDescription(mdrRuleGroup.getDescription());
3087    
3088                    return mdrRuleGroupImpl;
3089            }
3090    
3091            /**
3092             * Returns the m d r rule group with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
3093             *
3094             * @param primaryKey the primary key of the m d r rule group
3095             * @return the m d r rule group
3096             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
3097             */
3098            @Override
3099            public MDRRuleGroup findByPrimaryKey(Serializable primaryKey)
3100                    throws NoSuchRuleGroupException {
3101                    MDRRuleGroup mdrRuleGroup = fetchByPrimaryKey(primaryKey);
3102    
3103                    if (mdrRuleGroup == null) {
3104                            if (_log.isWarnEnabled()) {
3105                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3106                            }
3107    
3108                            throw new NoSuchRuleGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3109                                    primaryKey);
3110                    }
3111    
3112                    return mdrRuleGroup;
3113            }
3114    
3115            /**
3116             * Returns the m d r rule group with the primary key or throws a {@link NoSuchRuleGroupException} if it could not be found.
3117             *
3118             * @param ruleGroupId the primary key of the m d r rule group
3119             * @return the m d r rule group
3120             * @throws NoSuchRuleGroupException if a m d r rule group with the primary key could not be found
3121             */
3122            @Override
3123            public MDRRuleGroup findByPrimaryKey(long ruleGroupId)
3124                    throws NoSuchRuleGroupException {
3125                    return findByPrimaryKey((Serializable)ruleGroupId);
3126            }
3127    
3128            /**
3129             * Returns the m d r rule group with the primary key or returns <code>null</code> if it could not be found.
3130             *
3131             * @param primaryKey the primary key of the m d r rule group
3132             * @return the m d r rule group, or <code>null</code> if a m d r rule group with the primary key could not be found
3133             */
3134            @Override
3135            public MDRRuleGroup fetchByPrimaryKey(Serializable primaryKey) {
3136                    MDRRuleGroup mdrRuleGroup = (MDRRuleGroup)EntityCacheUtil.getResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
3137                                    MDRRuleGroupImpl.class, primaryKey);
3138    
3139                    if (mdrRuleGroup == _nullMDRRuleGroup) {
3140                            return null;
3141                    }
3142    
3143                    if (mdrRuleGroup == null) {
3144                            Session session = null;
3145    
3146                            try {
3147                                    session = openSession();
3148    
3149                                    mdrRuleGroup = (MDRRuleGroup)session.get(MDRRuleGroupImpl.class,
3150                                                    primaryKey);
3151    
3152                                    if (mdrRuleGroup != null) {
3153                                            cacheResult(mdrRuleGroup);
3154                                    }
3155                                    else {
3156                                            EntityCacheUtil.putResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
3157                                                    MDRRuleGroupImpl.class, primaryKey, _nullMDRRuleGroup);
3158                                    }
3159                            }
3160                            catch (Exception e) {
3161                                    EntityCacheUtil.removeResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
3162                                            MDRRuleGroupImpl.class, primaryKey);
3163    
3164                                    throw processException(e);
3165                            }
3166                            finally {
3167                                    closeSession(session);
3168                            }
3169                    }
3170    
3171                    return mdrRuleGroup;
3172            }
3173    
3174            /**
3175             * Returns the m d r rule group with the primary key or returns <code>null</code> if it could not be found.
3176             *
3177             * @param ruleGroupId the primary key of the m d r rule group
3178             * @return the m d r rule group, or <code>null</code> if a m d r rule group with the primary key could not be found
3179             */
3180            @Override
3181            public MDRRuleGroup fetchByPrimaryKey(long ruleGroupId) {
3182                    return fetchByPrimaryKey((Serializable)ruleGroupId);
3183            }
3184    
3185            @Override
3186            public Map<Serializable, MDRRuleGroup> fetchByPrimaryKeys(
3187                    Set<Serializable> primaryKeys) {
3188                    if (primaryKeys.isEmpty()) {
3189                            return Collections.emptyMap();
3190                    }
3191    
3192                    Map<Serializable, MDRRuleGroup> map = new HashMap<Serializable, MDRRuleGroup>();
3193    
3194                    if (primaryKeys.size() == 1) {
3195                            Iterator<Serializable> iterator = primaryKeys.iterator();
3196    
3197                            Serializable primaryKey = iterator.next();
3198    
3199                            MDRRuleGroup mdrRuleGroup = fetchByPrimaryKey(primaryKey);
3200    
3201                            if (mdrRuleGroup != null) {
3202                                    map.put(primaryKey, mdrRuleGroup);
3203                            }
3204    
3205                            return map;
3206                    }
3207    
3208                    Set<Serializable> uncachedPrimaryKeys = null;
3209    
3210                    for (Serializable primaryKey : primaryKeys) {
3211                            MDRRuleGroup mdrRuleGroup = (MDRRuleGroup)EntityCacheUtil.getResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
3212                                            MDRRuleGroupImpl.class, primaryKey);
3213    
3214                            if (mdrRuleGroup == null) {
3215                                    if (uncachedPrimaryKeys == null) {
3216                                            uncachedPrimaryKeys = new HashSet<Serializable>();
3217                                    }
3218    
3219                                    uncachedPrimaryKeys.add(primaryKey);
3220                            }
3221                            else {
3222                                    map.put(primaryKey, mdrRuleGroup);
3223                            }
3224                    }
3225    
3226                    if (uncachedPrimaryKeys == null) {
3227                            return map;
3228                    }
3229    
3230                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3231                                    1);
3232    
3233                    query.append(_SQL_SELECT_MDRRULEGROUP_WHERE_PKS_IN);
3234    
3235                    for (Serializable primaryKey : uncachedPrimaryKeys) {
3236                            query.append(String.valueOf(primaryKey));
3237    
3238                            query.append(StringPool.COMMA);
3239                    }
3240    
3241                    query.setIndex(query.index() - 1);
3242    
3243                    query.append(StringPool.CLOSE_PARENTHESIS);
3244    
3245                    String sql = query.toString();
3246    
3247                    Session session = null;
3248    
3249                    try {
3250                            session = openSession();
3251    
3252                            Query q = session.createQuery(sql);
3253    
3254                            for (MDRRuleGroup mdrRuleGroup : (List<MDRRuleGroup>)q.list()) {
3255                                    map.put(mdrRuleGroup.getPrimaryKeyObj(), mdrRuleGroup);
3256    
3257                                    cacheResult(mdrRuleGroup);
3258    
3259                                    uncachedPrimaryKeys.remove(mdrRuleGroup.getPrimaryKeyObj());
3260                            }
3261    
3262                            for (Serializable primaryKey : uncachedPrimaryKeys) {
3263                                    EntityCacheUtil.putResult(MDRRuleGroupModelImpl.ENTITY_CACHE_ENABLED,
3264                                            MDRRuleGroupImpl.class, primaryKey, _nullMDRRuleGroup);
3265                            }
3266                    }
3267                    catch (Exception e) {
3268                            throw processException(e);
3269                    }
3270                    finally {
3271                            closeSession(session);
3272                    }
3273    
3274                    return map;
3275            }
3276    
3277            /**
3278             * Returns all the m d r rule groups.
3279             *
3280             * @return the m d r rule groups
3281             */
3282            @Override
3283            public List<MDRRuleGroup> findAll() {
3284                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3285            }
3286    
3287            /**
3288             * Returns a range of all the m d r rule groups.
3289             *
3290             * <p>
3291             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3292             * </p>
3293             *
3294             * @param start the lower bound of the range of m d r rule groups
3295             * @param end the upper bound of the range of m d r rule groups (not inclusive)
3296             * @return the range of m d r rule groups
3297             */
3298            @Override
3299            public List<MDRRuleGroup> findAll(int start, int end) {
3300                    return findAll(start, end, null);
3301            }
3302    
3303            /**
3304             * Returns an ordered range of all the m d r rule groups.
3305             *
3306             * <p>
3307             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link MDRRuleGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3308             * </p>
3309             *
3310             * @param start the lower bound of the range of m d r rule groups
3311             * @param end the upper bound of the range of m d r rule groups (not inclusive)
3312             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3313             * @return the ordered range of m d r rule groups
3314             */
3315            @Override
3316            public List<MDRRuleGroup> findAll(int start, int end,
3317                    OrderByComparator<MDRRuleGroup> orderByComparator) {
3318                    boolean pagination = true;
3319                    FinderPath finderPath = null;
3320                    Object[] finderArgs = null;
3321    
3322                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3323                                    (orderByComparator == null)) {
3324                            pagination = false;
3325                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3326                            finderArgs = FINDER_ARGS_EMPTY;
3327                    }
3328                    else {
3329                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3330                            finderArgs = new Object[] { start, end, orderByComparator };
3331                    }
3332    
3333                    List<MDRRuleGroup> list = (List<MDRRuleGroup>)FinderCacheUtil.getResult(finderPath,
3334                                    finderArgs, this);
3335    
3336                    if (list == null) {
3337                            StringBundler query = null;
3338                            String sql = null;
3339    
3340                            if (orderByComparator != null) {
3341                                    query = new StringBundler(2 +
3342                                                    (orderByComparator.getOrderByFields().length * 3));
3343    
3344                                    query.append(_SQL_SELECT_MDRRULEGROUP);
3345    
3346                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3347                                            orderByComparator);
3348    
3349                                    sql = query.toString();
3350                            }
3351                            else {
3352                                    sql = _SQL_SELECT_MDRRULEGROUP;
3353    
3354                                    if (pagination) {
3355                                            sql = sql.concat(MDRRuleGroupModelImpl.ORDER_BY_JPQL);
3356                                    }
3357                            }
3358    
3359                            Session session = null;
3360    
3361                            try {
3362                                    session = openSession();
3363    
3364                                    Query q = session.createQuery(sql);
3365    
3366                                    if (!pagination) {
3367                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
3368                                                            start, end, false);
3369    
3370                                            Collections.sort(list);
3371    
3372                                            list = Collections.unmodifiableList(list);
3373                                    }
3374                                    else {
3375                                            list = (List<MDRRuleGroup>)QueryUtil.list(q, getDialect(),
3376                                                            start, end);
3377                                    }
3378    
3379                                    cacheResult(list);
3380    
3381                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3382                            }
3383                            catch (Exception e) {
3384                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3385    
3386                                    throw processException(e);
3387                            }
3388                            finally {
3389                                    closeSession(session);
3390                            }
3391                    }
3392    
3393                    return list;
3394            }
3395    
3396            /**
3397             * Removes all the m d r rule groups from the database.
3398             *
3399             */
3400            @Override
3401            public void removeAll() {
3402                    for (MDRRuleGroup mdrRuleGroup : findAll()) {
3403                            remove(mdrRuleGroup);
3404                    }
3405            }
3406    
3407            /**
3408             * Returns the number of m d r rule groups.
3409             *
3410             * @return the number of m d r rule groups
3411             */
3412            @Override
3413            public int countAll() {
3414                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3415                                    FINDER_ARGS_EMPTY, this);
3416    
3417                    if (count == null) {
3418                            Session session = null;
3419    
3420                            try {
3421                                    session = openSession();
3422    
3423                                    Query q = session.createQuery(_SQL_COUNT_MDRRULEGROUP);
3424    
3425                                    count = (Long)q.uniqueResult();
3426    
3427                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3428                                            FINDER_ARGS_EMPTY, count);
3429                            }
3430                            catch (Exception e) {
3431                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3432                                            FINDER_ARGS_EMPTY);
3433    
3434                                    throw processException(e);
3435                            }
3436                            finally {
3437                                    closeSession(session);
3438                            }
3439                    }
3440    
3441                    return count.intValue();
3442            }
3443    
3444            @Override
3445            protected Set<String> getBadColumnNames() {
3446                    return _badColumnNames;
3447            }
3448    
3449            /**
3450             * Initializes the m d r rule group persistence.
3451             */
3452            public void afterPropertiesSet() {
3453            }
3454    
3455            public void destroy() {
3456                    EntityCacheUtil.removeCache(MDRRuleGroupImpl.class.getName());
3457                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3458                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3459                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3460            }
3461    
3462            private static final String _SQL_SELECT_MDRRULEGROUP = "SELECT mdrRuleGroup FROM MDRRuleGroup mdrRuleGroup";
3463            private static final String _SQL_SELECT_MDRRULEGROUP_WHERE_PKS_IN = "SELECT mdrRuleGroup FROM MDRRuleGroup mdrRuleGroup WHERE ruleGroupId IN (";
3464            private static final String _SQL_SELECT_MDRRULEGROUP_WHERE = "SELECT mdrRuleGroup FROM MDRRuleGroup mdrRuleGroup WHERE ";
3465            private static final String _SQL_COUNT_MDRRULEGROUP = "SELECT COUNT(mdrRuleGroup) FROM MDRRuleGroup mdrRuleGroup";
3466            private static final String _SQL_COUNT_MDRRULEGROUP_WHERE = "SELECT COUNT(mdrRuleGroup) FROM MDRRuleGroup mdrRuleGroup WHERE ";
3467            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mdrRuleGroup.ruleGroupId";
3468            private static final String _FILTER_SQL_SELECT_MDRRULEGROUP_WHERE = "SELECT DISTINCT {mdrRuleGroup.*} FROM MDRRuleGroup mdrRuleGroup WHERE ";
3469            private static final String _FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_1 =
3470                    "SELECT {MDRRuleGroup.*} FROM (SELECT DISTINCT mdrRuleGroup.ruleGroupId FROM MDRRuleGroup mdrRuleGroup WHERE ";
3471            private static final String _FILTER_SQL_SELECT_MDRRULEGROUP_NO_INLINE_DISTINCT_WHERE_2 =
3472                    ") TEMP_TABLE INNER JOIN MDRRuleGroup ON TEMP_TABLE.ruleGroupId = MDRRuleGroup.ruleGroupId";
3473            private static final String _FILTER_SQL_COUNT_MDRRULEGROUP_WHERE = "SELECT COUNT(DISTINCT mdrRuleGroup.ruleGroupId) AS COUNT_VALUE FROM MDRRuleGroup mdrRuleGroup WHERE ";
3474            private static final String _FILTER_ENTITY_ALIAS = "mdrRuleGroup";
3475            private static final String _FILTER_ENTITY_TABLE = "MDRRuleGroup";
3476            private static final String _ORDER_BY_ENTITY_ALIAS = "mdrRuleGroup.";
3477            private static final String _ORDER_BY_ENTITY_TABLE = "MDRRuleGroup.";
3478            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRRuleGroup exists with the primary key ";
3479            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRRuleGroup exists with the key {";
3480            private static final Log _log = LogFactoryUtil.getLog(MDRRuleGroupPersistenceImpl.class);
3481            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3482                                    "uuid"
3483                            });
3484            private static final MDRRuleGroup _nullMDRRuleGroup = new MDRRuleGroupImpl() {
3485                            @Override
3486                            public Object clone() {
3487                                    return this;
3488                            }
3489    
3490                            @Override
3491                            public CacheModel<MDRRuleGroup> toCacheModel() {
3492                                    return _nullMDRRuleGroupCacheModel;
3493                            }
3494                    };
3495    
3496            private static final CacheModel<MDRRuleGroup> _nullMDRRuleGroupCacheModel = new CacheModel<MDRRuleGroup>() {
3497                            @Override
3498                            public MDRRuleGroup toEntityModel() {
3499                                    return _nullMDRRuleGroup;
3500                            }
3501                    };
3502    }