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