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