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