001    /**
002     * Copyright (c) 2000-2013 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.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchSystemEventException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
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.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.SetUtil;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.UnmodifiableList;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.model.SystemEvent;
040    import com.liferay.portal.model.impl.SystemEventImpl;
041    import com.liferay.portal.model.impl.SystemEventModelImpl;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import java.io.Serializable;
045    
046    import java.util.ArrayList;
047    import java.util.Collections;
048    import java.util.List;
049    import java.util.Set;
050    
051    /**
052     * The persistence implementation for the system event service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see SystemEventPersistence
060     * @see SystemEventUtil
061     * @generated
062     */
063    public class SystemEventPersistenceImpl extends BasePersistenceImpl<SystemEvent>
064            implements SystemEventPersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link SystemEventUtil} to access the system event persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = SystemEventImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List1";
073            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List2";
075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
076                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
078            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
079                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
082                            SystemEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
085                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
087                            new String[] {
088                                    Long.class.getName(),
089                                    
090                            Integer.class.getName(), Integer.class.getName(),
091                                    OrderByComparator.class.getName()
092                            });
093            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
094                    new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
095                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
097                            new String[] { Long.class.getName() },
098                            SystemEventModelImpl.GROUPID_COLUMN_BITMASK |
099                            SystemEventModelImpl.CREATEDATE_COLUMN_BITMASK);
100            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
101                            SystemEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
103                            new String[] { Long.class.getName() });
104    
105            /**
106             * Returns all the system events where groupId = &#63;.
107             *
108             * @param groupId the group ID
109             * @return the matching system events
110             * @throws SystemException if a system exception occurred
111             */
112            @Override
113            public List<SystemEvent> findByGroupId(long groupId)
114                    throws SystemException {
115                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
116            }
117    
118            /**
119             * Returns a range of all the system events where groupId = &#63;.
120             *
121             * <p>
122             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. 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.
123             * </p>
124             *
125             * @param groupId the group ID
126             * @param start the lower bound of the range of system events
127             * @param end the upper bound of the range of system events (not inclusive)
128             * @return the range of matching system events
129             * @throws SystemException if a system exception occurred
130             */
131            @Override
132            public List<SystemEvent> findByGroupId(long groupId, int start, int end)
133                    throws SystemException {
134                    return findByGroupId(groupId, start, end, null);
135            }
136    
137            /**
138             * Returns an ordered range of all the system events where groupId = &#63;.
139             *
140             * <p>
141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
142             * </p>
143             *
144             * @param groupId the group ID
145             * @param start the lower bound of the range of system events
146             * @param end the upper bound of the range of system events (not inclusive)
147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
148             * @return the ordered range of matching system events
149             * @throws SystemException if a system exception occurred
150             */
151            @Override
152            public List<SystemEvent> findByGroupId(long groupId, int start, int end,
153                    OrderByComparator orderByComparator) throws SystemException {
154                    boolean pagination = true;
155                    FinderPath finderPath = null;
156                    Object[] finderArgs = null;
157    
158                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
159                                    (orderByComparator == null)) {
160                            pagination = false;
161                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
162                            finderArgs = new Object[] { groupId };
163                    }
164                    else {
165                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
166                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
167                    }
168    
169                    List<SystemEvent> list = (List<SystemEvent>)FinderCacheUtil.getResult(finderPath,
170                                    finderArgs, this);
171    
172                    if ((list != null) && !list.isEmpty()) {
173                            for (SystemEvent systemEvent : list) {
174                                    if ((groupId != systemEvent.getGroupId())) {
175                                            list = null;
176    
177                                            break;
178                                    }
179                            }
180                    }
181    
182                    if (list == null) {
183                            StringBundler query = null;
184    
185                            if (orderByComparator != null) {
186                                    query = new StringBundler(3 +
187                                                    (orderByComparator.getOrderByFields().length * 3));
188                            }
189                            else {
190                                    query = new StringBundler(3);
191                            }
192    
193                            query.append(_SQL_SELECT_SYSTEMEVENT_WHERE);
194    
195                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
196    
197                            if (orderByComparator != null) {
198                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
199                                            orderByComparator);
200                            }
201                            else
202                             if (pagination) {
203                                    query.append(SystemEventModelImpl.ORDER_BY_JPQL);
204                            }
205    
206                            String sql = query.toString();
207    
208                            Session session = null;
209    
210                            try {
211                                    session = openSession();
212    
213                                    Query q = session.createQuery(sql);
214    
215                                    QueryPos qPos = QueryPos.getInstance(q);
216    
217                                    qPos.add(groupId);
218    
219                                    if (!pagination) {
220                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
221                                                            start, end, false);
222    
223                                            Collections.sort(list);
224    
225                                            list = new UnmodifiableList<SystemEvent>(list);
226                                    }
227                                    else {
228                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
229                                                            start, end);
230                                    }
231    
232                                    cacheResult(list);
233    
234                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
235                            }
236                            catch (Exception e) {
237                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
238    
239                                    throw processException(e);
240                            }
241                            finally {
242                                    closeSession(session);
243                            }
244                    }
245    
246                    return list;
247            }
248    
249            /**
250             * Returns the first system event in the ordered set where groupId = &#63;.
251             *
252             * @param groupId the group ID
253             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
254             * @return the first matching system event
255             * @throws com.liferay.portal.NoSuchSystemEventException if a matching system event could not be found
256             * @throws SystemException if a system exception occurred
257             */
258            @Override
259            public SystemEvent findByGroupId_First(long groupId,
260                    OrderByComparator orderByComparator)
261                    throws NoSuchSystemEventException, SystemException {
262                    SystemEvent systemEvent = fetchByGroupId_First(groupId,
263                                    orderByComparator);
264    
265                    if (systemEvent != null) {
266                            return systemEvent;
267                    }
268    
269                    StringBundler msg = new StringBundler(4);
270    
271                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
272    
273                    msg.append("groupId=");
274                    msg.append(groupId);
275    
276                    msg.append(StringPool.CLOSE_CURLY_BRACE);
277    
278                    throw new NoSuchSystemEventException(msg.toString());
279            }
280    
281            /**
282             * Returns the first system event in the ordered set where groupId = &#63;.
283             *
284             * @param groupId the group ID
285             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
286             * @return the first matching system event, or <code>null</code> if a matching system event could not be found
287             * @throws SystemException if a system exception occurred
288             */
289            @Override
290            public SystemEvent fetchByGroupId_First(long groupId,
291                    OrderByComparator orderByComparator) throws SystemException {
292                    List<SystemEvent> list = findByGroupId(groupId, 0, 1, orderByComparator);
293    
294                    if (!list.isEmpty()) {
295                            return list.get(0);
296                    }
297    
298                    return null;
299            }
300    
301            /**
302             * Returns the last system event in the ordered set where groupId = &#63;.
303             *
304             * @param groupId the group ID
305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
306             * @return the last matching system event
307             * @throws com.liferay.portal.NoSuchSystemEventException if a matching system event could not be found
308             * @throws SystemException if a system exception occurred
309             */
310            @Override
311            public SystemEvent findByGroupId_Last(long groupId,
312                    OrderByComparator orderByComparator)
313                    throws NoSuchSystemEventException, SystemException {
314                    SystemEvent systemEvent = fetchByGroupId_Last(groupId, orderByComparator);
315    
316                    if (systemEvent != null) {
317                            return systemEvent;
318                    }
319    
320                    StringBundler msg = new StringBundler(4);
321    
322                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
323    
324                    msg.append("groupId=");
325                    msg.append(groupId);
326    
327                    msg.append(StringPool.CLOSE_CURLY_BRACE);
328    
329                    throw new NoSuchSystemEventException(msg.toString());
330            }
331    
332            /**
333             * Returns the last system event in the ordered set where groupId = &#63;.
334             *
335             * @param groupId the group ID
336             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
337             * @return the last matching system event, or <code>null</code> if a matching system event could not be found
338             * @throws SystemException if a system exception occurred
339             */
340            @Override
341            public SystemEvent fetchByGroupId_Last(long groupId,
342                    OrderByComparator orderByComparator) throws SystemException {
343                    int count = countByGroupId(groupId);
344    
345                    if (count == 0) {
346                            return null;
347                    }
348    
349                    List<SystemEvent> list = findByGroupId(groupId, count - 1, count,
350                                    orderByComparator);
351    
352                    if (!list.isEmpty()) {
353                            return list.get(0);
354                    }
355    
356                    return null;
357            }
358    
359            /**
360             * Returns the system events before and after the current system event in the ordered set where groupId = &#63;.
361             *
362             * @param systemEventId the primary key of the current system event
363             * @param groupId the group ID
364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
365             * @return the previous, current, and next system event
366             * @throws com.liferay.portal.NoSuchSystemEventException if a system event with the primary key could not be found
367             * @throws SystemException if a system exception occurred
368             */
369            @Override
370            public SystemEvent[] findByGroupId_PrevAndNext(long systemEventId,
371                    long groupId, OrderByComparator orderByComparator)
372                    throws NoSuchSystemEventException, SystemException {
373                    SystemEvent systemEvent = findByPrimaryKey(systemEventId);
374    
375                    Session session = null;
376    
377                    try {
378                            session = openSession();
379    
380                            SystemEvent[] array = new SystemEventImpl[3];
381    
382                            array[0] = getByGroupId_PrevAndNext(session, systemEvent, groupId,
383                                            orderByComparator, true);
384    
385                            array[1] = systemEvent;
386    
387                            array[2] = getByGroupId_PrevAndNext(session, systemEvent, groupId,
388                                            orderByComparator, false);
389    
390                            return array;
391                    }
392                    catch (Exception e) {
393                            throw processException(e);
394                    }
395                    finally {
396                            closeSession(session);
397                    }
398            }
399    
400            protected SystemEvent getByGroupId_PrevAndNext(Session session,
401                    SystemEvent systemEvent, long groupId,
402                    OrderByComparator orderByComparator, boolean previous) {
403                    StringBundler query = null;
404    
405                    if (orderByComparator != null) {
406                            query = new StringBundler(6 +
407                                            (orderByComparator.getOrderByFields().length * 6));
408                    }
409                    else {
410                            query = new StringBundler(3);
411                    }
412    
413                    query.append(_SQL_SELECT_SYSTEMEVENT_WHERE);
414    
415                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
416    
417                    if (orderByComparator != null) {
418                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
419    
420                            if (orderByConditionFields.length > 0) {
421                                    query.append(WHERE_AND);
422                            }
423    
424                            for (int i = 0; i < orderByConditionFields.length; i++) {
425                                    query.append(_ORDER_BY_ENTITY_ALIAS);
426                                    query.append(orderByConditionFields[i]);
427    
428                                    if ((i + 1) < orderByConditionFields.length) {
429                                            if (orderByComparator.isAscending() ^ previous) {
430                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
431                                            }
432                                            else {
433                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
434                                            }
435                                    }
436                                    else {
437                                            if (orderByComparator.isAscending() ^ previous) {
438                                                    query.append(WHERE_GREATER_THAN);
439                                            }
440                                            else {
441                                                    query.append(WHERE_LESSER_THAN);
442                                            }
443                                    }
444                            }
445    
446                            query.append(ORDER_BY_CLAUSE);
447    
448                            String[] orderByFields = orderByComparator.getOrderByFields();
449    
450                            for (int i = 0; i < orderByFields.length; i++) {
451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
452                                    query.append(orderByFields[i]);
453    
454                                    if ((i + 1) < orderByFields.length) {
455                                            if (orderByComparator.isAscending() ^ previous) {
456                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
457                                            }
458                                            else {
459                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
460                                            }
461                                    }
462                                    else {
463                                            if (orderByComparator.isAscending() ^ previous) {
464                                                    query.append(ORDER_BY_ASC);
465                                            }
466                                            else {
467                                                    query.append(ORDER_BY_DESC);
468                                            }
469                                    }
470                            }
471                    }
472                    else {
473                            query.append(SystemEventModelImpl.ORDER_BY_JPQL);
474                    }
475    
476                    String sql = query.toString();
477    
478                    Query q = session.createQuery(sql);
479    
480                    q.setFirstResult(0);
481                    q.setMaxResults(2);
482    
483                    QueryPos qPos = QueryPos.getInstance(q);
484    
485                    qPos.add(groupId);
486    
487                    if (orderByComparator != null) {
488                            Object[] values = orderByComparator.getOrderByConditionValues(systemEvent);
489    
490                            for (Object value : values) {
491                                    qPos.add(value);
492                            }
493                    }
494    
495                    List<SystemEvent> list = q.list();
496    
497                    if (list.size() == 2) {
498                            return list.get(1);
499                    }
500                    else {
501                            return null;
502                    }
503            }
504    
505            /**
506             * Removes all the system events where groupId = &#63; from the database.
507             *
508             * @param groupId the group ID
509             * @throws SystemException if a system exception occurred
510             */
511            @Override
512            public void removeByGroupId(long groupId) throws SystemException {
513                    for (SystemEvent systemEvent : findByGroupId(groupId,
514                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
515                            remove(systemEvent);
516                    }
517            }
518    
519            /**
520             * Returns the number of system events where groupId = &#63;.
521             *
522             * @param groupId the group ID
523             * @return the number of matching system events
524             * @throws SystemException if a system exception occurred
525             */
526            @Override
527            public int countByGroupId(long groupId) throws SystemException {
528                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
529    
530                    Object[] finderArgs = new Object[] { groupId };
531    
532                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
533                                    this);
534    
535                    if (count == null) {
536                            StringBundler query = new StringBundler(2);
537    
538                            query.append(_SQL_COUNT_SYSTEMEVENT_WHERE);
539    
540                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
541    
542                            String sql = query.toString();
543    
544                            Session session = null;
545    
546                            try {
547                                    session = openSession();
548    
549                                    Query q = session.createQuery(sql);
550    
551                                    QueryPos qPos = QueryPos.getInstance(q);
552    
553                                    qPos.add(groupId);
554    
555                                    count = (Long)q.uniqueResult();
556    
557                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
558                            }
559                            catch (Exception e) {
560                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
561    
562                                    throw processException(e);
563                            }
564                            finally {
565                                    closeSession(session);
566                            }
567                    }
568    
569                    return count.intValue();
570            }
571    
572            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "systemEvent.groupId = ?";
573            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
574                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
575                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_C",
576                            new String[] {
577                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
578                                    
579                            Integer.class.getName(), Integer.class.getName(),
580                                    OrderByComparator.class.getName()
581                            });
582            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
583                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
584                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
585                            new String[] {
586                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
587                            },
588                            SystemEventModelImpl.GROUPID_COLUMN_BITMASK |
589                            SystemEventModelImpl.CLASSNAMEID_COLUMN_BITMASK |
590                            SystemEventModelImpl.CLASSPK_COLUMN_BITMASK |
591                            SystemEventModelImpl.CREATEDATE_COLUMN_BITMASK);
592            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
593                            SystemEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
594                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
595                            new String[] {
596                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
597                            });
598    
599            /**
600             * Returns all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
601             *
602             * @param groupId the group ID
603             * @param classNameId the class name ID
604             * @param classPK the class p k
605             * @return the matching system events
606             * @throws SystemException if a system exception occurred
607             */
608            @Override
609            public List<SystemEvent> findByG_C_C(long groupId, long classNameId,
610                    long classPK) throws SystemException {
611                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
612                            QueryUtil.ALL_POS, null);
613            }
614    
615            /**
616             * Returns a range of all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
617             *
618             * <p>
619             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. 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.
620             * </p>
621             *
622             * @param groupId the group ID
623             * @param classNameId the class name ID
624             * @param classPK the class p k
625             * @param start the lower bound of the range of system events
626             * @param end the upper bound of the range of system events (not inclusive)
627             * @return the range of matching system events
628             * @throws SystemException if a system exception occurred
629             */
630            @Override
631            public List<SystemEvent> findByG_C_C(long groupId, long classNameId,
632                    long classPK, int start, int end) throws SystemException {
633                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
634            }
635    
636            /**
637             * Returns an ordered range of all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
638             *
639             * <p>
640             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. 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.
641             * </p>
642             *
643             * @param groupId the group ID
644             * @param classNameId the class name ID
645             * @param classPK the class p k
646             * @param start the lower bound of the range of system events
647             * @param end the upper bound of the range of system events (not inclusive)
648             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
649             * @return the ordered range of matching system events
650             * @throws SystemException if a system exception occurred
651             */
652            @Override
653            public List<SystemEvent> findByG_C_C(long groupId, long classNameId,
654                    long classPK, int start, int end, OrderByComparator orderByComparator)
655                    throws SystemException {
656                    boolean pagination = true;
657                    FinderPath finderPath = null;
658                    Object[] finderArgs = null;
659    
660                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
661                                    (orderByComparator == null)) {
662                            pagination = false;
663                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
664                            finderArgs = new Object[] { groupId, classNameId, classPK };
665                    }
666                    else {
667                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
668                            finderArgs = new Object[] {
669                                            groupId, classNameId, classPK,
670                                            
671                                            start, end, orderByComparator
672                                    };
673                    }
674    
675                    List<SystemEvent> list = (List<SystemEvent>)FinderCacheUtil.getResult(finderPath,
676                                    finderArgs, this);
677    
678                    if ((list != null) && !list.isEmpty()) {
679                            for (SystemEvent systemEvent : list) {
680                                    if ((groupId != systemEvent.getGroupId()) ||
681                                                    (classNameId != systemEvent.getClassNameId()) ||
682                                                    (classPK != systemEvent.getClassPK())) {
683                                            list = null;
684    
685                                            break;
686                                    }
687                            }
688                    }
689    
690                    if (list == null) {
691                            StringBundler query = null;
692    
693                            if (orderByComparator != null) {
694                                    query = new StringBundler(5 +
695                                                    (orderByComparator.getOrderByFields().length * 3));
696                            }
697                            else {
698                                    query = new StringBundler(5);
699                            }
700    
701                            query.append(_SQL_SELECT_SYSTEMEVENT_WHERE);
702    
703                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
704    
705                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
706    
707                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
708    
709                            if (orderByComparator != null) {
710                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
711                                            orderByComparator);
712                            }
713                            else
714                             if (pagination) {
715                                    query.append(SystemEventModelImpl.ORDER_BY_JPQL);
716                            }
717    
718                            String sql = query.toString();
719    
720                            Session session = null;
721    
722                            try {
723                                    session = openSession();
724    
725                                    Query q = session.createQuery(sql);
726    
727                                    QueryPos qPos = QueryPos.getInstance(q);
728    
729                                    qPos.add(groupId);
730    
731                                    qPos.add(classNameId);
732    
733                                    qPos.add(classPK);
734    
735                                    if (!pagination) {
736                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
737                                                            start, end, false);
738    
739                                            Collections.sort(list);
740    
741                                            list = new UnmodifiableList<SystemEvent>(list);
742                                    }
743                                    else {
744                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
745                                                            start, end);
746                                    }
747    
748                                    cacheResult(list);
749    
750                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
751                            }
752                            catch (Exception e) {
753                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
754    
755                                    throw processException(e);
756                            }
757                            finally {
758                                    closeSession(session);
759                            }
760                    }
761    
762                    return list;
763            }
764    
765            /**
766             * Returns the first system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
767             *
768             * @param groupId the group ID
769             * @param classNameId the class name ID
770             * @param classPK the class p k
771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
772             * @return the first matching system event
773             * @throws com.liferay.portal.NoSuchSystemEventException if a matching system event could not be found
774             * @throws SystemException if a system exception occurred
775             */
776            @Override
777            public SystemEvent findByG_C_C_First(long groupId, long classNameId,
778                    long classPK, OrderByComparator orderByComparator)
779                    throws NoSuchSystemEventException, SystemException {
780                    SystemEvent systemEvent = fetchByG_C_C_First(groupId, classNameId,
781                                    classPK, orderByComparator);
782    
783                    if (systemEvent != null) {
784                            return systemEvent;
785                    }
786    
787                    StringBundler msg = new StringBundler(8);
788    
789                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
790    
791                    msg.append("groupId=");
792                    msg.append(groupId);
793    
794                    msg.append(", classNameId=");
795                    msg.append(classNameId);
796    
797                    msg.append(", classPK=");
798                    msg.append(classPK);
799    
800                    msg.append(StringPool.CLOSE_CURLY_BRACE);
801    
802                    throw new NoSuchSystemEventException(msg.toString());
803            }
804    
805            /**
806             * Returns the first system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
807             *
808             * @param groupId the group ID
809             * @param classNameId the class name ID
810             * @param classPK the class p k
811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
812             * @return the first matching system event, or <code>null</code> if a matching system event could not be found
813             * @throws SystemException if a system exception occurred
814             */
815            @Override
816            public SystemEvent fetchByG_C_C_First(long groupId, long classNameId,
817                    long classPK, OrderByComparator orderByComparator)
818                    throws SystemException {
819                    List<SystemEvent> list = findByG_C_C(groupId, classNameId, classPK, 0,
820                                    1, orderByComparator);
821    
822                    if (!list.isEmpty()) {
823                            return list.get(0);
824                    }
825    
826                    return null;
827            }
828    
829            /**
830             * Returns the last system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
831             *
832             * @param groupId the group ID
833             * @param classNameId the class name ID
834             * @param classPK the class p k
835             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
836             * @return the last matching system event
837             * @throws com.liferay.portal.NoSuchSystemEventException if a matching system event could not be found
838             * @throws SystemException if a system exception occurred
839             */
840            @Override
841            public SystemEvent findByG_C_C_Last(long groupId, long classNameId,
842                    long classPK, OrderByComparator orderByComparator)
843                    throws NoSuchSystemEventException, SystemException {
844                    SystemEvent systemEvent = fetchByG_C_C_Last(groupId, classNameId,
845                                    classPK, orderByComparator);
846    
847                    if (systemEvent != null) {
848                            return systemEvent;
849                    }
850    
851                    StringBundler msg = new StringBundler(8);
852    
853                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
854    
855                    msg.append("groupId=");
856                    msg.append(groupId);
857    
858                    msg.append(", classNameId=");
859                    msg.append(classNameId);
860    
861                    msg.append(", classPK=");
862                    msg.append(classPK);
863    
864                    msg.append(StringPool.CLOSE_CURLY_BRACE);
865    
866                    throw new NoSuchSystemEventException(msg.toString());
867            }
868    
869            /**
870             * Returns the last system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
871             *
872             * @param groupId the group ID
873             * @param classNameId the class name ID
874             * @param classPK the class p k
875             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
876             * @return the last matching system event, or <code>null</code> if a matching system event could not be found
877             * @throws SystemException if a system exception occurred
878             */
879            @Override
880            public SystemEvent fetchByG_C_C_Last(long groupId, long classNameId,
881                    long classPK, OrderByComparator orderByComparator)
882                    throws SystemException {
883                    int count = countByG_C_C(groupId, classNameId, classPK);
884    
885                    if (count == 0) {
886                            return null;
887                    }
888    
889                    List<SystemEvent> list = findByG_C_C(groupId, classNameId, classPK,
890                                    count - 1, count, orderByComparator);
891    
892                    if (!list.isEmpty()) {
893                            return list.get(0);
894                    }
895    
896                    return null;
897            }
898    
899            /**
900             * Returns the system events before and after the current system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
901             *
902             * @param systemEventId the primary key of the current system event
903             * @param groupId the group ID
904             * @param classNameId the class name ID
905             * @param classPK the class p k
906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
907             * @return the previous, current, and next system event
908             * @throws com.liferay.portal.NoSuchSystemEventException if a system event with the primary key could not be found
909             * @throws SystemException if a system exception occurred
910             */
911            @Override
912            public SystemEvent[] findByG_C_C_PrevAndNext(long systemEventId,
913                    long groupId, long classNameId, long classPK,
914                    OrderByComparator orderByComparator)
915                    throws NoSuchSystemEventException, SystemException {
916                    SystemEvent systemEvent = findByPrimaryKey(systemEventId);
917    
918                    Session session = null;
919    
920                    try {
921                            session = openSession();
922    
923                            SystemEvent[] array = new SystemEventImpl[3];
924    
925                            array[0] = getByG_C_C_PrevAndNext(session, systemEvent, groupId,
926                                            classNameId, classPK, orderByComparator, true);
927    
928                            array[1] = systemEvent;
929    
930                            array[2] = getByG_C_C_PrevAndNext(session, systemEvent, groupId,
931                                            classNameId, classPK, orderByComparator, false);
932    
933                            return array;
934                    }
935                    catch (Exception e) {
936                            throw processException(e);
937                    }
938                    finally {
939                            closeSession(session);
940                    }
941            }
942    
943            protected SystemEvent getByG_C_C_PrevAndNext(Session session,
944                    SystemEvent systemEvent, long groupId, long classNameId, long classPK,
945                    OrderByComparator orderByComparator, boolean previous) {
946                    StringBundler query = null;
947    
948                    if (orderByComparator != null) {
949                            query = new StringBundler(6 +
950                                            (orderByComparator.getOrderByFields().length * 6));
951                    }
952                    else {
953                            query = new StringBundler(3);
954                    }
955    
956                    query.append(_SQL_SELECT_SYSTEMEVENT_WHERE);
957    
958                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
959    
960                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
961    
962                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
963    
964                    if (orderByComparator != null) {
965                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
966    
967                            if (orderByConditionFields.length > 0) {
968                                    query.append(WHERE_AND);
969                            }
970    
971                            for (int i = 0; i < orderByConditionFields.length; i++) {
972                                    query.append(_ORDER_BY_ENTITY_ALIAS);
973                                    query.append(orderByConditionFields[i]);
974    
975                                    if ((i + 1) < orderByConditionFields.length) {
976                                            if (orderByComparator.isAscending() ^ previous) {
977                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
978                                            }
979                                            else {
980                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
981                                            }
982                                    }
983                                    else {
984                                            if (orderByComparator.isAscending() ^ previous) {
985                                                    query.append(WHERE_GREATER_THAN);
986                                            }
987                                            else {
988                                                    query.append(WHERE_LESSER_THAN);
989                                            }
990                                    }
991                            }
992    
993                            query.append(ORDER_BY_CLAUSE);
994    
995                            String[] orderByFields = orderByComparator.getOrderByFields();
996    
997                            for (int i = 0; i < orderByFields.length; i++) {
998                                    query.append(_ORDER_BY_ENTITY_ALIAS);
999                                    query.append(orderByFields[i]);
1000    
1001                                    if ((i + 1) < orderByFields.length) {
1002                                            if (orderByComparator.isAscending() ^ previous) {
1003                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1004                                            }
1005                                            else {
1006                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1007                                            }
1008                                    }
1009                                    else {
1010                                            if (orderByComparator.isAscending() ^ previous) {
1011                                                    query.append(ORDER_BY_ASC);
1012                                            }
1013                                            else {
1014                                                    query.append(ORDER_BY_DESC);
1015                                            }
1016                                    }
1017                            }
1018                    }
1019                    else {
1020                            query.append(SystemEventModelImpl.ORDER_BY_JPQL);
1021                    }
1022    
1023                    String sql = query.toString();
1024    
1025                    Query q = session.createQuery(sql);
1026    
1027                    q.setFirstResult(0);
1028                    q.setMaxResults(2);
1029    
1030                    QueryPos qPos = QueryPos.getInstance(q);
1031    
1032                    qPos.add(groupId);
1033    
1034                    qPos.add(classNameId);
1035    
1036                    qPos.add(classPK);
1037    
1038                    if (orderByComparator != null) {
1039                            Object[] values = orderByComparator.getOrderByConditionValues(systemEvent);
1040    
1041                            for (Object value : values) {
1042                                    qPos.add(value);
1043                            }
1044                    }
1045    
1046                    List<SystemEvent> list = q.list();
1047    
1048                    if (list.size() == 2) {
1049                            return list.get(1);
1050                    }
1051                    else {
1052                            return null;
1053                    }
1054            }
1055    
1056            /**
1057             * Removes all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
1058             *
1059             * @param groupId the group ID
1060             * @param classNameId the class name ID
1061             * @param classPK the class p k
1062             * @throws SystemException if a system exception occurred
1063             */
1064            @Override
1065            public void removeByG_C_C(long groupId, long classNameId, long classPK)
1066                    throws SystemException {
1067                    for (SystemEvent systemEvent : findByG_C_C(groupId, classNameId,
1068                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1069                            remove(systemEvent);
1070                    }
1071            }
1072    
1073            /**
1074             * Returns the number of system events where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
1075             *
1076             * @param groupId the group ID
1077             * @param classNameId the class name ID
1078             * @param classPK the class p k
1079             * @return the number of matching system events
1080             * @throws SystemException if a system exception occurred
1081             */
1082            @Override
1083            public int countByG_C_C(long groupId, long classNameId, long classPK)
1084                    throws SystemException {
1085                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
1086    
1087                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
1088    
1089                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1090                                    this);
1091    
1092                    if (count == null) {
1093                            StringBundler query = new StringBundler(4);
1094    
1095                            query.append(_SQL_COUNT_SYSTEMEVENT_WHERE);
1096    
1097                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
1098    
1099                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
1100    
1101                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
1102    
1103                            String sql = query.toString();
1104    
1105                            Session session = null;
1106    
1107                            try {
1108                                    session = openSession();
1109    
1110                                    Query q = session.createQuery(sql);
1111    
1112                                    QueryPos qPos = QueryPos.getInstance(q);
1113    
1114                                    qPos.add(groupId);
1115    
1116                                    qPos.add(classNameId);
1117    
1118                                    qPos.add(classPK);
1119    
1120                                    count = (Long)q.uniqueResult();
1121    
1122                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1123                            }
1124                            catch (Exception e) {
1125                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1126    
1127                                    throw processException(e);
1128                            }
1129                            finally {
1130                                    closeSession(session);
1131                            }
1132                    }
1133    
1134                    return count.intValue();
1135            }
1136    
1137            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "systemEvent.groupId = ? AND ";
1138            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "systemEvent.classNameId = ? AND ";
1139            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "systemEvent.classPK = ?";
1140            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_T = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
1141                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
1142                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_C_T",
1143                            new String[] {
1144                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1145                                    Integer.class.getName(),
1146                                    
1147                            Integer.class.getName(), Integer.class.getName(),
1148                                    OrderByComparator.class.getName()
1149                            });
1150            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_T =
1151                    new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
1152                            SystemEventModelImpl.FINDER_CACHE_ENABLED, SystemEventImpl.class,
1153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C_T",
1154                            new String[] {
1155                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1156                                    Integer.class.getName()
1157                            },
1158                            SystemEventModelImpl.GROUPID_COLUMN_BITMASK |
1159                            SystemEventModelImpl.CLASSNAMEID_COLUMN_BITMASK |
1160                            SystemEventModelImpl.CLASSPK_COLUMN_BITMASK |
1161                            SystemEventModelImpl.TYPE_COLUMN_BITMASK |
1162                            SystemEventModelImpl.CREATEDATE_COLUMN_BITMASK);
1163            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_T = new FinderPath(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
1164                            SystemEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1165                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C_T",
1166                            new String[] {
1167                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
1168                                    Integer.class.getName()
1169                            });
1170    
1171            /**
1172             * Returns all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1173             *
1174             * @param groupId the group ID
1175             * @param classNameId the class name ID
1176             * @param classPK the class p k
1177             * @param type the type
1178             * @return the matching system events
1179             * @throws SystemException if a system exception occurred
1180             */
1181            @Override
1182            public List<SystemEvent> findByG_C_C_T(long groupId, long classNameId,
1183                    long classPK, int type) throws SystemException {
1184                    return findByG_C_C_T(groupId, classNameId, classPK, type,
1185                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1186            }
1187    
1188            /**
1189             * Returns a range of all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1190             *
1191             * <p>
1192             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. 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.
1193             * </p>
1194             *
1195             * @param groupId the group ID
1196             * @param classNameId the class name ID
1197             * @param classPK the class p k
1198             * @param type the type
1199             * @param start the lower bound of the range of system events
1200             * @param end the upper bound of the range of system events (not inclusive)
1201             * @return the range of matching system events
1202             * @throws SystemException if a system exception occurred
1203             */
1204            @Override
1205            public List<SystemEvent> findByG_C_C_T(long groupId, long classNameId,
1206                    long classPK, int type, int start, int end) throws SystemException {
1207                    return findByG_C_C_T(groupId, classNameId, classPK, type, start, end,
1208                            null);
1209            }
1210    
1211            /**
1212             * Returns an ordered range of all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1213             *
1214             * <p>
1215             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. 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.
1216             * </p>
1217             *
1218             * @param groupId the group ID
1219             * @param classNameId the class name ID
1220             * @param classPK the class p k
1221             * @param type the type
1222             * @param start the lower bound of the range of system events
1223             * @param end the upper bound of the range of system events (not inclusive)
1224             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1225             * @return the ordered range of matching system events
1226             * @throws SystemException if a system exception occurred
1227             */
1228            @Override
1229            public List<SystemEvent> findByG_C_C_T(long groupId, long classNameId,
1230                    long classPK, int type, int start, int end,
1231                    OrderByComparator orderByComparator) throws SystemException {
1232                    boolean pagination = true;
1233                    FinderPath finderPath = null;
1234                    Object[] finderArgs = null;
1235    
1236                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1237                                    (orderByComparator == null)) {
1238                            pagination = false;
1239                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_T;
1240                            finderArgs = new Object[] { groupId, classNameId, classPK, type };
1241                    }
1242                    else {
1243                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_T;
1244                            finderArgs = new Object[] {
1245                                            groupId, classNameId, classPK, type,
1246                                            
1247                                            start, end, orderByComparator
1248                                    };
1249                    }
1250    
1251                    List<SystemEvent> list = (List<SystemEvent>)FinderCacheUtil.getResult(finderPath,
1252                                    finderArgs, this);
1253    
1254                    if ((list != null) && !list.isEmpty()) {
1255                            for (SystemEvent systemEvent : list) {
1256                                    if ((groupId != systemEvent.getGroupId()) ||
1257                                                    (classNameId != systemEvent.getClassNameId()) ||
1258                                                    (classPK != systemEvent.getClassPK()) ||
1259                                                    (type != systemEvent.getType())) {
1260                                            list = null;
1261    
1262                                            break;
1263                                    }
1264                            }
1265                    }
1266    
1267                    if (list == null) {
1268                            StringBundler query = null;
1269    
1270                            if (orderByComparator != null) {
1271                                    query = new StringBundler(6 +
1272                                                    (orderByComparator.getOrderByFields().length * 3));
1273                            }
1274                            else {
1275                                    query = new StringBundler(6);
1276                            }
1277    
1278                            query.append(_SQL_SELECT_SYSTEMEVENT_WHERE);
1279    
1280                            query.append(_FINDER_COLUMN_G_C_C_T_GROUPID_2);
1281    
1282                            query.append(_FINDER_COLUMN_G_C_C_T_CLASSNAMEID_2);
1283    
1284                            query.append(_FINDER_COLUMN_G_C_C_T_CLASSPK_2);
1285    
1286                            query.append(_FINDER_COLUMN_G_C_C_T_TYPE_2);
1287    
1288                            if (orderByComparator != null) {
1289                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1290                                            orderByComparator);
1291                            }
1292                            else
1293                             if (pagination) {
1294                                    query.append(SystemEventModelImpl.ORDER_BY_JPQL);
1295                            }
1296    
1297                            String sql = query.toString();
1298    
1299                            Session session = null;
1300    
1301                            try {
1302                                    session = openSession();
1303    
1304                                    Query q = session.createQuery(sql);
1305    
1306                                    QueryPos qPos = QueryPos.getInstance(q);
1307    
1308                                    qPos.add(groupId);
1309    
1310                                    qPos.add(classNameId);
1311    
1312                                    qPos.add(classPK);
1313    
1314                                    qPos.add(type);
1315    
1316                                    if (!pagination) {
1317                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
1318                                                            start, end, false);
1319    
1320                                            Collections.sort(list);
1321    
1322                                            list = new UnmodifiableList<SystemEvent>(list);
1323                                    }
1324                                    else {
1325                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
1326                                                            start, end);
1327                                    }
1328    
1329                                    cacheResult(list);
1330    
1331                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1332                            }
1333                            catch (Exception e) {
1334                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1335    
1336                                    throw processException(e);
1337                            }
1338                            finally {
1339                                    closeSession(session);
1340                            }
1341                    }
1342    
1343                    return list;
1344            }
1345    
1346            /**
1347             * Returns the first system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1348             *
1349             * @param groupId the group ID
1350             * @param classNameId the class name ID
1351             * @param classPK the class p k
1352             * @param type the type
1353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1354             * @return the first matching system event
1355             * @throws com.liferay.portal.NoSuchSystemEventException if a matching system event could not be found
1356             * @throws SystemException if a system exception occurred
1357             */
1358            @Override
1359            public SystemEvent findByG_C_C_T_First(long groupId, long classNameId,
1360                    long classPK, int type, OrderByComparator orderByComparator)
1361                    throws NoSuchSystemEventException, SystemException {
1362                    SystemEvent systemEvent = fetchByG_C_C_T_First(groupId, classNameId,
1363                                    classPK, type, orderByComparator);
1364    
1365                    if (systemEvent != null) {
1366                            return systemEvent;
1367                    }
1368    
1369                    StringBundler msg = new StringBundler(10);
1370    
1371                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1372    
1373                    msg.append("groupId=");
1374                    msg.append(groupId);
1375    
1376                    msg.append(", classNameId=");
1377                    msg.append(classNameId);
1378    
1379                    msg.append(", classPK=");
1380                    msg.append(classPK);
1381    
1382                    msg.append(", type=");
1383                    msg.append(type);
1384    
1385                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1386    
1387                    throw new NoSuchSystemEventException(msg.toString());
1388            }
1389    
1390            /**
1391             * Returns the first system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1392             *
1393             * @param groupId the group ID
1394             * @param classNameId the class name ID
1395             * @param classPK the class p k
1396             * @param type the type
1397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1398             * @return the first matching system event, or <code>null</code> if a matching system event could not be found
1399             * @throws SystemException if a system exception occurred
1400             */
1401            @Override
1402            public SystemEvent fetchByG_C_C_T_First(long groupId, long classNameId,
1403                    long classPK, int type, OrderByComparator orderByComparator)
1404                    throws SystemException {
1405                    List<SystemEvent> list = findByG_C_C_T(groupId, classNameId, classPK,
1406                                    type, 0, 1, orderByComparator);
1407    
1408                    if (!list.isEmpty()) {
1409                            return list.get(0);
1410                    }
1411    
1412                    return null;
1413            }
1414    
1415            /**
1416             * Returns the last system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1417             *
1418             * @param groupId the group ID
1419             * @param classNameId the class name ID
1420             * @param classPK the class p k
1421             * @param type the type
1422             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1423             * @return the last matching system event
1424             * @throws com.liferay.portal.NoSuchSystemEventException if a matching system event could not be found
1425             * @throws SystemException if a system exception occurred
1426             */
1427            @Override
1428            public SystemEvent findByG_C_C_T_Last(long groupId, long classNameId,
1429                    long classPK, int type, OrderByComparator orderByComparator)
1430                    throws NoSuchSystemEventException, SystemException {
1431                    SystemEvent systemEvent = fetchByG_C_C_T_Last(groupId, classNameId,
1432                                    classPK, type, orderByComparator);
1433    
1434                    if (systemEvent != null) {
1435                            return systemEvent;
1436                    }
1437    
1438                    StringBundler msg = new StringBundler(10);
1439    
1440                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1441    
1442                    msg.append("groupId=");
1443                    msg.append(groupId);
1444    
1445                    msg.append(", classNameId=");
1446                    msg.append(classNameId);
1447    
1448                    msg.append(", classPK=");
1449                    msg.append(classPK);
1450    
1451                    msg.append(", type=");
1452                    msg.append(type);
1453    
1454                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1455    
1456                    throw new NoSuchSystemEventException(msg.toString());
1457            }
1458    
1459            /**
1460             * Returns the last system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1461             *
1462             * @param groupId the group ID
1463             * @param classNameId the class name ID
1464             * @param classPK the class p k
1465             * @param type the type
1466             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1467             * @return the last matching system event, or <code>null</code> if a matching system event could not be found
1468             * @throws SystemException if a system exception occurred
1469             */
1470            @Override
1471            public SystemEvent fetchByG_C_C_T_Last(long groupId, long classNameId,
1472                    long classPK, int type, OrderByComparator orderByComparator)
1473                    throws SystemException {
1474                    int count = countByG_C_C_T(groupId, classNameId, classPK, type);
1475    
1476                    if (count == 0) {
1477                            return null;
1478                    }
1479    
1480                    List<SystemEvent> list = findByG_C_C_T(groupId, classNameId, classPK,
1481                                    type, count - 1, count, orderByComparator);
1482    
1483                    if (!list.isEmpty()) {
1484                            return list.get(0);
1485                    }
1486    
1487                    return null;
1488            }
1489    
1490            /**
1491             * Returns the system events before and after the current system event in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1492             *
1493             * @param systemEventId the primary key of the current system event
1494             * @param groupId the group ID
1495             * @param classNameId the class name ID
1496             * @param classPK the class p k
1497             * @param type the type
1498             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1499             * @return the previous, current, and next system event
1500             * @throws com.liferay.portal.NoSuchSystemEventException if a system event with the primary key could not be found
1501             * @throws SystemException if a system exception occurred
1502             */
1503            @Override
1504            public SystemEvent[] findByG_C_C_T_PrevAndNext(long systemEventId,
1505                    long groupId, long classNameId, long classPK, int type,
1506                    OrderByComparator orderByComparator)
1507                    throws NoSuchSystemEventException, SystemException {
1508                    SystemEvent systemEvent = findByPrimaryKey(systemEventId);
1509    
1510                    Session session = null;
1511    
1512                    try {
1513                            session = openSession();
1514    
1515                            SystemEvent[] array = new SystemEventImpl[3];
1516    
1517                            array[0] = getByG_C_C_T_PrevAndNext(session, systemEvent, groupId,
1518                                            classNameId, classPK, type, orderByComparator, true);
1519    
1520                            array[1] = systemEvent;
1521    
1522                            array[2] = getByG_C_C_T_PrevAndNext(session, systemEvent, groupId,
1523                                            classNameId, classPK, type, orderByComparator, false);
1524    
1525                            return array;
1526                    }
1527                    catch (Exception e) {
1528                            throw processException(e);
1529                    }
1530                    finally {
1531                            closeSession(session);
1532                    }
1533            }
1534    
1535            protected SystemEvent getByG_C_C_T_PrevAndNext(Session session,
1536                    SystemEvent systemEvent, long groupId, long classNameId, long classPK,
1537                    int type, OrderByComparator orderByComparator, boolean previous) {
1538                    StringBundler query = null;
1539    
1540                    if (orderByComparator != null) {
1541                            query = new StringBundler(6 +
1542                                            (orderByComparator.getOrderByFields().length * 6));
1543                    }
1544                    else {
1545                            query = new StringBundler(3);
1546                    }
1547    
1548                    query.append(_SQL_SELECT_SYSTEMEVENT_WHERE);
1549    
1550                    query.append(_FINDER_COLUMN_G_C_C_T_GROUPID_2);
1551    
1552                    query.append(_FINDER_COLUMN_G_C_C_T_CLASSNAMEID_2);
1553    
1554                    query.append(_FINDER_COLUMN_G_C_C_T_CLASSPK_2);
1555    
1556                    query.append(_FINDER_COLUMN_G_C_C_T_TYPE_2);
1557    
1558                    if (orderByComparator != null) {
1559                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1560    
1561                            if (orderByConditionFields.length > 0) {
1562                                    query.append(WHERE_AND);
1563                            }
1564    
1565                            for (int i = 0; i < orderByConditionFields.length; i++) {
1566                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1567                                    query.append(orderByConditionFields[i]);
1568    
1569                                    if ((i + 1) < orderByConditionFields.length) {
1570                                            if (orderByComparator.isAscending() ^ previous) {
1571                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1572                                            }
1573                                            else {
1574                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1575                                            }
1576                                    }
1577                                    else {
1578                                            if (orderByComparator.isAscending() ^ previous) {
1579                                                    query.append(WHERE_GREATER_THAN);
1580                                            }
1581                                            else {
1582                                                    query.append(WHERE_LESSER_THAN);
1583                                            }
1584                                    }
1585                            }
1586    
1587                            query.append(ORDER_BY_CLAUSE);
1588    
1589                            String[] orderByFields = orderByComparator.getOrderByFields();
1590    
1591                            for (int i = 0; i < orderByFields.length; i++) {
1592                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1593                                    query.append(orderByFields[i]);
1594    
1595                                    if ((i + 1) < orderByFields.length) {
1596                                            if (orderByComparator.isAscending() ^ previous) {
1597                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1598                                            }
1599                                            else {
1600                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1601                                            }
1602                                    }
1603                                    else {
1604                                            if (orderByComparator.isAscending() ^ previous) {
1605                                                    query.append(ORDER_BY_ASC);
1606                                            }
1607                                            else {
1608                                                    query.append(ORDER_BY_DESC);
1609                                            }
1610                                    }
1611                            }
1612                    }
1613                    else {
1614                            query.append(SystemEventModelImpl.ORDER_BY_JPQL);
1615                    }
1616    
1617                    String sql = query.toString();
1618    
1619                    Query q = session.createQuery(sql);
1620    
1621                    q.setFirstResult(0);
1622                    q.setMaxResults(2);
1623    
1624                    QueryPos qPos = QueryPos.getInstance(q);
1625    
1626                    qPos.add(groupId);
1627    
1628                    qPos.add(classNameId);
1629    
1630                    qPos.add(classPK);
1631    
1632                    qPos.add(type);
1633    
1634                    if (orderByComparator != null) {
1635                            Object[] values = orderByComparator.getOrderByConditionValues(systemEvent);
1636    
1637                            for (Object value : values) {
1638                                    qPos.add(value);
1639                            }
1640                    }
1641    
1642                    List<SystemEvent> list = q.list();
1643    
1644                    if (list.size() == 2) {
1645                            return list.get(1);
1646                    }
1647                    else {
1648                            return null;
1649                    }
1650            }
1651    
1652            /**
1653             * Removes all the system events where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; from the database.
1654             *
1655             * @param groupId the group ID
1656             * @param classNameId the class name ID
1657             * @param classPK the class p k
1658             * @param type the type
1659             * @throws SystemException if a system exception occurred
1660             */
1661            @Override
1662            public void removeByG_C_C_T(long groupId, long classNameId, long classPK,
1663                    int type) throws SystemException {
1664                    for (SystemEvent systemEvent : findByG_C_C_T(groupId, classNameId,
1665                                    classPK, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1666                            remove(systemEvent);
1667                    }
1668            }
1669    
1670            /**
1671             * Returns the number of system events where groupId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
1672             *
1673             * @param groupId the group ID
1674             * @param classNameId the class name ID
1675             * @param classPK the class p k
1676             * @param type the type
1677             * @return the number of matching system events
1678             * @throws SystemException if a system exception occurred
1679             */
1680            @Override
1681            public int countByG_C_C_T(long groupId, long classNameId, long classPK,
1682                    int type) throws SystemException {
1683                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C_T;
1684    
1685                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK, type };
1686    
1687                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1688                                    this);
1689    
1690                    if (count == null) {
1691                            StringBundler query = new StringBundler(5);
1692    
1693                            query.append(_SQL_COUNT_SYSTEMEVENT_WHERE);
1694    
1695                            query.append(_FINDER_COLUMN_G_C_C_T_GROUPID_2);
1696    
1697                            query.append(_FINDER_COLUMN_G_C_C_T_CLASSNAMEID_2);
1698    
1699                            query.append(_FINDER_COLUMN_G_C_C_T_CLASSPK_2);
1700    
1701                            query.append(_FINDER_COLUMN_G_C_C_T_TYPE_2);
1702    
1703                            String sql = query.toString();
1704    
1705                            Session session = null;
1706    
1707                            try {
1708                                    session = openSession();
1709    
1710                                    Query q = session.createQuery(sql);
1711    
1712                                    QueryPos qPos = QueryPos.getInstance(q);
1713    
1714                                    qPos.add(groupId);
1715    
1716                                    qPos.add(classNameId);
1717    
1718                                    qPos.add(classPK);
1719    
1720                                    qPos.add(type);
1721    
1722                                    count = (Long)q.uniqueResult();
1723    
1724                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1725                            }
1726                            catch (Exception e) {
1727                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1728    
1729                                    throw processException(e);
1730                            }
1731                            finally {
1732                                    closeSession(session);
1733                            }
1734                    }
1735    
1736                    return count.intValue();
1737            }
1738    
1739            private static final String _FINDER_COLUMN_G_C_C_T_GROUPID_2 = "systemEvent.groupId = ? AND ";
1740            private static final String _FINDER_COLUMN_G_C_C_T_CLASSNAMEID_2 = "systemEvent.classNameId = ? AND ";
1741            private static final String _FINDER_COLUMN_G_C_C_T_CLASSPK_2 = "systemEvent.classPK = ? AND ";
1742            private static final String _FINDER_COLUMN_G_C_C_T_TYPE_2 = "systemEvent.type = ?";
1743    
1744            public SystemEventPersistenceImpl() {
1745                    setModelClass(SystemEvent.class);
1746            }
1747    
1748            /**
1749             * Caches the system event in the entity cache if it is enabled.
1750             *
1751             * @param systemEvent the system event
1752             */
1753            @Override
1754            public void cacheResult(SystemEvent systemEvent) {
1755                    EntityCacheUtil.putResult(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
1756                            SystemEventImpl.class, systemEvent.getPrimaryKey(), systemEvent);
1757    
1758                    systemEvent.resetOriginalValues();
1759            }
1760    
1761            /**
1762             * Caches the system events in the entity cache if it is enabled.
1763             *
1764             * @param systemEvents the system events
1765             */
1766            @Override
1767            public void cacheResult(List<SystemEvent> systemEvents) {
1768                    for (SystemEvent systemEvent : systemEvents) {
1769                            if (EntityCacheUtil.getResult(
1770                                                    SystemEventModelImpl.ENTITY_CACHE_ENABLED,
1771                                                    SystemEventImpl.class, systemEvent.getPrimaryKey()) == null) {
1772                                    cacheResult(systemEvent);
1773                            }
1774                            else {
1775                                    systemEvent.resetOriginalValues();
1776                            }
1777                    }
1778            }
1779    
1780            /**
1781             * Clears the cache for all system events.
1782             *
1783             * <p>
1784             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1785             * </p>
1786             */
1787            @Override
1788            public void clearCache() {
1789                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1790                            CacheRegistryUtil.clear(SystemEventImpl.class.getName());
1791                    }
1792    
1793                    EntityCacheUtil.clearCache(SystemEventImpl.class.getName());
1794    
1795                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1796                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1797                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1798            }
1799    
1800            /**
1801             * Clears the cache for the system event.
1802             *
1803             * <p>
1804             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1805             * </p>
1806             */
1807            @Override
1808            public void clearCache(SystemEvent systemEvent) {
1809                    EntityCacheUtil.removeResult(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
1810                            SystemEventImpl.class, systemEvent.getPrimaryKey());
1811    
1812                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1813                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1814            }
1815    
1816            @Override
1817            public void clearCache(List<SystemEvent> systemEvents) {
1818                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1819                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1820    
1821                    for (SystemEvent systemEvent : systemEvents) {
1822                            EntityCacheUtil.removeResult(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
1823                                    SystemEventImpl.class, systemEvent.getPrimaryKey());
1824                    }
1825            }
1826    
1827            /**
1828             * Creates a new system event with the primary key. Does not add the system event to the database.
1829             *
1830             * @param systemEventId the primary key for the new system event
1831             * @return the new system event
1832             */
1833            @Override
1834            public SystemEvent create(long systemEventId) {
1835                    SystemEvent systemEvent = new SystemEventImpl();
1836    
1837                    systemEvent.setNew(true);
1838                    systemEvent.setPrimaryKey(systemEventId);
1839    
1840                    return systemEvent;
1841            }
1842    
1843            /**
1844             * Removes the system event with the primary key from the database. Also notifies the appropriate model listeners.
1845             *
1846             * @param systemEventId the primary key of the system event
1847             * @return the system event that was removed
1848             * @throws com.liferay.portal.NoSuchSystemEventException if a system event with the primary key could not be found
1849             * @throws SystemException if a system exception occurred
1850             */
1851            @Override
1852            public SystemEvent remove(long systemEventId)
1853                    throws NoSuchSystemEventException, SystemException {
1854                    return remove((Serializable)systemEventId);
1855            }
1856    
1857            /**
1858             * Removes the system event with the primary key from the database. Also notifies the appropriate model listeners.
1859             *
1860             * @param primaryKey the primary key of the system event
1861             * @return the system event that was removed
1862             * @throws com.liferay.portal.NoSuchSystemEventException if a system event with the primary key could not be found
1863             * @throws SystemException if a system exception occurred
1864             */
1865            @Override
1866            public SystemEvent remove(Serializable primaryKey)
1867                    throws NoSuchSystemEventException, SystemException {
1868                    Session session = null;
1869    
1870                    try {
1871                            session = openSession();
1872    
1873                            SystemEvent systemEvent = (SystemEvent)session.get(SystemEventImpl.class,
1874                                            primaryKey);
1875    
1876                            if (systemEvent == null) {
1877                                    if (_log.isWarnEnabled()) {
1878                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1879                                    }
1880    
1881                                    throw new NoSuchSystemEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1882                                            primaryKey);
1883                            }
1884    
1885                            return remove(systemEvent);
1886                    }
1887                    catch (NoSuchSystemEventException nsee) {
1888                            throw nsee;
1889                    }
1890                    catch (Exception e) {
1891                            throw processException(e);
1892                    }
1893                    finally {
1894                            closeSession(session);
1895                    }
1896            }
1897    
1898            @Override
1899            protected SystemEvent removeImpl(SystemEvent systemEvent)
1900                    throws SystemException {
1901                    systemEvent = toUnwrappedModel(systemEvent);
1902    
1903                    Session session = null;
1904    
1905                    try {
1906                            session = openSession();
1907    
1908                            if (!session.contains(systemEvent)) {
1909                                    systemEvent = (SystemEvent)session.get(SystemEventImpl.class,
1910                                                    systemEvent.getPrimaryKeyObj());
1911                            }
1912    
1913                            if (systemEvent != null) {
1914                                    session.delete(systemEvent);
1915                            }
1916                    }
1917                    catch (Exception e) {
1918                            throw processException(e);
1919                    }
1920                    finally {
1921                            closeSession(session);
1922                    }
1923    
1924                    if (systemEvent != null) {
1925                            clearCache(systemEvent);
1926                    }
1927    
1928                    return systemEvent;
1929            }
1930    
1931            @Override
1932            public SystemEvent updateImpl(
1933                    com.liferay.portal.model.SystemEvent systemEvent)
1934                    throws SystemException {
1935                    systemEvent = toUnwrappedModel(systemEvent);
1936    
1937                    boolean isNew = systemEvent.isNew();
1938    
1939                    SystemEventModelImpl systemEventModelImpl = (SystemEventModelImpl)systemEvent;
1940    
1941                    Session session = null;
1942    
1943                    try {
1944                            session = openSession();
1945    
1946                            if (systemEvent.isNew()) {
1947                                    session.save(systemEvent);
1948    
1949                                    systemEvent.setNew(false);
1950                            }
1951                            else {
1952                                    session.merge(systemEvent);
1953                            }
1954                    }
1955                    catch (Exception e) {
1956                            throw processException(e);
1957                    }
1958                    finally {
1959                            closeSession(session);
1960                    }
1961    
1962                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1963    
1964                    if (isNew || !SystemEventModelImpl.COLUMN_BITMASK_ENABLED) {
1965                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1966                    }
1967    
1968                    else {
1969                            if ((systemEventModelImpl.getColumnBitmask() &
1970                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
1971                                    Object[] args = new Object[] {
1972                                                    systemEventModelImpl.getOriginalGroupId()
1973                                            };
1974    
1975                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1976                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1977                                            args);
1978    
1979                                    args = new Object[] { systemEventModelImpl.getGroupId() };
1980    
1981                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1982                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1983                                            args);
1984                            }
1985    
1986                            if ((systemEventModelImpl.getColumnBitmask() &
1987                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
1988                                    Object[] args = new Object[] {
1989                                                    systemEventModelImpl.getOriginalGroupId(),
1990                                                    systemEventModelImpl.getOriginalClassNameId(),
1991                                                    systemEventModelImpl.getOriginalClassPK()
1992                                            };
1993    
1994                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1995                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1996                                            args);
1997    
1998                                    args = new Object[] {
1999                                                    systemEventModelImpl.getGroupId(),
2000                                                    systemEventModelImpl.getClassNameId(),
2001                                                    systemEventModelImpl.getClassPK()
2002                                            };
2003    
2004                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
2005                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
2006                                            args);
2007                            }
2008    
2009                            if ((systemEventModelImpl.getColumnBitmask() &
2010                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_T.getColumnBitmask()) != 0) {
2011                                    Object[] args = new Object[] {
2012                                                    systemEventModelImpl.getOriginalGroupId(),
2013                                                    systemEventModelImpl.getOriginalClassNameId(),
2014                                                    systemEventModelImpl.getOriginalClassPK(),
2015                                                    systemEventModelImpl.getOriginalType()
2016                                            };
2017    
2018                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_T, args);
2019                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_T,
2020                                            args);
2021    
2022                                    args = new Object[] {
2023                                                    systemEventModelImpl.getGroupId(),
2024                                                    systemEventModelImpl.getClassNameId(),
2025                                                    systemEventModelImpl.getClassPK(),
2026                                                    systemEventModelImpl.getType()
2027                                            };
2028    
2029                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_T, args);
2030                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_T,
2031                                            args);
2032                            }
2033                    }
2034    
2035                    EntityCacheUtil.putResult(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
2036                            SystemEventImpl.class, systemEvent.getPrimaryKey(), systemEvent);
2037    
2038                    return systemEvent;
2039            }
2040    
2041            protected SystemEvent toUnwrappedModel(SystemEvent systemEvent) {
2042                    if (systemEvent instanceof SystemEventImpl) {
2043                            return systemEvent;
2044                    }
2045    
2046                    SystemEventImpl systemEventImpl = new SystemEventImpl();
2047    
2048                    systemEventImpl.setNew(systemEvent.isNew());
2049                    systemEventImpl.setPrimaryKey(systemEvent.getPrimaryKey());
2050    
2051                    systemEventImpl.setSystemEventId(systemEvent.getSystemEventId());
2052                    systemEventImpl.setGroupId(systemEvent.getGroupId());
2053                    systemEventImpl.setCompanyId(systemEvent.getCompanyId());
2054                    systemEventImpl.setUserId(systemEvent.getUserId());
2055                    systemEventImpl.setUserName(systemEvent.getUserName());
2056                    systemEventImpl.setCreateDate(systemEvent.getCreateDate());
2057                    systemEventImpl.setClassNameId(systemEvent.getClassNameId());
2058                    systemEventImpl.setClassPK(systemEvent.getClassPK());
2059                    systemEventImpl.setClassUuid(systemEvent.getClassUuid());
2060                    systemEventImpl.setReferrerClassNameId(systemEvent.getReferrerClassNameId());
2061                    systemEventImpl.setParentSystemEventId(systemEvent.getParentSystemEventId());
2062                    systemEventImpl.setSystemEventSetKey(systemEvent.getSystemEventSetKey());
2063                    systemEventImpl.setType(systemEvent.getType());
2064                    systemEventImpl.setExtraData(systemEvent.getExtraData());
2065    
2066                    return systemEventImpl;
2067            }
2068    
2069            /**
2070             * Returns the system event with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2071             *
2072             * @param primaryKey the primary key of the system event
2073             * @return the system event
2074             * @throws com.liferay.portal.NoSuchSystemEventException if a system event with the primary key could not be found
2075             * @throws SystemException if a system exception occurred
2076             */
2077            @Override
2078            public SystemEvent findByPrimaryKey(Serializable primaryKey)
2079                    throws NoSuchSystemEventException, SystemException {
2080                    SystemEvent systemEvent = fetchByPrimaryKey(primaryKey);
2081    
2082                    if (systemEvent == null) {
2083                            if (_log.isWarnEnabled()) {
2084                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2085                            }
2086    
2087                            throw new NoSuchSystemEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2088                                    primaryKey);
2089                    }
2090    
2091                    return systemEvent;
2092            }
2093    
2094            /**
2095             * Returns the system event with the primary key or throws a {@link com.liferay.portal.NoSuchSystemEventException} if it could not be found.
2096             *
2097             * @param systemEventId the primary key of the system event
2098             * @return the system event
2099             * @throws com.liferay.portal.NoSuchSystemEventException if a system event with the primary key could not be found
2100             * @throws SystemException if a system exception occurred
2101             */
2102            @Override
2103            public SystemEvent findByPrimaryKey(long systemEventId)
2104                    throws NoSuchSystemEventException, SystemException {
2105                    return findByPrimaryKey((Serializable)systemEventId);
2106            }
2107    
2108            /**
2109             * Returns the system event with the primary key or returns <code>null</code> if it could not be found.
2110             *
2111             * @param primaryKey the primary key of the system event
2112             * @return the system event, or <code>null</code> if a system event with the primary key could not be found
2113             * @throws SystemException if a system exception occurred
2114             */
2115            @Override
2116            public SystemEvent fetchByPrimaryKey(Serializable primaryKey)
2117                    throws SystemException {
2118                    SystemEvent systemEvent = (SystemEvent)EntityCacheUtil.getResult(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
2119                                    SystemEventImpl.class, primaryKey);
2120    
2121                    if (systemEvent == _nullSystemEvent) {
2122                            return null;
2123                    }
2124    
2125                    if (systemEvent == null) {
2126                            Session session = null;
2127    
2128                            try {
2129                                    session = openSession();
2130    
2131                                    systemEvent = (SystemEvent)session.get(SystemEventImpl.class,
2132                                                    primaryKey);
2133    
2134                                    if (systemEvent != null) {
2135                                            cacheResult(systemEvent);
2136                                    }
2137                                    else {
2138                                            EntityCacheUtil.putResult(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
2139                                                    SystemEventImpl.class, primaryKey, _nullSystemEvent);
2140                                    }
2141                            }
2142                            catch (Exception e) {
2143                                    EntityCacheUtil.removeResult(SystemEventModelImpl.ENTITY_CACHE_ENABLED,
2144                                            SystemEventImpl.class, primaryKey);
2145    
2146                                    throw processException(e);
2147                            }
2148                            finally {
2149                                    closeSession(session);
2150                            }
2151                    }
2152    
2153                    return systemEvent;
2154            }
2155    
2156            /**
2157             * Returns the system event with the primary key or returns <code>null</code> if it could not be found.
2158             *
2159             * @param systemEventId the primary key of the system event
2160             * @return the system event, or <code>null</code> if a system event with the primary key could not be found
2161             * @throws SystemException if a system exception occurred
2162             */
2163            @Override
2164            public SystemEvent fetchByPrimaryKey(long systemEventId)
2165                    throws SystemException {
2166                    return fetchByPrimaryKey((Serializable)systemEventId);
2167            }
2168    
2169            /**
2170             * Returns all the system events.
2171             *
2172             * @return the system events
2173             * @throws SystemException if a system exception occurred
2174             */
2175            @Override
2176            public List<SystemEvent> findAll() throws SystemException {
2177                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2178            }
2179    
2180            /**
2181             * Returns a range of all the system events.
2182             *
2183             * <p>
2184             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. 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.
2185             * </p>
2186             *
2187             * @param start the lower bound of the range of system events
2188             * @param end the upper bound of the range of system events (not inclusive)
2189             * @return the range of system events
2190             * @throws SystemException if a system exception occurred
2191             */
2192            @Override
2193            public List<SystemEvent> findAll(int start, int end)
2194                    throws SystemException {
2195                    return findAll(start, end, null);
2196            }
2197    
2198            /**
2199             * Returns an ordered range of all the system events.
2200             *
2201             * <p>
2202             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.SystemEventModelImpl}. 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.
2203             * </p>
2204             *
2205             * @param start the lower bound of the range of system events
2206             * @param end the upper bound of the range of system events (not inclusive)
2207             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2208             * @return the ordered range of system events
2209             * @throws SystemException if a system exception occurred
2210             */
2211            @Override
2212            public List<SystemEvent> findAll(int start, int end,
2213                    OrderByComparator orderByComparator) throws SystemException {
2214                    boolean pagination = true;
2215                    FinderPath finderPath = null;
2216                    Object[] finderArgs = null;
2217    
2218                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2219                                    (orderByComparator == null)) {
2220                            pagination = false;
2221                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2222                            finderArgs = FINDER_ARGS_EMPTY;
2223                    }
2224                    else {
2225                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2226                            finderArgs = new Object[] { start, end, orderByComparator };
2227                    }
2228    
2229                    List<SystemEvent> list = (List<SystemEvent>)FinderCacheUtil.getResult(finderPath,
2230                                    finderArgs, this);
2231    
2232                    if (list == null) {
2233                            StringBundler query = null;
2234                            String sql = null;
2235    
2236                            if (orderByComparator != null) {
2237                                    query = new StringBundler(2 +
2238                                                    (orderByComparator.getOrderByFields().length * 3));
2239    
2240                                    query.append(_SQL_SELECT_SYSTEMEVENT);
2241    
2242                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2243                                            orderByComparator);
2244    
2245                                    sql = query.toString();
2246                            }
2247                            else {
2248                                    sql = _SQL_SELECT_SYSTEMEVENT;
2249    
2250                                    if (pagination) {
2251                                            sql = sql.concat(SystemEventModelImpl.ORDER_BY_JPQL);
2252                                    }
2253                            }
2254    
2255                            Session session = null;
2256    
2257                            try {
2258                                    session = openSession();
2259    
2260                                    Query q = session.createQuery(sql);
2261    
2262                                    if (!pagination) {
2263                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
2264                                                            start, end, false);
2265    
2266                                            Collections.sort(list);
2267    
2268                                            list = new UnmodifiableList<SystemEvent>(list);
2269                                    }
2270                                    else {
2271                                            list = (List<SystemEvent>)QueryUtil.list(q, getDialect(),
2272                                                            start, end);
2273                                    }
2274    
2275                                    cacheResult(list);
2276    
2277                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2278                            }
2279                            catch (Exception e) {
2280                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2281    
2282                                    throw processException(e);
2283                            }
2284                            finally {
2285                                    closeSession(session);
2286                            }
2287                    }
2288    
2289                    return list;
2290            }
2291    
2292            /**
2293             * Removes all the system events from the database.
2294             *
2295             * @throws SystemException if a system exception occurred
2296             */
2297            @Override
2298            public void removeAll() throws SystemException {
2299                    for (SystemEvent systemEvent : findAll()) {
2300                            remove(systemEvent);
2301                    }
2302            }
2303    
2304            /**
2305             * Returns the number of system events.
2306             *
2307             * @return the number of system events
2308             * @throws SystemException if a system exception occurred
2309             */
2310            @Override
2311            public int countAll() throws SystemException {
2312                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2313                                    FINDER_ARGS_EMPTY, this);
2314    
2315                    if (count == null) {
2316                            Session session = null;
2317    
2318                            try {
2319                                    session = openSession();
2320    
2321                                    Query q = session.createQuery(_SQL_COUNT_SYSTEMEVENT);
2322    
2323                                    count = (Long)q.uniqueResult();
2324    
2325                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2326                                            FINDER_ARGS_EMPTY, count);
2327                            }
2328                            catch (Exception e) {
2329                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2330                                            FINDER_ARGS_EMPTY);
2331    
2332                                    throw processException(e);
2333                            }
2334                            finally {
2335                                    closeSession(session);
2336                            }
2337                    }
2338    
2339                    return count.intValue();
2340            }
2341    
2342            @Override
2343            protected Set<String> getBadColumnNames() {
2344                    return _badColumnNames;
2345            }
2346    
2347            /**
2348             * Initializes the system event persistence.
2349             */
2350            public void afterPropertiesSet() {
2351                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2352                                            com.liferay.portal.util.PropsUtil.get(
2353                                                    "value.object.listener.com.liferay.portal.model.SystemEvent")));
2354    
2355                    if (listenerClassNames.length > 0) {
2356                            try {
2357                                    List<ModelListener<SystemEvent>> listenersList = new ArrayList<ModelListener<SystemEvent>>();
2358    
2359                                    for (String listenerClassName : listenerClassNames) {
2360                                            listenersList.add((ModelListener<SystemEvent>)InstanceFactory.newInstance(
2361                                                            getClassLoader(), listenerClassName));
2362                                    }
2363    
2364                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2365                            }
2366                            catch (Exception e) {
2367                                    _log.error(e);
2368                            }
2369                    }
2370            }
2371    
2372            public void destroy() {
2373                    EntityCacheUtil.removeCache(SystemEventImpl.class.getName());
2374                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2375                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2376                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2377            }
2378    
2379            private static final String _SQL_SELECT_SYSTEMEVENT = "SELECT systemEvent FROM SystemEvent systemEvent";
2380            private static final String _SQL_SELECT_SYSTEMEVENT_WHERE = "SELECT systemEvent FROM SystemEvent systemEvent WHERE ";
2381            private static final String _SQL_COUNT_SYSTEMEVENT = "SELECT COUNT(systemEvent) FROM SystemEvent systemEvent";
2382            private static final String _SQL_COUNT_SYSTEMEVENT_WHERE = "SELECT COUNT(systemEvent) FROM SystemEvent systemEvent WHERE ";
2383            private static final String _ORDER_BY_ENTITY_ALIAS = "systemEvent.";
2384            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SystemEvent exists with the primary key ";
2385            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SystemEvent exists with the key {";
2386            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2387            private static Log _log = LogFactoryUtil.getLog(SystemEventPersistenceImpl.class);
2388            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2389                                    "type"
2390                            });
2391            private static SystemEvent _nullSystemEvent = new SystemEventImpl() {
2392                            @Override
2393                            public Object clone() {
2394                                    return this;
2395                            }
2396    
2397                            @Override
2398                            public CacheModel<SystemEvent> toCacheModel() {
2399                                    return _nullSystemEventCacheModel;
2400                            }
2401                    };
2402    
2403            private static CacheModel<SystemEvent> _nullSystemEventCacheModel = new CacheModel<SystemEvent>() {
2404                            @Override
2405                            public SystemEvent toEntityModel() {
2406                                    return _nullSystemEvent;
2407                            }
2408                    };
2409    }