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