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