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