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.NoSuchModelException;
018    import com.liferay.portal.NoSuchShardException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.model.Shard;
041    import com.liferay.portal.model.impl.ShardImpl;
042    import com.liferay.portal.model.impl.ShardModelImpl;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import java.io.Serializable;
046    
047    import java.util.ArrayList;
048    import java.util.Collections;
049    import java.util.List;
050    
051    /**
052     * The persistence implementation for the shard service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see ShardPersistence
060     * @see ShardUtil
061     * @generated
062     */
063    public class ShardPersistenceImpl extends BasePersistenceImpl<Shard>
064            implements ShardPersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link ShardUtil} to access the shard persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = ShardImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List1";
073            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List2";
075            public static final FinderPath FINDER_PATH_FETCH_BY_NAME = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
076                            ShardModelImpl.FINDER_CACHE_ENABLED, ShardImpl.class,
077                            FINDER_CLASS_NAME_ENTITY, "fetchByName",
078                            new String[] { String.class.getName() },
079                            ShardModelImpl.NAME_COLUMN_BITMASK);
080            public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
081                            ShardModelImpl.FINDER_CACHE_ENABLED, Long.class,
082                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName",
083                            new String[] { String.class.getName() });
084            public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
085                            ShardModelImpl.FINDER_CACHE_ENABLED, ShardImpl.class,
086                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
087                            new String[] { Long.class.getName(), Long.class.getName() },
088                            ShardModelImpl.CLASSNAMEID_COLUMN_BITMASK |
089                            ShardModelImpl.CLASSPK_COLUMN_BITMASK);
090            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
091                            ShardModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
093                            new String[] { Long.class.getName(), Long.class.getName() });
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
095                            ShardModelImpl.FINDER_CACHE_ENABLED, ShardImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
098                            ShardModelImpl.FINDER_CACHE_ENABLED, ShardImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
100            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShardModelImpl.ENTITY_CACHE_ENABLED,
101                            ShardModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
103    
104            /**
105             * Caches the shard in the entity cache if it is enabled.
106             *
107             * @param shard the shard
108             */
109            public void cacheResult(Shard shard) {
110                    EntityCacheUtil.putResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
111                            ShardImpl.class, shard.getPrimaryKey(), shard);
112    
113                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
114                            new Object[] { shard.getName() }, shard);
115    
116                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
117                            new Object[] {
118                                    Long.valueOf(shard.getClassNameId()),
119                                    Long.valueOf(shard.getClassPK())
120                            }, shard);
121    
122                    shard.resetOriginalValues();
123            }
124    
125            /**
126             * Caches the shards in the entity cache if it is enabled.
127             *
128             * @param shards the shards
129             */
130            public void cacheResult(List<Shard> shards) {
131                    for (Shard shard : shards) {
132                            if (EntityCacheUtil.getResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
133                                                    ShardImpl.class, shard.getPrimaryKey()) == null) {
134                                    cacheResult(shard);
135                            }
136                            else {
137                                    shard.resetOriginalValues();
138                            }
139                    }
140            }
141    
142            /**
143             * Clears the cache for all shards.
144             *
145             * <p>
146             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
147             * </p>
148             */
149            @Override
150            public void clearCache() {
151                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
152                            CacheRegistryUtil.clear(ShardImpl.class.getName());
153                    }
154    
155                    EntityCacheUtil.clearCache(ShardImpl.class.getName());
156    
157                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
158                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
159                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
160            }
161    
162            /**
163             * Clears the cache for the shard.
164             *
165             * <p>
166             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
167             * </p>
168             */
169            @Override
170            public void clearCache(Shard shard) {
171                    EntityCacheUtil.removeResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
172                            ShardImpl.class, shard.getPrimaryKey());
173    
174                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
175                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
176    
177                    clearUniqueFindersCache(shard);
178            }
179    
180            @Override
181            public void clearCache(List<Shard> shards) {
182                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
183                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
184    
185                    for (Shard shard : shards) {
186                            EntityCacheUtil.removeResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
187                                    ShardImpl.class, shard.getPrimaryKey());
188    
189                            clearUniqueFindersCache(shard);
190                    }
191            }
192    
193            protected void cacheUniqueFindersCache(Shard shard) {
194                    if (shard.isNew()) {
195                            Object[] args = new Object[] { shard.getName() };
196    
197                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME, args,
198                                    Long.valueOf(1));
199                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME, args, shard);
200    
201                            args = new Object[] {
202                                            Long.valueOf(shard.getClassNameId()),
203                                            Long.valueOf(shard.getClassPK())
204                                    };
205    
206                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
207                                    Long.valueOf(1));
208                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args, shard);
209                    }
210                    else {
211                            ShardModelImpl shardModelImpl = (ShardModelImpl)shard;
212    
213                            if ((shardModelImpl.getColumnBitmask() &
214                                            FINDER_PATH_FETCH_BY_NAME.getColumnBitmask()) != 0) {
215                                    Object[] args = new Object[] { shard.getName() };
216    
217                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME, args,
218                                            Long.valueOf(1));
219                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME, args, shard);
220                            }
221    
222                            if ((shardModelImpl.getColumnBitmask() &
223                                            FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
224                                    Object[] args = new Object[] {
225                                                    Long.valueOf(shard.getClassNameId()),
226                                                    Long.valueOf(shard.getClassPK())
227                                            };
228    
229                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
230                                            Long.valueOf(1));
231                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args, shard);
232                            }
233                    }
234            }
235    
236            protected void clearUniqueFindersCache(Shard shard) {
237                    ShardModelImpl shardModelImpl = (ShardModelImpl)shard;
238    
239                    Object[] args = new Object[] { shard.getName() };
240    
241                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
242                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME, args);
243    
244                    if ((shardModelImpl.getColumnBitmask() &
245                                    FINDER_PATH_FETCH_BY_NAME.getColumnBitmask()) != 0) {
246                            args = new Object[] { shardModelImpl.getOriginalName() };
247    
248                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
249                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME, args);
250                    }
251    
252                    args = new Object[] {
253                                    Long.valueOf(shard.getClassNameId()),
254                                    Long.valueOf(shard.getClassPK())
255                            };
256    
257                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
258                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
259    
260                    if ((shardModelImpl.getColumnBitmask() &
261                                    FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
262                            args = new Object[] {
263                                            Long.valueOf(shardModelImpl.getOriginalClassNameId()),
264                                            Long.valueOf(shardModelImpl.getOriginalClassPK())
265                                    };
266    
267                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
268                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
269                    }
270            }
271    
272            /**
273             * Creates a new shard with the primary key. Does not add the shard to the database.
274             *
275             * @param shardId the primary key for the new shard
276             * @return the new shard
277             */
278            public Shard create(long shardId) {
279                    Shard shard = new ShardImpl();
280    
281                    shard.setNew(true);
282                    shard.setPrimaryKey(shardId);
283    
284                    return shard;
285            }
286    
287            /**
288             * Removes the shard with the primary key from the database. Also notifies the appropriate model listeners.
289             *
290             * @param shardId the primary key of the shard
291             * @return the shard that was removed
292             * @throws com.liferay.portal.NoSuchShardException if a shard with the primary key could not be found
293             * @throws SystemException if a system exception occurred
294             */
295            public Shard remove(long shardId)
296                    throws NoSuchShardException, SystemException {
297                    return remove(Long.valueOf(shardId));
298            }
299    
300            /**
301             * Removes the shard with the primary key from the database. Also notifies the appropriate model listeners.
302             *
303             * @param primaryKey the primary key of the shard
304             * @return the shard that was removed
305             * @throws com.liferay.portal.NoSuchShardException if a shard with the primary key could not be found
306             * @throws SystemException if a system exception occurred
307             */
308            @Override
309            public Shard remove(Serializable primaryKey)
310                    throws NoSuchShardException, SystemException {
311                    Session session = null;
312    
313                    try {
314                            session = openSession();
315    
316                            Shard shard = (Shard)session.get(ShardImpl.class, primaryKey);
317    
318                            if (shard == null) {
319                                    if (_log.isWarnEnabled()) {
320                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
321                                    }
322    
323                                    throw new NoSuchShardException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
324                                            primaryKey);
325                            }
326    
327                            return remove(shard);
328                    }
329                    catch (NoSuchShardException nsee) {
330                            throw nsee;
331                    }
332                    catch (Exception e) {
333                            throw processException(e);
334                    }
335                    finally {
336                            closeSession(session);
337                    }
338            }
339    
340            @Override
341            protected Shard removeImpl(Shard shard) throws SystemException {
342                    shard = toUnwrappedModel(shard);
343    
344                    Session session = null;
345    
346                    try {
347                            session = openSession();
348    
349                            BatchSessionUtil.delete(session, shard);
350                    }
351                    catch (Exception e) {
352                            throw processException(e);
353                    }
354                    finally {
355                            closeSession(session);
356                    }
357    
358                    clearCache(shard);
359    
360                    return shard;
361            }
362    
363            @Override
364            public Shard updateImpl(com.liferay.portal.model.Shard shard, boolean merge)
365                    throws SystemException {
366                    shard = toUnwrappedModel(shard);
367    
368                    boolean isNew = shard.isNew();
369    
370                    Session session = null;
371    
372                    try {
373                            session = openSession();
374    
375                            BatchSessionUtil.update(session, shard, merge);
376    
377                            shard.setNew(false);
378                    }
379                    catch (Exception e) {
380                            throw processException(e);
381                    }
382                    finally {
383                            closeSession(session);
384                    }
385    
386                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
387    
388                    if (isNew || !ShardModelImpl.COLUMN_BITMASK_ENABLED) {
389                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
390                    }
391    
392                    EntityCacheUtil.putResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
393                            ShardImpl.class, shard.getPrimaryKey(), shard);
394    
395                    clearUniqueFindersCache(shard);
396                    cacheUniqueFindersCache(shard);
397    
398                    return shard;
399            }
400    
401            protected Shard toUnwrappedModel(Shard shard) {
402                    if (shard instanceof ShardImpl) {
403                            return shard;
404                    }
405    
406                    ShardImpl shardImpl = new ShardImpl();
407    
408                    shardImpl.setNew(shard.isNew());
409                    shardImpl.setPrimaryKey(shard.getPrimaryKey());
410    
411                    shardImpl.setShardId(shard.getShardId());
412                    shardImpl.setClassNameId(shard.getClassNameId());
413                    shardImpl.setClassPK(shard.getClassPK());
414                    shardImpl.setName(shard.getName());
415    
416                    return shardImpl;
417            }
418    
419            /**
420             * Returns the shard with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
421             *
422             * @param primaryKey the primary key of the shard
423             * @return the shard
424             * @throws com.liferay.portal.NoSuchModelException if a shard with the primary key could not be found
425             * @throws SystemException if a system exception occurred
426             */
427            @Override
428            public Shard findByPrimaryKey(Serializable primaryKey)
429                    throws NoSuchModelException, SystemException {
430                    return findByPrimaryKey(((Long)primaryKey).longValue());
431            }
432    
433            /**
434             * Returns the shard with the primary key or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found.
435             *
436             * @param shardId the primary key of the shard
437             * @return the shard
438             * @throws com.liferay.portal.NoSuchShardException if a shard with the primary key could not be found
439             * @throws SystemException if a system exception occurred
440             */
441            public Shard findByPrimaryKey(long shardId)
442                    throws NoSuchShardException, SystemException {
443                    Shard shard = fetchByPrimaryKey(shardId);
444    
445                    if (shard == null) {
446                            if (_log.isWarnEnabled()) {
447                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + shardId);
448                            }
449    
450                            throw new NoSuchShardException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
451                                    shardId);
452                    }
453    
454                    return shard;
455            }
456    
457            /**
458             * Returns the shard with the primary key or returns <code>null</code> if it could not be found.
459             *
460             * @param primaryKey the primary key of the shard
461             * @return the shard, or <code>null</code> if a shard with the primary key could not be found
462             * @throws SystemException if a system exception occurred
463             */
464            @Override
465            public Shard fetchByPrimaryKey(Serializable primaryKey)
466                    throws SystemException {
467                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
468            }
469    
470            /**
471             * Returns the shard with the primary key or returns <code>null</code> if it could not be found.
472             *
473             * @param shardId the primary key of the shard
474             * @return the shard, or <code>null</code> if a shard with the primary key could not be found
475             * @throws SystemException if a system exception occurred
476             */
477            public Shard fetchByPrimaryKey(long shardId) throws SystemException {
478                    Shard shard = (Shard)EntityCacheUtil.getResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
479                                    ShardImpl.class, shardId);
480    
481                    if (shard == _nullShard) {
482                            return null;
483                    }
484    
485                    if (shard == null) {
486                            Session session = null;
487    
488                            boolean hasException = false;
489    
490                            try {
491                                    session = openSession();
492    
493                                    shard = (Shard)session.get(ShardImpl.class,
494                                                    Long.valueOf(shardId));
495                            }
496                            catch (Exception e) {
497                                    hasException = true;
498    
499                                    throw processException(e);
500                            }
501                            finally {
502                                    if (shard != null) {
503                                            cacheResult(shard);
504                                    }
505                                    else if (!hasException) {
506                                            EntityCacheUtil.putResult(ShardModelImpl.ENTITY_CACHE_ENABLED,
507                                                    ShardImpl.class, shardId, _nullShard);
508                                    }
509    
510                                    closeSession(session);
511                            }
512                    }
513    
514                    return shard;
515            }
516    
517            /**
518             * Returns the shard where name = &#63; or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found.
519             *
520             * @param name the name
521             * @return the matching shard
522             * @throws com.liferay.portal.NoSuchShardException if a matching shard could not be found
523             * @throws SystemException if a system exception occurred
524             */
525            public Shard findByName(String name)
526                    throws NoSuchShardException, SystemException {
527                    Shard shard = fetchByName(name);
528    
529                    if (shard == null) {
530                            StringBundler msg = new StringBundler(4);
531    
532                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
533    
534                            msg.append("name=");
535                            msg.append(name);
536    
537                            msg.append(StringPool.CLOSE_CURLY_BRACE);
538    
539                            if (_log.isWarnEnabled()) {
540                                    _log.warn(msg.toString());
541                            }
542    
543                            throw new NoSuchShardException(msg.toString());
544                    }
545    
546                    return shard;
547            }
548    
549            /**
550             * Returns the shard where name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
551             *
552             * @param name the name
553             * @return the matching shard, or <code>null</code> if a matching shard could not be found
554             * @throws SystemException if a system exception occurred
555             */
556            public Shard fetchByName(String name) throws SystemException {
557                    return fetchByName(name, true);
558            }
559    
560            /**
561             * Returns the shard where name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
562             *
563             * @param name the name
564             * @param retrieveFromCache whether to use the finder cache
565             * @return the matching shard, or <code>null</code> if a matching shard could not be found
566             * @throws SystemException if a system exception occurred
567             */
568            public Shard fetchByName(String name, boolean retrieveFromCache)
569                    throws SystemException {
570                    Object[] finderArgs = new Object[] { name };
571    
572                    Object result = null;
573    
574                    if (retrieveFromCache) {
575                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_NAME,
576                                            finderArgs, this);
577                    }
578    
579                    if (result instanceof Shard) {
580                            Shard shard = (Shard)result;
581    
582                            if (!Validator.equals(name, shard.getName())) {
583                                    result = null;
584                            }
585                    }
586    
587                    if (result == null) {
588                            StringBundler query = new StringBundler(2);
589    
590                            query.append(_SQL_SELECT_SHARD_WHERE);
591    
592                            if (name == null) {
593                                    query.append(_FINDER_COLUMN_NAME_NAME_1);
594                            }
595                            else {
596                                    if (name.equals(StringPool.BLANK)) {
597                                            query.append(_FINDER_COLUMN_NAME_NAME_3);
598                                    }
599                                    else {
600                                            query.append(_FINDER_COLUMN_NAME_NAME_2);
601                                    }
602                            }
603    
604                            String sql = query.toString();
605    
606                            Session session = null;
607    
608                            try {
609                                    session = openSession();
610    
611                                    Query q = session.createQuery(sql);
612    
613                                    QueryPos qPos = QueryPos.getInstance(q);
614    
615                                    if (name != null) {
616                                            qPos.add(name);
617                                    }
618    
619                                    List<Shard> list = q.list();
620    
621                                    result = list;
622    
623                                    Shard shard = null;
624    
625                                    if (list.isEmpty()) {
626                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
627                                                    finderArgs, list);
628                                    }
629                                    else {
630                                            shard = list.get(0);
631    
632                                            cacheResult(shard);
633    
634                                            if ((shard.getName() == null) ||
635                                                            !shard.getName().equals(name)) {
636                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_NAME,
637                                                            finderArgs, shard);
638                                            }
639                                    }
640    
641                                    return shard;
642                            }
643                            catch (Exception e) {
644                                    throw processException(e);
645                            }
646                            finally {
647                                    if (result == null) {
648                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_NAME,
649                                                    finderArgs);
650                                    }
651    
652                                    closeSession(session);
653                            }
654                    }
655                    else {
656                            if (result instanceof List<?>) {
657                                    return null;
658                            }
659                            else {
660                                    return (Shard)result;
661                            }
662                    }
663            }
664    
665            /**
666             * Returns the shard where classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portal.NoSuchShardException} if it could not be found.
667             *
668             * @param classNameId the class name ID
669             * @param classPK the class p k
670             * @return the matching shard
671             * @throws com.liferay.portal.NoSuchShardException if a matching shard could not be found
672             * @throws SystemException if a system exception occurred
673             */
674            public Shard findByC_C(long classNameId, long classPK)
675                    throws NoSuchShardException, SystemException {
676                    Shard shard = fetchByC_C(classNameId, classPK);
677    
678                    if (shard == null) {
679                            StringBundler msg = new StringBundler(6);
680    
681                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
682    
683                            msg.append("classNameId=");
684                            msg.append(classNameId);
685    
686                            msg.append(", classPK=");
687                            msg.append(classPK);
688    
689                            msg.append(StringPool.CLOSE_CURLY_BRACE);
690    
691                            if (_log.isWarnEnabled()) {
692                                    _log.warn(msg.toString());
693                            }
694    
695                            throw new NoSuchShardException(msg.toString());
696                    }
697    
698                    return shard;
699            }
700    
701            /**
702             * Returns the shard where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
703             *
704             * @param classNameId the class name ID
705             * @param classPK the class p k
706             * @return the matching shard, or <code>null</code> if a matching shard could not be found
707             * @throws SystemException if a system exception occurred
708             */
709            public Shard fetchByC_C(long classNameId, long classPK)
710                    throws SystemException {
711                    return fetchByC_C(classNameId, classPK, true);
712            }
713    
714            /**
715             * Returns the shard where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
716             *
717             * @param classNameId the class name ID
718             * @param classPK the class p k
719             * @param retrieveFromCache whether to use the finder cache
720             * @return the matching shard, or <code>null</code> if a matching shard could not be found
721             * @throws SystemException if a system exception occurred
722             */
723            public Shard fetchByC_C(long classNameId, long classPK,
724                    boolean retrieveFromCache) throws SystemException {
725                    Object[] finderArgs = new Object[] { classNameId, classPK };
726    
727                    Object result = null;
728    
729                    if (retrieveFromCache) {
730                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
731                                            finderArgs, this);
732                    }
733    
734                    if (result instanceof Shard) {
735                            Shard shard = (Shard)result;
736    
737                            if ((classNameId != shard.getClassNameId()) ||
738                                            (classPK != shard.getClassPK())) {
739                                    result = null;
740                            }
741                    }
742    
743                    if (result == null) {
744                            StringBundler query = new StringBundler(3);
745    
746                            query.append(_SQL_SELECT_SHARD_WHERE);
747    
748                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
749    
750                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
751    
752                            String sql = query.toString();
753    
754                            Session session = null;
755    
756                            try {
757                                    session = openSession();
758    
759                                    Query q = session.createQuery(sql);
760    
761                                    QueryPos qPos = QueryPos.getInstance(q);
762    
763                                    qPos.add(classNameId);
764    
765                                    qPos.add(classPK);
766    
767                                    List<Shard> list = q.list();
768    
769                                    result = list;
770    
771                                    Shard shard = null;
772    
773                                    if (list.isEmpty()) {
774                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
775                                                    finderArgs, list);
776                                    }
777                                    else {
778                                            shard = list.get(0);
779    
780                                            cacheResult(shard);
781    
782                                            if ((shard.getClassNameId() != classNameId) ||
783                                                            (shard.getClassPK() != classPK)) {
784                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
785                                                            finderArgs, shard);
786                                            }
787                                    }
788    
789                                    return shard;
790                            }
791                            catch (Exception e) {
792                                    throw processException(e);
793                            }
794                            finally {
795                                    if (result == null) {
796                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
797                                                    finderArgs);
798                                    }
799    
800                                    closeSession(session);
801                            }
802                    }
803                    else {
804                            if (result instanceof List<?>) {
805                                    return null;
806                            }
807                            else {
808                                    return (Shard)result;
809                            }
810                    }
811            }
812    
813            /**
814             * Returns all the shards.
815             *
816             * @return the shards
817             * @throws SystemException if a system exception occurred
818             */
819            public List<Shard> findAll() throws SystemException {
820                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
821            }
822    
823            /**
824             * Returns a range of all the shards.
825             *
826             * <p>
827             * 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.
828             * </p>
829             *
830             * @param start the lower bound of the range of shards
831             * @param end the upper bound of the range of shards (not inclusive)
832             * @return the range of shards
833             * @throws SystemException if a system exception occurred
834             */
835            public List<Shard> findAll(int start, int end) throws SystemException {
836                    return findAll(start, end, null);
837            }
838    
839            /**
840             * Returns an ordered range of all the shards.
841             *
842             * <p>
843             * 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.
844             * </p>
845             *
846             * @param start the lower bound of the range of shards
847             * @param end the upper bound of the range of shards (not inclusive)
848             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
849             * @return the ordered range of shards
850             * @throws SystemException if a system exception occurred
851             */
852            public List<Shard> findAll(int start, int end,
853                    OrderByComparator orderByComparator) throws SystemException {
854                    FinderPath finderPath = null;
855                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
856    
857                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
858                                    (orderByComparator == null)) {
859                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
860                            finderArgs = FINDER_ARGS_EMPTY;
861                    }
862                    else {
863                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
864                            finderArgs = new Object[] { start, end, orderByComparator };
865                    }
866    
867                    List<Shard> list = (List<Shard>)FinderCacheUtil.getResult(finderPath,
868                                    finderArgs, this);
869    
870                    if (list == null) {
871                            StringBundler query = null;
872                            String sql = null;
873    
874                            if (orderByComparator != null) {
875                                    query = new StringBundler(2 +
876                                                    (orderByComparator.getOrderByFields().length * 3));
877    
878                                    query.append(_SQL_SELECT_SHARD);
879    
880                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
881                                            orderByComparator);
882    
883                                    sql = query.toString();
884                            }
885                            else {
886                                    sql = _SQL_SELECT_SHARD;
887                            }
888    
889                            Session session = null;
890    
891                            try {
892                                    session = openSession();
893    
894                                    Query q = session.createQuery(sql);
895    
896                                    if (orderByComparator == null) {
897                                            list = (List<Shard>)QueryUtil.list(q, getDialect(), start,
898                                                            end, false);
899    
900                                            Collections.sort(list);
901                                    }
902                                    else {
903                                            list = (List<Shard>)QueryUtil.list(q, getDialect(), start,
904                                                            end);
905                                    }
906                            }
907                            catch (Exception e) {
908                                    throw processException(e);
909                            }
910                            finally {
911                                    if (list == null) {
912                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
913                                    }
914                                    else {
915                                            cacheResult(list);
916    
917                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
918                                    }
919    
920                                    closeSession(session);
921                            }
922                    }
923    
924                    return list;
925            }
926    
927            /**
928             * Removes the shard where name = &#63; from the database.
929             *
930             * @param name the name
931             * @return the shard that was removed
932             * @throws SystemException if a system exception occurred
933             */
934            public Shard removeByName(String name)
935                    throws NoSuchShardException, SystemException {
936                    Shard shard = findByName(name);
937    
938                    return remove(shard);
939            }
940    
941            /**
942             * Removes the shard where classNameId = &#63; and classPK = &#63; from the database.
943             *
944             * @param classNameId the class name ID
945             * @param classPK the class p k
946             * @return the shard that was removed
947             * @throws SystemException if a system exception occurred
948             */
949            public Shard removeByC_C(long classNameId, long classPK)
950                    throws NoSuchShardException, SystemException {
951                    Shard shard = findByC_C(classNameId, classPK);
952    
953                    return remove(shard);
954            }
955    
956            /**
957             * Removes all the shards from the database.
958             *
959             * @throws SystemException if a system exception occurred
960             */
961            public void removeAll() throws SystemException {
962                    for (Shard shard : findAll()) {
963                            remove(shard);
964                    }
965            }
966    
967            /**
968             * Returns the number of shards where name = &#63;.
969             *
970             * @param name the name
971             * @return the number of matching shards
972             * @throws SystemException if a system exception occurred
973             */
974            public int countByName(String name) throws SystemException {
975                    Object[] finderArgs = new Object[] { name };
976    
977                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
978                                    finderArgs, this);
979    
980                    if (count == null) {
981                            StringBundler query = new StringBundler(2);
982    
983                            query.append(_SQL_COUNT_SHARD_WHERE);
984    
985                            if (name == null) {
986                                    query.append(_FINDER_COLUMN_NAME_NAME_1);
987                            }
988                            else {
989                                    if (name.equals(StringPool.BLANK)) {
990                                            query.append(_FINDER_COLUMN_NAME_NAME_3);
991                                    }
992                                    else {
993                                            query.append(_FINDER_COLUMN_NAME_NAME_2);
994                                    }
995                            }
996    
997                            String sql = query.toString();
998    
999                            Session session = null;
1000    
1001                            try {
1002                                    session = openSession();
1003    
1004                                    Query q = session.createQuery(sql);
1005    
1006                                    QueryPos qPos = QueryPos.getInstance(q);
1007    
1008                                    if (name != null) {
1009                                            qPos.add(name);
1010                                    }
1011    
1012                                    count = (Long)q.uniqueResult();
1013                            }
1014                            catch (Exception e) {
1015                                    throw processException(e);
1016                            }
1017                            finally {
1018                                    if (count == null) {
1019                                            count = Long.valueOf(0);
1020                                    }
1021    
1022                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
1023                                            finderArgs, count);
1024    
1025                                    closeSession(session);
1026                            }
1027                    }
1028    
1029                    return count.intValue();
1030            }
1031    
1032            /**
1033             * Returns the number of shards where classNameId = &#63; and classPK = &#63;.
1034             *
1035             * @param classNameId the class name ID
1036             * @param classPK the class p k
1037             * @return the number of matching shards
1038             * @throws SystemException if a system exception occurred
1039             */
1040            public int countByC_C(long classNameId, long classPK)
1041                    throws SystemException {
1042                    Object[] finderArgs = new Object[] { classNameId, classPK };
1043    
1044                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1045                                    finderArgs, this);
1046    
1047                    if (count == null) {
1048                            StringBundler query = new StringBundler(3);
1049    
1050                            query.append(_SQL_COUNT_SHARD_WHERE);
1051    
1052                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1053    
1054                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1055    
1056                            String sql = query.toString();
1057    
1058                            Session session = null;
1059    
1060                            try {
1061                                    session = openSession();
1062    
1063                                    Query q = session.createQuery(sql);
1064    
1065                                    QueryPos qPos = QueryPos.getInstance(q);
1066    
1067                                    qPos.add(classNameId);
1068    
1069                                    qPos.add(classPK);
1070    
1071                                    count = (Long)q.uniqueResult();
1072                            }
1073                            catch (Exception e) {
1074                                    throw processException(e);
1075                            }
1076                            finally {
1077                                    if (count == null) {
1078                                            count = Long.valueOf(0);
1079                                    }
1080    
1081                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1082                                            count);
1083    
1084                                    closeSession(session);
1085                            }
1086                    }
1087    
1088                    return count.intValue();
1089            }
1090    
1091            /**
1092             * Returns the number of shards.
1093             *
1094             * @return the number of shards
1095             * @throws SystemException if a system exception occurred
1096             */
1097            public int countAll() throws SystemException {
1098                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1099                                    FINDER_ARGS_EMPTY, this);
1100    
1101                    if (count == null) {
1102                            Session session = null;
1103    
1104                            try {
1105                                    session = openSession();
1106    
1107                                    Query q = session.createQuery(_SQL_COUNT_SHARD);
1108    
1109                                    count = (Long)q.uniqueResult();
1110                            }
1111                            catch (Exception e) {
1112                                    throw processException(e);
1113                            }
1114                            finally {
1115                                    if (count == null) {
1116                                            count = Long.valueOf(0);
1117                                    }
1118    
1119                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1120                                            FINDER_ARGS_EMPTY, count);
1121    
1122                                    closeSession(session);
1123                            }
1124                    }
1125    
1126                    return count.intValue();
1127            }
1128    
1129            /**
1130             * Initializes the shard persistence.
1131             */
1132            public void afterPropertiesSet() {
1133                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1134                                            com.liferay.portal.util.PropsUtil.get(
1135                                                    "value.object.listener.com.liferay.portal.model.Shard")));
1136    
1137                    if (listenerClassNames.length > 0) {
1138                            try {
1139                                    List<ModelListener<Shard>> listenersList = new ArrayList<ModelListener<Shard>>();
1140    
1141                                    for (String listenerClassName : listenerClassNames) {
1142                                            Class<?> clazz = getClass();
1143    
1144                                            listenersList.add((ModelListener<Shard>)InstanceFactory.newInstance(
1145                                                            clazz.getClassLoader(), listenerClassName));
1146                                    }
1147    
1148                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1149                            }
1150                            catch (Exception e) {
1151                                    _log.error(e);
1152                            }
1153                    }
1154            }
1155    
1156            public void destroy() {
1157                    EntityCacheUtil.removeCache(ShardImpl.class.getName());
1158                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1159                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1160            }
1161    
1162            @BeanReference(type = AccountPersistence.class)
1163            protected AccountPersistence accountPersistence;
1164            @BeanReference(type = AddressPersistence.class)
1165            protected AddressPersistence addressPersistence;
1166            @BeanReference(type = BrowserTrackerPersistence.class)
1167            protected BrowserTrackerPersistence browserTrackerPersistence;
1168            @BeanReference(type = ClassNamePersistence.class)
1169            protected ClassNamePersistence classNamePersistence;
1170            @BeanReference(type = ClusterGroupPersistence.class)
1171            protected ClusterGroupPersistence clusterGroupPersistence;
1172            @BeanReference(type = CompanyPersistence.class)
1173            protected CompanyPersistence companyPersistence;
1174            @BeanReference(type = ContactPersistence.class)
1175            protected ContactPersistence contactPersistence;
1176            @BeanReference(type = CountryPersistence.class)
1177            protected CountryPersistence countryPersistence;
1178            @BeanReference(type = EmailAddressPersistence.class)
1179            protected EmailAddressPersistence emailAddressPersistence;
1180            @BeanReference(type = GroupPersistence.class)
1181            protected GroupPersistence groupPersistence;
1182            @BeanReference(type = ImagePersistence.class)
1183            protected ImagePersistence imagePersistence;
1184            @BeanReference(type = LayoutPersistence.class)
1185            protected LayoutPersistence layoutPersistence;
1186            @BeanReference(type = LayoutBranchPersistence.class)
1187            protected LayoutBranchPersistence layoutBranchPersistence;
1188            @BeanReference(type = LayoutPrototypePersistence.class)
1189            protected LayoutPrototypePersistence layoutPrototypePersistence;
1190            @BeanReference(type = LayoutRevisionPersistence.class)
1191            protected LayoutRevisionPersistence layoutRevisionPersistence;
1192            @BeanReference(type = LayoutSetPersistence.class)
1193            protected LayoutSetPersistence layoutSetPersistence;
1194            @BeanReference(type = LayoutSetBranchPersistence.class)
1195            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1196            @BeanReference(type = LayoutSetPrototypePersistence.class)
1197            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1198            @BeanReference(type = ListTypePersistence.class)
1199            protected ListTypePersistence listTypePersistence;
1200            @BeanReference(type = LockPersistence.class)
1201            protected LockPersistence lockPersistence;
1202            @BeanReference(type = MembershipRequestPersistence.class)
1203            protected MembershipRequestPersistence membershipRequestPersistence;
1204            @BeanReference(type = OrganizationPersistence.class)
1205            protected OrganizationPersistence organizationPersistence;
1206            @BeanReference(type = OrgGroupPermissionPersistence.class)
1207            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1208            @BeanReference(type = OrgGroupRolePersistence.class)
1209            protected OrgGroupRolePersistence orgGroupRolePersistence;
1210            @BeanReference(type = OrgLaborPersistence.class)
1211            protected OrgLaborPersistence orgLaborPersistence;
1212            @BeanReference(type = PasswordPolicyPersistence.class)
1213            protected PasswordPolicyPersistence passwordPolicyPersistence;
1214            @BeanReference(type = PasswordPolicyRelPersistence.class)
1215            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1216            @BeanReference(type = PasswordTrackerPersistence.class)
1217            protected PasswordTrackerPersistence passwordTrackerPersistence;
1218            @BeanReference(type = PermissionPersistence.class)
1219            protected PermissionPersistence permissionPersistence;
1220            @BeanReference(type = PhonePersistence.class)
1221            protected PhonePersistence phonePersistence;
1222            @BeanReference(type = PluginSettingPersistence.class)
1223            protected PluginSettingPersistence pluginSettingPersistence;
1224            @BeanReference(type = PortalPreferencesPersistence.class)
1225            protected PortalPreferencesPersistence portalPreferencesPersistence;
1226            @BeanReference(type = PortletPersistence.class)
1227            protected PortletPersistence portletPersistence;
1228            @BeanReference(type = PortletItemPersistence.class)
1229            protected PortletItemPersistence portletItemPersistence;
1230            @BeanReference(type = PortletPreferencesPersistence.class)
1231            protected PortletPreferencesPersistence portletPreferencesPersistence;
1232            @BeanReference(type = RegionPersistence.class)
1233            protected RegionPersistence regionPersistence;
1234            @BeanReference(type = ReleasePersistence.class)
1235            protected ReleasePersistence releasePersistence;
1236            @BeanReference(type = RepositoryPersistence.class)
1237            protected RepositoryPersistence repositoryPersistence;
1238            @BeanReference(type = RepositoryEntryPersistence.class)
1239            protected RepositoryEntryPersistence repositoryEntryPersistence;
1240            @BeanReference(type = ResourcePersistence.class)
1241            protected ResourcePersistence resourcePersistence;
1242            @BeanReference(type = ResourceActionPersistence.class)
1243            protected ResourceActionPersistence resourceActionPersistence;
1244            @BeanReference(type = ResourceBlockPersistence.class)
1245            protected ResourceBlockPersistence resourceBlockPersistence;
1246            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1247            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1248            @BeanReference(type = ResourceCodePersistence.class)
1249            protected ResourceCodePersistence resourceCodePersistence;
1250            @BeanReference(type = ResourcePermissionPersistence.class)
1251            protected ResourcePermissionPersistence resourcePermissionPersistence;
1252            @BeanReference(type = ResourceTypePermissionPersistence.class)
1253            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1254            @BeanReference(type = RolePersistence.class)
1255            protected RolePersistence rolePersistence;
1256            @BeanReference(type = ServiceComponentPersistence.class)
1257            protected ServiceComponentPersistence serviceComponentPersistence;
1258            @BeanReference(type = ShardPersistence.class)
1259            protected ShardPersistence shardPersistence;
1260            @BeanReference(type = SubscriptionPersistence.class)
1261            protected SubscriptionPersistence subscriptionPersistence;
1262            @BeanReference(type = TeamPersistence.class)
1263            protected TeamPersistence teamPersistence;
1264            @BeanReference(type = TicketPersistence.class)
1265            protected TicketPersistence ticketPersistence;
1266            @BeanReference(type = UserPersistence.class)
1267            protected UserPersistence userPersistence;
1268            @BeanReference(type = UserGroupPersistence.class)
1269            protected UserGroupPersistence userGroupPersistence;
1270            @BeanReference(type = UserGroupGroupRolePersistence.class)
1271            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1272            @BeanReference(type = UserGroupRolePersistence.class)
1273            protected UserGroupRolePersistence userGroupRolePersistence;
1274            @BeanReference(type = UserIdMapperPersistence.class)
1275            protected UserIdMapperPersistence userIdMapperPersistence;
1276            @BeanReference(type = UserNotificationEventPersistence.class)
1277            protected UserNotificationEventPersistence userNotificationEventPersistence;
1278            @BeanReference(type = UserTrackerPersistence.class)
1279            protected UserTrackerPersistence userTrackerPersistence;
1280            @BeanReference(type = UserTrackerPathPersistence.class)
1281            protected UserTrackerPathPersistence userTrackerPathPersistence;
1282            @BeanReference(type = VirtualHostPersistence.class)
1283            protected VirtualHostPersistence virtualHostPersistence;
1284            @BeanReference(type = WebDAVPropsPersistence.class)
1285            protected WebDAVPropsPersistence webDAVPropsPersistence;
1286            @BeanReference(type = WebsitePersistence.class)
1287            protected WebsitePersistence websitePersistence;
1288            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1289            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1290            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1291            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1292            private static final String _SQL_SELECT_SHARD = "SELECT shard FROM Shard shard";
1293            private static final String _SQL_SELECT_SHARD_WHERE = "SELECT shard FROM Shard shard WHERE ";
1294            private static final String _SQL_COUNT_SHARD = "SELECT COUNT(shard) FROM Shard shard";
1295            private static final String _SQL_COUNT_SHARD_WHERE = "SELECT COUNT(shard) FROM Shard shard WHERE ";
1296            private static final String _FINDER_COLUMN_NAME_NAME_1 = "shard.name IS NULL";
1297            private static final String _FINDER_COLUMN_NAME_NAME_2 = "shard.name = ?";
1298            private static final String _FINDER_COLUMN_NAME_NAME_3 = "(shard.name IS NULL OR shard.name = ?)";
1299            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "shard.classNameId = ? AND ";
1300            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "shard.classPK = ?";
1301            private static final String _ORDER_BY_ENTITY_ALIAS = "shard.";
1302            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Shard exists with the primary key ";
1303            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Shard exists with the key {";
1304            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1305            private static Log _log = LogFactoryUtil.getLog(ShardPersistenceImpl.class);
1306            private static Shard _nullShard = new ShardImpl() {
1307                            @Override
1308                            public Object clone() {
1309                                    return this;
1310                            }
1311    
1312                            @Override
1313                            public CacheModel<Shard> toCacheModel() {
1314                                    return _nullShardCacheModel;
1315                            }
1316                    };
1317    
1318            private static CacheModel<Shard> _nullShardCacheModel = new CacheModel<Shard>() {
1319                            public Shard toEntityModel() {
1320                                    return _nullShard;
1321                            }
1322                    };
1323    }