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