001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchClusterGroupException;
018    import com.liferay.portal.NoSuchModelException;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.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.StringBundler;
033    import com.liferay.portal.kernel.util.StringUtil;
034    import com.liferay.portal.kernel.util.UnmodifiableList;
035    import com.liferay.portal.model.CacheModel;
036    import com.liferay.portal.model.ClusterGroup;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.model.impl.ClusterGroupImpl;
039    import com.liferay.portal.model.impl.ClusterGroupModelImpl;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import java.io.Serializable;
043    
044    import java.util.ArrayList;
045    import java.util.Collections;
046    import java.util.List;
047    
048    /**
049     * The persistence implementation for the cluster group service.
050     *
051     * <p>
052     * Caching information and settings can be found in <code>portal.properties</code>
053     * </p>
054     *
055     * @author Brian Wing Shun Chan
056     * @see ClusterGroupPersistence
057     * @see ClusterGroupUtil
058     * @generated
059     */
060    public class ClusterGroupPersistenceImpl extends BasePersistenceImpl<ClusterGroup>
061            implements ClusterGroupPersistence {
062            /*
063             * NOTE FOR DEVELOPERS:
064             *
065             * Never modify or reference this class directly. Always use {@link ClusterGroupUtil} to access the cluster group persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
066             */
067            public static final String FINDER_CLASS_NAME_ENTITY = ClusterGroupImpl.class.getName();
068            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
069                    ".List1";
070            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071                    ".List2";
072            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
073                            ClusterGroupModelImpl.FINDER_CACHE_ENABLED, ClusterGroupImpl.class,
074                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
075            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
076                            ClusterGroupModelImpl.FINDER_CACHE_ENABLED, ClusterGroupImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
078            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
079                            ClusterGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
081    
082            /**
083             * Caches the cluster group in the entity cache if it is enabled.
084             *
085             * @param clusterGroup the cluster group
086             */
087            public void cacheResult(ClusterGroup clusterGroup) {
088                    EntityCacheUtil.putResult(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
089                            ClusterGroupImpl.class, clusterGroup.getPrimaryKey(), clusterGroup);
090    
091                    clusterGroup.resetOriginalValues();
092            }
093    
094            /**
095             * Caches the cluster groups in the entity cache if it is enabled.
096             *
097             * @param clusterGroups the cluster groups
098             */
099            public void cacheResult(List<ClusterGroup> clusterGroups) {
100                    for (ClusterGroup clusterGroup : clusterGroups) {
101                            if (EntityCacheUtil.getResult(
102                                                    ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
103                                                    ClusterGroupImpl.class, clusterGroup.getPrimaryKey()) == null) {
104                                    cacheResult(clusterGroup);
105                            }
106                            else {
107                                    clusterGroup.resetOriginalValues();
108                            }
109                    }
110            }
111    
112            /**
113             * Clears the cache for all cluster groups.
114             *
115             * <p>
116             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
117             * </p>
118             */
119            @Override
120            public void clearCache() {
121                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
122                            CacheRegistryUtil.clear(ClusterGroupImpl.class.getName());
123                    }
124    
125                    EntityCacheUtil.clearCache(ClusterGroupImpl.class.getName());
126    
127                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
128                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
129                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
130            }
131    
132            /**
133             * Clears the cache for the cluster group.
134             *
135             * <p>
136             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
137             * </p>
138             */
139            @Override
140            public void clearCache(ClusterGroup clusterGroup) {
141                    EntityCacheUtil.removeResult(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
142                            ClusterGroupImpl.class, clusterGroup.getPrimaryKey());
143    
144                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
145                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
146            }
147    
148            @Override
149            public void clearCache(List<ClusterGroup> clusterGroups) {
150                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
151                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
152    
153                    for (ClusterGroup clusterGroup : clusterGroups) {
154                            EntityCacheUtil.removeResult(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
155                                    ClusterGroupImpl.class, clusterGroup.getPrimaryKey());
156                    }
157            }
158    
159            /**
160             * Creates a new cluster group with the primary key. Does not add the cluster group to the database.
161             *
162             * @param clusterGroupId the primary key for the new cluster group
163             * @return the new cluster group
164             */
165            public ClusterGroup create(long clusterGroupId) {
166                    ClusterGroup clusterGroup = new ClusterGroupImpl();
167    
168                    clusterGroup.setNew(true);
169                    clusterGroup.setPrimaryKey(clusterGroupId);
170    
171                    return clusterGroup;
172            }
173    
174            /**
175             * Removes the cluster group with the primary key from the database. Also notifies the appropriate model listeners.
176             *
177             * @param clusterGroupId the primary key of the cluster group
178             * @return the cluster group that was removed
179             * @throws com.liferay.portal.NoSuchClusterGroupException if a cluster group with the primary key could not be found
180             * @throws SystemException if a system exception occurred
181             */
182            public ClusterGroup remove(long clusterGroupId)
183                    throws NoSuchClusterGroupException, SystemException {
184                    return remove(Long.valueOf(clusterGroupId));
185            }
186    
187            /**
188             * Removes the cluster group with the primary key from the database. Also notifies the appropriate model listeners.
189             *
190             * @param primaryKey the primary key of the cluster group
191             * @return the cluster group that was removed
192             * @throws com.liferay.portal.NoSuchClusterGroupException if a cluster group with the primary key could not be found
193             * @throws SystemException if a system exception occurred
194             */
195            @Override
196            public ClusterGroup remove(Serializable primaryKey)
197                    throws NoSuchClusterGroupException, SystemException {
198                    Session session = null;
199    
200                    try {
201                            session = openSession();
202    
203                            ClusterGroup clusterGroup = (ClusterGroup)session.get(ClusterGroupImpl.class,
204                                            primaryKey);
205    
206                            if (clusterGroup == null) {
207                                    if (_log.isWarnEnabled()) {
208                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
209                                    }
210    
211                                    throw new NoSuchClusterGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
212                                            primaryKey);
213                            }
214    
215                            return remove(clusterGroup);
216                    }
217                    catch (NoSuchClusterGroupException nsee) {
218                            throw nsee;
219                    }
220                    catch (Exception e) {
221                            throw processException(e);
222                    }
223                    finally {
224                            closeSession(session);
225                    }
226            }
227    
228            @Override
229            protected ClusterGroup removeImpl(ClusterGroup clusterGroup)
230                    throws SystemException {
231                    clusterGroup = toUnwrappedModel(clusterGroup);
232    
233                    Session session = null;
234    
235                    try {
236                            session = openSession();
237    
238                            if (!session.contains(clusterGroup)) {
239                                    clusterGroup = (ClusterGroup)session.get(ClusterGroupImpl.class,
240                                                    clusterGroup.getPrimaryKeyObj());
241                            }
242    
243                            if (clusterGroup != null) {
244                                    session.delete(clusterGroup);
245                            }
246                    }
247                    catch (Exception e) {
248                            throw processException(e);
249                    }
250                    finally {
251                            closeSession(session);
252                    }
253    
254                    if (clusterGroup != null) {
255                            clearCache(clusterGroup);
256                    }
257    
258                    return clusterGroup;
259            }
260    
261            @Override
262            public ClusterGroup updateImpl(
263                    com.liferay.portal.model.ClusterGroup clusterGroup)
264                    throws SystemException {
265                    clusterGroup = toUnwrappedModel(clusterGroup);
266    
267                    boolean isNew = clusterGroup.isNew();
268    
269                    Session session = null;
270    
271                    try {
272                            session = openSession();
273    
274                            if (clusterGroup.isNew()) {
275                                    session.save(clusterGroup);
276    
277                                    clusterGroup.setNew(false);
278                            }
279                            else {
280                                    session.merge(clusterGroup);
281                            }
282                    }
283                    catch (Exception e) {
284                            throw processException(e);
285                    }
286                    finally {
287                            closeSession(session);
288                    }
289    
290                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
291    
292                    if (isNew) {
293                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
294                    }
295    
296                    EntityCacheUtil.putResult(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
297                            ClusterGroupImpl.class, clusterGroup.getPrimaryKey(), clusterGroup);
298    
299                    return clusterGroup;
300            }
301    
302            protected ClusterGroup toUnwrappedModel(ClusterGroup clusterGroup) {
303                    if (clusterGroup instanceof ClusterGroupImpl) {
304                            return clusterGroup;
305                    }
306    
307                    ClusterGroupImpl clusterGroupImpl = new ClusterGroupImpl();
308    
309                    clusterGroupImpl.setNew(clusterGroup.isNew());
310                    clusterGroupImpl.setPrimaryKey(clusterGroup.getPrimaryKey());
311    
312                    clusterGroupImpl.setClusterGroupId(clusterGroup.getClusterGroupId());
313                    clusterGroupImpl.setName(clusterGroup.getName());
314                    clusterGroupImpl.setClusterNodeIds(clusterGroup.getClusterNodeIds());
315                    clusterGroupImpl.setWholeCluster(clusterGroup.isWholeCluster());
316    
317                    return clusterGroupImpl;
318            }
319    
320            /**
321             * Returns the cluster group with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
322             *
323             * @param primaryKey the primary key of the cluster group
324             * @return the cluster group
325             * @throws com.liferay.portal.NoSuchModelException if a cluster group with the primary key could not be found
326             * @throws SystemException if a system exception occurred
327             */
328            @Override
329            public ClusterGroup findByPrimaryKey(Serializable primaryKey)
330                    throws NoSuchModelException, SystemException {
331                    return findByPrimaryKey(((Long)primaryKey).longValue());
332            }
333    
334            /**
335             * Returns the cluster group with the primary key or throws a {@link com.liferay.portal.NoSuchClusterGroupException} if it could not be found.
336             *
337             * @param clusterGroupId the primary key of the cluster group
338             * @return the cluster group
339             * @throws com.liferay.portal.NoSuchClusterGroupException if a cluster group with the primary key could not be found
340             * @throws SystemException if a system exception occurred
341             */
342            public ClusterGroup findByPrimaryKey(long clusterGroupId)
343                    throws NoSuchClusterGroupException, SystemException {
344                    ClusterGroup clusterGroup = fetchByPrimaryKey(clusterGroupId);
345    
346                    if (clusterGroup == null) {
347                            if (_log.isWarnEnabled()) {
348                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + clusterGroupId);
349                            }
350    
351                            throw new NoSuchClusterGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
352                                    clusterGroupId);
353                    }
354    
355                    return clusterGroup;
356            }
357    
358            /**
359             * Returns the cluster group with the primary key or returns <code>null</code> if it could not be found.
360             *
361             * @param primaryKey the primary key of the cluster group
362             * @return the cluster group, or <code>null</code> if a cluster group with the primary key could not be found
363             * @throws SystemException if a system exception occurred
364             */
365            @Override
366            public ClusterGroup fetchByPrimaryKey(Serializable primaryKey)
367                    throws SystemException {
368                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
369            }
370    
371            /**
372             * Returns the cluster group with the primary key or returns <code>null</code> if it could not be found.
373             *
374             * @param clusterGroupId the primary key of the cluster group
375             * @return the cluster group, or <code>null</code> if a cluster group with the primary key could not be found
376             * @throws SystemException if a system exception occurred
377             */
378            public ClusterGroup fetchByPrimaryKey(long clusterGroupId)
379                    throws SystemException {
380                    ClusterGroup clusterGroup = (ClusterGroup)EntityCacheUtil.getResult(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
381                                    ClusterGroupImpl.class, clusterGroupId);
382    
383                    if (clusterGroup == _nullClusterGroup) {
384                            return null;
385                    }
386    
387                    if (clusterGroup == null) {
388                            Session session = null;
389    
390                            try {
391                                    session = openSession();
392    
393                                    clusterGroup = (ClusterGroup)session.get(ClusterGroupImpl.class,
394                                                    Long.valueOf(clusterGroupId));
395    
396                                    if (clusterGroup != null) {
397                                            cacheResult(clusterGroup);
398                                    }
399                                    else {
400                                            EntityCacheUtil.putResult(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
401                                                    ClusterGroupImpl.class, clusterGroupId,
402                                                    _nullClusterGroup);
403                                    }
404                            }
405                            catch (Exception e) {
406                                    EntityCacheUtil.removeResult(ClusterGroupModelImpl.ENTITY_CACHE_ENABLED,
407                                            ClusterGroupImpl.class, clusterGroupId);
408    
409                                    throw processException(e);
410                            }
411                            finally {
412                                    closeSession(session);
413                            }
414                    }
415    
416                    return clusterGroup;
417            }
418    
419            /**
420             * Returns all the cluster groups.
421             *
422             * @return the cluster groups
423             * @throws SystemException if a system exception occurred
424             */
425            public List<ClusterGroup> findAll() throws SystemException {
426                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
427            }
428    
429            /**
430             * Returns a range of all the cluster groups.
431             *
432             * <p>
433             * 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.ClusterGroupModelImpl}. 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.
434             * </p>
435             *
436             * @param start the lower bound of the range of cluster groups
437             * @param end the upper bound of the range of cluster groups (not inclusive)
438             * @return the range of cluster groups
439             * @throws SystemException if a system exception occurred
440             */
441            public List<ClusterGroup> findAll(int start, int end)
442                    throws SystemException {
443                    return findAll(start, end, null);
444            }
445    
446            /**
447             * Returns an ordered range of all the cluster groups.
448             *
449             * <p>
450             * 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.ClusterGroupModelImpl}. 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.
451             * </p>
452             *
453             * @param start the lower bound of the range of cluster groups
454             * @param end the upper bound of the range of cluster groups (not inclusive)
455             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
456             * @return the ordered range of cluster groups
457             * @throws SystemException if a system exception occurred
458             */
459            public List<ClusterGroup> findAll(int start, int end,
460                    OrderByComparator orderByComparator) throws SystemException {
461                    boolean pagination = true;
462                    FinderPath finderPath = null;
463                    Object[] finderArgs = null;
464    
465                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
466                                    (orderByComparator == null)) {
467                            pagination = false;
468                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
469                            finderArgs = FINDER_ARGS_EMPTY;
470                    }
471                    else {
472                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
473                            finderArgs = new Object[] { start, end, orderByComparator };
474                    }
475    
476                    List<ClusterGroup> list = (List<ClusterGroup>)FinderCacheUtil.getResult(finderPath,
477                                    finderArgs, this);
478    
479                    if (list == null) {
480                            StringBundler query = null;
481                            String sql = null;
482    
483                            if (orderByComparator != null) {
484                                    query = new StringBundler(2 +
485                                                    (orderByComparator.getOrderByFields().length * 3));
486    
487                                    query.append(_SQL_SELECT_CLUSTERGROUP);
488    
489                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
490                                            orderByComparator);
491    
492                                    sql = query.toString();
493                            }
494                            else {
495                                    sql = _SQL_SELECT_CLUSTERGROUP;
496    
497                                    if (pagination) {
498                                            sql = sql.concat(ClusterGroupModelImpl.ORDER_BY_JPQL);
499                                    }
500                            }
501    
502                            Session session = null;
503    
504                            try {
505                                    session = openSession();
506    
507                                    Query q = session.createQuery(sql);
508    
509                                    if (!pagination) {
510                                            list = (List<ClusterGroup>)QueryUtil.list(q, getDialect(),
511                                                            start, end, false);
512    
513                                            Collections.sort(list);
514    
515                                            list = new UnmodifiableList<ClusterGroup>(list);
516                                    }
517                                    else {
518                                            list = (List<ClusterGroup>)QueryUtil.list(q, getDialect(),
519                                                            start, end);
520                                    }
521    
522                                    cacheResult(list);
523    
524                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
525                            }
526                            catch (Exception e) {
527                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
528    
529                                    throw processException(e);
530                            }
531                            finally {
532                                    closeSession(session);
533                            }
534                    }
535    
536                    return list;
537            }
538    
539            /**
540             * Removes all the cluster groups from the database.
541             *
542             * @throws SystemException if a system exception occurred
543             */
544            public void removeAll() throws SystemException {
545                    for (ClusterGroup clusterGroup : findAll()) {
546                            remove(clusterGroup);
547                    }
548            }
549    
550            /**
551             * Returns the number of cluster groups.
552             *
553             * @return the number of cluster groups
554             * @throws SystemException if a system exception occurred
555             */
556            public int countAll() throws SystemException {
557                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
558                                    FINDER_ARGS_EMPTY, this);
559    
560                    if (count == null) {
561                            Session session = null;
562    
563                            try {
564                                    session = openSession();
565    
566                                    Query q = session.createQuery(_SQL_COUNT_CLUSTERGROUP);
567    
568                                    count = (Long)q.uniqueResult();
569    
570                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
571                                            FINDER_ARGS_EMPTY, count);
572                            }
573                            catch (Exception e) {
574                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
575                                            FINDER_ARGS_EMPTY);
576    
577                                    throw processException(e);
578                            }
579                            finally {
580                                    closeSession(session);
581                            }
582                    }
583    
584                    return count.intValue();
585            }
586    
587            /**
588             * Initializes the cluster group persistence.
589             */
590            public void afterPropertiesSet() {
591                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
592                                            com.liferay.portal.util.PropsUtil.get(
593                                                    "value.object.listener.com.liferay.portal.model.ClusterGroup")));
594    
595                    if (listenerClassNames.length > 0) {
596                            try {
597                                    List<ModelListener<ClusterGroup>> listenersList = new ArrayList<ModelListener<ClusterGroup>>();
598    
599                                    for (String listenerClassName : listenerClassNames) {
600                                            listenersList.add((ModelListener<ClusterGroup>)InstanceFactory.newInstance(
601                                                            listenerClassName));
602                                    }
603    
604                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
605                            }
606                            catch (Exception e) {
607                                    _log.error(e);
608                            }
609                    }
610            }
611    
612            public void destroy() {
613                    EntityCacheUtil.removeCache(ClusterGroupImpl.class.getName());
614                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
615                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
616                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
617            }
618    
619            private static final String _SQL_SELECT_CLUSTERGROUP = "SELECT clusterGroup FROM ClusterGroup clusterGroup";
620            private static final String _SQL_COUNT_CLUSTERGROUP = "SELECT COUNT(clusterGroup) FROM ClusterGroup clusterGroup";
621            private static final String _ORDER_BY_ENTITY_ALIAS = "clusterGroup.";
622            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ClusterGroup exists with the primary key ";
623            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
624            private static Log _log = LogFactoryUtil.getLog(ClusterGroupPersistenceImpl.class);
625            private static ClusterGroup _nullClusterGroup = new ClusterGroupImpl() {
626                            @Override
627                            public Object clone() {
628                                    return this;
629                            }
630    
631                            @Override
632                            public CacheModel<ClusterGroup> toCacheModel() {
633                                    return _nullClusterGroupCacheModel;
634                            }
635                    };
636    
637            private static CacheModel<ClusterGroup> _nullClusterGroupCacheModel = new CacheModel<ClusterGroup>() {
638                            public ClusterGroup toEntityModel() {
639                                    return _nullClusterGroup;
640                            }
641                    };
642    }