001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchResourceCodeException;
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.ResourceCode;
041    import com.liferay.portal.model.impl.ResourceCodeImpl;
042    import com.liferay.portal.model.impl.ResourceCodeModelImpl;
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 resource code 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 ResourceCodePersistence
060     * @see ResourceCodeUtil
061     * @generated
062     */
063    public class ResourceCodePersistenceImpl extends BasePersistenceImpl<ResourceCode>
064            implements ResourceCodePersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link ResourceCodeUtil} to access the resource code persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = ResourceCodeImpl.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_WITH_PAGINATION_FIND_BY_COMPANYID =
076                    new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
077                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, ResourceCodeImpl.class,
078                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
079                            new String[] {
080                                    Long.class.getName(),
081                                    
082                            "java.lang.Integer", "java.lang.Integer",
083                                    "com.liferay.portal.kernel.util.OrderByComparator"
084                            });
085            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
086                    new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
087                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, ResourceCodeImpl.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
089                            new String[] { Long.class.getName() },
090                            ResourceCodeModelImpl.COMPANYID_COLUMN_BITMASK);
091            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
092                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
094                            new String[] { Long.class.getName() });
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
096                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, ResourceCodeImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByName",
098                            new String[] {
099                                    String.class.getName(),
100                                    
101                            "java.lang.Integer", "java.lang.Integer",
102                                    "com.liferay.portal.kernel.util.OrderByComparator"
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
105                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, ResourceCodeImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByName",
107                            new String[] { String.class.getName() },
108                            ResourceCodeModelImpl.NAME_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
110                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName",
112                            new String[] { String.class.getName() });
113            public static final FinderPath FINDER_PATH_FETCH_BY_C_N_S = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
114                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, ResourceCodeImpl.class,
115                            FINDER_CLASS_NAME_ENTITY, "fetchByC_N_S",
116                            new String[] {
117                                    Long.class.getName(), String.class.getName(),
118                                    Integer.class.getName()
119                            },
120                            ResourceCodeModelImpl.COMPANYID_COLUMN_BITMASK |
121                            ResourceCodeModelImpl.NAME_COLUMN_BITMASK |
122                            ResourceCodeModelImpl.SCOPE_COLUMN_BITMASK);
123            public static final FinderPath FINDER_PATH_COUNT_BY_C_N_S = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
124                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N_S",
126                            new String[] {
127                                    Long.class.getName(), String.class.getName(),
128                                    Integer.class.getName()
129                            });
130            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
131                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, ResourceCodeImpl.class,
132                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
133            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
134                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, ResourceCodeImpl.class,
135                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
136            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
137                            ResourceCodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
138                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
139    
140            /**
141             * Caches the resource code in the entity cache if it is enabled.
142             *
143             * @param resourceCode the resource code
144             */
145            public void cacheResult(ResourceCode resourceCode) {
146                    EntityCacheUtil.putResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
147                            ResourceCodeImpl.class, resourceCode.getPrimaryKey(), resourceCode);
148    
149                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
150                            new Object[] {
151                                    Long.valueOf(resourceCode.getCompanyId()),
152                                    
153                            resourceCode.getName(), Integer.valueOf(resourceCode.getScope())
154                            }, resourceCode);
155    
156                    resourceCode.resetOriginalValues();
157            }
158    
159            /**
160             * Caches the resource codes in the entity cache if it is enabled.
161             *
162             * @param resourceCodes the resource codes
163             */
164            public void cacheResult(List<ResourceCode> resourceCodes) {
165                    for (ResourceCode resourceCode : resourceCodes) {
166                            if (EntityCacheUtil.getResult(
167                                                    ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
168                                                    ResourceCodeImpl.class, resourceCode.getPrimaryKey()) == null) {
169                                    cacheResult(resourceCode);
170                            }
171                            else {
172                                    resourceCode.resetOriginalValues();
173                            }
174                    }
175            }
176    
177            /**
178             * Clears the cache for all resource codes.
179             *
180             * <p>
181             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
182             * </p>
183             */
184            @Override
185            public void clearCache() {
186                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
187                            CacheRegistryUtil.clear(ResourceCodeImpl.class.getName());
188                    }
189    
190                    EntityCacheUtil.clearCache(ResourceCodeImpl.class.getName());
191    
192                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
193                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
194                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
195            }
196    
197            /**
198             * Clears the cache for the resource code.
199             *
200             * <p>
201             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
202             * </p>
203             */
204            @Override
205            public void clearCache(ResourceCode resourceCode) {
206                    EntityCacheUtil.removeResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
207                            ResourceCodeImpl.class, resourceCode.getPrimaryKey());
208    
209                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
210                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
211    
212                    clearUniqueFindersCache(resourceCode);
213            }
214    
215            @Override
216            public void clearCache(List<ResourceCode> resourceCodes) {
217                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
218                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
219    
220                    for (ResourceCode resourceCode : resourceCodes) {
221                            EntityCacheUtil.removeResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
222                                    ResourceCodeImpl.class, resourceCode.getPrimaryKey());
223    
224                            clearUniqueFindersCache(resourceCode);
225                    }
226            }
227    
228            protected void clearUniqueFindersCache(ResourceCode resourceCode) {
229                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S,
230                            new Object[] {
231                                    Long.valueOf(resourceCode.getCompanyId()),
232                                    
233                            resourceCode.getName(), Integer.valueOf(resourceCode.getScope())
234                            });
235            }
236    
237            /**
238             * Creates a new resource code with the primary key. Does not add the resource code to the database.
239             *
240             * @param codeId the primary key for the new resource code
241             * @return the new resource code
242             */
243            public ResourceCode create(long codeId) {
244                    ResourceCode resourceCode = new ResourceCodeImpl();
245    
246                    resourceCode.setNew(true);
247                    resourceCode.setPrimaryKey(codeId);
248    
249                    return resourceCode;
250            }
251    
252            /**
253             * Removes the resource code with the primary key from the database. Also notifies the appropriate model listeners.
254             *
255             * @param codeId the primary key of the resource code
256             * @return the resource code that was removed
257             * @throws com.liferay.portal.NoSuchResourceCodeException if a resource code with the primary key could not be found
258             * @throws SystemException if a system exception occurred
259             */
260            public ResourceCode remove(long codeId)
261                    throws NoSuchResourceCodeException, SystemException {
262                    return remove(Long.valueOf(codeId));
263            }
264    
265            /**
266             * Removes the resource code with the primary key from the database. Also notifies the appropriate model listeners.
267             *
268             * @param primaryKey the primary key of the resource code
269             * @return the resource code that was removed
270             * @throws com.liferay.portal.NoSuchResourceCodeException if a resource code with the primary key could not be found
271             * @throws SystemException if a system exception occurred
272             */
273            @Override
274            public ResourceCode remove(Serializable primaryKey)
275                    throws NoSuchResourceCodeException, SystemException {
276                    Session session = null;
277    
278                    try {
279                            session = openSession();
280    
281                            ResourceCode resourceCode = (ResourceCode)session.get(ResourceCodeImpl.class,
282                                            primaryKey);
283    
284                            if (resourceCode == null) {
285                                    if (_log.isWarnEnabled()) {
286                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
287                                    }
288    
289                                    throw new NoSuchResourceCodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
290                                            primaryKey);
291                            }
292    
293                            return remove(resourceCode);
294                    }
295                    catch (NoSuchResourceCodeException nsee) {
296                            throw nsee;
297                    }
298                    catch (Exception e) {
299                            throw processException(e);
300                    }
301                    finally {
302                            closeSession(session);
303                    }
304            }
305    
306            @Override
307            protected ResourceCode removeImpl(ResourceCode resourceCode)
308                    throws SystemException {
309                    resourceCode = toUnwrappedModel(resourceCode);
310    
311                    Session session = null;
312    
313                    try {
314                            session = openSession();
315    
316                            BatchSessionUtil.delete(session, resourceCode);
317                    }
318                    catch (Exception e) {
319                            throw processException(e);
320                    }
321                    finally {
322                            closeSession(session);
323                    }
324    
325                    clearCache(resourceCode);
326    
327                    return resourceCode;
328            }
329    
330            @Override
331            public ResourceCode updateImpl(
332                    com.liferay.portal.model.ResourceCode resourceCode, boolean merge)
333                    throws SystemException {
334                    resourceCode = toUnwrappedModel(resourceCode);
335    
336                    boolean isNew = resourceCode.isNew();
337    
338                    ResourceCodeModelImpl resourceCodeModelImpl = (ResourceCodeModelImpl)resourceCode;
339    
340                    Session session = null;
341    
342                    try {
343                            session = openSession();
344    
345                            BatchSessionUtil.update(session, resourceCode, merge);
346    
347                            resourceCode.setNew(false);
348                    }
349                    catch (Exception e) {
350                            throw processException(e);
351                    }
352                    finally {
353                            closeSession(session);
354                    }
355    
356                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
357    
358                    if (isNew || !ResourceCodeModelImpl.COLUMN_BITMASK_ENABLED) {
359                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
360                    }
361    
362                    else {
363                            if ((resourceCodeModelImpl.getColumnBitmask() &
364                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
365                                    Object[] args = new Object[] {
366                                                    Long.valueOf(resourceCodeModelImpl.getOriginalCompanyId())
367                                            };
368    
369                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
370                                            args);
371                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
372                                            args);
373    
374                                    args = new Object[] {
375                                                    Long.valueOf(resourceCodeModelImpl.getCompanyId())
376                                            };
377    
378                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
379                                            args);
380                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
381                                            args);
382                            }
383    
384                            if ((resourceCodeModelImpl.getColumnBitmask() &
385                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME.getColumnBitmask()) != 0) {
386                                    Object[] args = new Object[] {
387                                                    resourceCodeModelImpl.getOriginalName()
388                                            };
389    
390                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
391                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
392                                            args);
393    
394                                    args = new Object[] { resourceCodeModelImpl.getName() };
395    
396                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_NAME, args);
397                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME,
398                                            args);
399                            }
400                    }
401    
402                    EntityCacheUtil.putResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
403                            ResourceCodeImpl.class, resourceCode.getPrimaryKey(), resourceCode);
404    
405                    if (isNew) {
406                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
407                                    new Object[] {
408                                            Long.valueOf(resourceCode.getCompanyId()),
409                                            
410                                    resourceCode.getName(), Integer.valueOf(resourceCode.getScope())
411                                    }, resourceCode);
412                    }
413                    else {
414                            if ((resourceCodeModelImpl.getColumnBitmask() &
415                                            FINDER_PATH_FETCH_BY_C_N_S.getColumnBitmask()) != 0) {
416                                    Object[] args = new Object[] {
417                                                    Long.valueOf(resourceCodeModelImpl.getOriginalCompanyId()),
418                                                    
419                                                    resourceCodeModelImpl.getOriginalName(),
420                                                    Integer.valueOf(resourceCodeModelImpl.getOriginalScope())
421                                            };
422    
423                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N_S, args);
424    
425                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S, args);
426    
427                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
428                                            new Object[] {
429                                                    Long.valueOf(resourceCode.getCompanyId()),
430                                                    
431                                            resourceCode.getName(),
432                                                    Integer.valueOf(resourceCode.getScope())
433                                            }, resourceCode);
434                            }
435                    }
436    
437                    return resourceCode;
438            }
439    
440            protected ResourceCode toUnwrappedModel(ResourceCode resourceCode) {
441                    if (resourceCode instanceof ResourceCodeImpl) {
442                            return resourceCode;
443                    }
444    
445                    ResourceCodeImpl resourceCodeImpl = new ResourceCodeImpl();
446    
447                    resourceCodeImpl.setNew(resourceCode.isNew());
448                    resourceCodeImpl.setPrimaryKey(resourceCode.getPrimaryKey());
449    
450                    resourceCodeImpl.setCodeId(resourceCode.getCodeId());
451                    resourceCodeImpl.setCompanyId(resourceCode.getCompanyId());
452                    resourceCodeImpl.setName(resourceCode.getName());
453                    resourceCodeImpl.setScope(resourceCode.getScope());
454    
455                    return resourceCodeImpl;
456            }
457    
458            /**
459             * Returns the resource code with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
460             *
461             * @param primaryKey the primary key of the resource code
462             * @return the resource code
463             * @throws com.liferay.portal.NoSuchModelException if a resource code with the primary key could not be found
464             * @throws SystemException if a system exception occurred
465             */
466            @Override
467            public ResourceCode findByPrimaryKey(Serializable primaryKey)
468                    throws NoSuchModelException, SystemException {
469                    return findByPrimaryKey(((Long)primaryKey).longValue());
470            }
471    
472            /**
473             * Returns the resource code with the primary key or throws a {@link com.liferay.portal.NoSuchResourceCodeException} if it could not be found.
474             *
475             * @param codeId the primary key of the resource code
476             * @return the resource code
477             * @throws com.liferay.portal.NoSuchResourceCodeException if a resource code with the primary key could not be found
478             * @throws SystemException if a system exception occurred
479             */
480            public ResourceCode findByPrimaryKey(long codeId)
481                    throws NoSuchResourceCodeException, SystemException {
482                    ResourceCode resourceCode = fetchByPrimaryKey(codeId);
483    
484                    if (resourceCode == null) {
485                            if (_log.isWarnEnabled()) {
486                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + codeId);
487                            }
488    
489                            throw new NoSuchResourceCodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
490                                    codeId);
491                    }
492    
493                    return resourceCode;
494            }
495    
496            /**
497             * Returns the resource code with the primary key or returns <code>null</code> if it could not be found.
498             *
499             * @param primaryKey the primary key of the resource code
500             * @return the resource code, or <code>null</code> if a resource code with the primary key could not be found
501             * @throws SystemException if a system exception occurred
502             */
503            @Override
504            public ResourceCode fetchByPrimaryKey(Serializable primaryKey)
505                    throws SystemException {
506                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
507            }
508    
509            /**
510             * Returns the resource code with the primary key or returns <code>null</code> if it could not be found.
511             *
512             * @param codeId the primary key of the resource code
513             * @return the resource code, or <code>null</code> if a resource code with the primary key could not be found
514             * @throws SystemException if a system exception occurred
515             */
516            public ResourceCode fetchByPrimaryKey(long codeId)
517                    throws SystemException {
518                    ResourceCode resourceCode = (ResourceCode)EntityCacheUtil.getResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
519                                    ResourceCodeImpl.class, codeId);
520    
521                    if (resourceCode == _nullResourceCode) {
522                            return null;
523                    }
524    
525                    if (resourceCode == null) {
526                            Session session = null;
527    
528                            boolean hasException = false;
529    
530                            try {
531                                    session = openSession();
532    
533                                    resourceCode = (ResourceCode)session.get(ResourceCodeImpl.class,
534                                                    Long.valueOf(codeId));
535                            }
536                            catch (Exception e) {
537                                    hasException = true;
538    
539                                    throw processException(e);
540                            }
541                            finally {
542                                    if (resourceCode != null) {
543                                            cacheResult(resourceCode);
544                                    }
545                                    else if (!hasException) {
546                                            EntityCacheUtil.putResult(ResourceCodeModelImpl.ENTITY_CACHE_ENABLED,
547                                                    ResourceCodeImpl.class, codeId, _nullResourceCode);
548                                    }
549    
550                                    closeSession(session);
551                            }
552                    }
553    
554                    return resourceCode;
555            }
556    
557            /**
558             * Returns all the resource codes where companyId = &#63;.
559             *
560             * @param companyId the company ID
561             * @return the matching resource codes
562             * @throws SystemException if a system exception occurred
563             */
564            public List<ResourceCode> findByCompanyId(long companyId)
565                    throws SystemException {
566                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
567                            null);
568            }
569    
570            /**
571             * Returns a range of all the resource codes where companyId = &#63;.
572             *
573             * <p>
574             * 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.
575             * </p>
576             *
577             * @param companyId the company ID
578             * @param start the lower bound of the range of resource codes
579             * @param end the upper bound of the range of resource codes (not inclusive)
580             * @return the range of matching resource codes
581             * @throws SystemException if a system exception occurred
582             */
583            public List<ResourceCode> findByCompanyId(long companyId, int start, int end)
584                    throws SystemException {
585                    return findByCompanyId(companyId, start, end, null);
586            }
587    
588            /**
589             * Returns an ordered range of all the resource codes where companyId = &#63;.
590             *
591             * <p>
592             * 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.
593             * </p>
594             *
595             * @param companyId the company ID
596             * @param start the lower bound of the range of resource codes
597             * @param end the upper bound of the range of resource codes (not inclusive)
598             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
599             * @return the ordered range of matching resource codes
600             * @throws SystemException if a system exception occurred
601             */
602            public List<ResourceCode> findByCompanyId(long companyId, int start,
603                    int end, OrderByComparator orderByComparator) throws SystemException {
604                    FinderPath finderPath = null;
605                    Object[] finderArgs = null;
606    
607                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
608                                    (orderByComparator == null)) {
609                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
610                            finderArgs = new Object[] { companyId };
611                    }
612                    else {
613                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
614                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
615                    }
616    
617                    List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(finderPath,
618                                    finderArgs, this);
619    
620                    if ((list != null) && !list.isEmpty()) {
621                            for (ResourceCode resourceCode : list) {
622                                    if ((companyId != resourceCode.getCompanyId())) {
623                                            list = null;
624    
625                                            break;
626                                    }
627                            }
628                    }
629    
630                    if (list == null) {
631                            StringBundler query = null;
632    
633                            if (orderByComparator != null) {
634                                    query = new StringBundler(3 +
635                                                    (orderByComparator.getOrderByFields().length * 3));
636                            }
637                            else {
638                                    query = new StringBundler(2);
639                            }
640    
641                            query.append(_SQL_SELECT_RESOURCECODE_WHERE);
642    
643                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
644    
645                            if (orderByComparator != null) {
646                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
647                                            orderByComparator);
648                            }
649    
650                            String sql = query.toString();
651    
652                            Session session = null;
653    
654                            try {
655                                    session = openSession();
656    
657                                    Query q = session.createQuery(sql);
658    
659                                    QueryPos qPos = QueryPos.getInstance(q);
660    
661                                    qPos.add(companyId);
662    
663                                    list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
664                                                    start, end);
665                            }
666                            catch (Exception e) {
667                                    throw processException(e);
668                            }
669                            finally {
670                                    if (list == null) {
671                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
672                                    }
673                                    else {
674                                            cacheResult(list);
675    
676                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
677                                    }
678    
679                                    closeSession(session);
680                            }
681                    }
682    
683                    return list;
684            }
685    
686            /**
687             * Returns the first resource code in the ordered set where companyId = &#63;.
688             *
689             * @param companyId the company ID
690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
691             * @return the first matching resource code
692             * @throws com.liferay.portal.NoSuchResourceCodeException if a matching resource code could not be found
693             * @throws SystemException if a system exception occurred
694             */
695            public ResourceCode findByCompanyId_First(long companyId,
696                    OrderByComparator orderByComparator)
697                    throws NoSuchResourceCodeException, SystemException {
698                    ResourceCode resourceCode = fetchByCompanyId_First(companyId,
699                                    orderByComparator);
700    
701                    if (resourceCode != null) {
702                            return resourceCode;
703                    }
704    
705                    StringBundler msg = new StringBundler(4);
706    
707                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
708    
709                    msg.append("companyId=");
710                    msg.append(companyId);
711    
712                    msg.append(StringPool.CLOSE_CURLY_BRACE);
713    
714                    throw new NoSuchResourceCodeException(msg.toString());
715            }
716    
717            /**
718             * Returns the first resource code in the ordered set where companyId = &#63;.
719             *
720             * @param companyId the company ID
721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
722             * @return the first matching resource code, or <code>null</code> if a matching resource code could not be found
723             * @throws SystemException if a system exception occurred
724             */
725            public ResourceCode fetchByCompanyId_First(long companyId,
726                    OrderByComparator orderByComparator) throws SystemException {
727                    List<ResourceCode> list = findByCompanyId(companyId, 0, 1,
728                                    orderByComparator);
729    
730                    if (!list.isEmpty()) {
731                            return list.get(0);
732                    }
733    
734                    return null;
735            }
736    
737            /**
738             * Returns the last resource code in the ordered set where companyId = &#63;.
739             *
740             * @param companyId the company ID
741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
742             * @return the last matching resource code
743             * @throws com.liferay.portal.NoSuchResourceCodeException if a matching resource code could not be found
744             * @throws SystemException if a system exception occurred
745             */
746            public ResourceCode findByCompanyId_Last(long companyId,
747                    OrderByComparator orderByComparator)
748                    throws NoSuchResourceCodeException, SystemException {
749                    ResourceCode resourceCode = fetchByCompanyId_Last(companyId,
750                                    orderByComparator);
751    
752                    if (resourceCode != null) {
753                            return resourceCode;
754                    }
755    
756                    StringBundler msg = new StringBundler(4);
757    
758                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
759    
760                    msg.append("companyId=");
761                    msg.append(companyId);
762    
763                    msg.append(StringPool.CLOSE_CURLY_BRACE);
764    
765                    throw new NoSuchResourceCodeException(msg.toString());
766            }
767    
768            /**
769             * Returns the last resource code in the ordered set where companyId = &#63;.
770             *
771             * @param companyId the company ID
772             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
773             * @return the last matching resource code, or <code>null</code> if a matching resource code could not be found
774             * @throws SystemException if a system exception occurred
775             */
776            public ResourceCode fetchByCompanyId_Last(long companyId,
777                    OrderByComparator orderByComparator) throws SystemException {
778                    int count = countByCompanyId(companyId);
779    
780                    List<ResourceCode> list = findByCompanyId(companyId, count - 1, count,
781                                    orderByComparator);
782    
783                    if (!list.isEmpty()) {
784                            return list.get(0);
785                    }
786    
787                    return null;
788            }
789    
790            /**
791             * Returns the resource codes before and after the current resource code in the ordered set where companyId = &#63;.
792             *
793             * @param codeId the primary key of the current resource code
794             * @param companyId the company ID
795             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
796             * @return the previous, current, and next resource code
797             * @throws com.liferay.portal.NoSuchResourceCodeException if a resource code with the primary key could not be found
798             * @throws SystemException if a system exception occurred
799             */
800            public ResourceCode[] findByCompanyId_PrevAndNext(long codeId,
801                    long companyId, OrderByComparator orderByComparator)
802                    throws NoSuchResourceCodeException, SystemException {
803                    ResourceCode resourceCode = findByPrimaryKey(codeId);
804    
805                    Session session = null;
806    
807                    try {
808                            session = openSession();
809    
810                            ResourceCode[] array = new ResourceCodeImpl[3];
811    
812                            array[0] = getByCompanyId_PrevAndNext(session, resourceCode,
813                                            companyId, orderByComparator, true);
814    
815                            array[1] = resourceCode;
816    
817                            array[2] = getByCompanyId_PrevAndNext(session, resourceCode,
818                                            companyId, orderByComparator, false);
819    
820                            return array;
821                    }
822                    catch (Exception e) {
823                            throw processException(e);
824                    }
825                    finally {
826                            closeSession(session);
827                    }
828            }
829    
830            protected ResourceCode getByCompanyId_PrevAndNext(Session session,
831                    ResourceCode resourceCode, long companyId,
832                    OrderByComparator orderByComparator, boolean previous) {
833                    StringBundler query = null;
834    
835                    if (orderByComparator != null) {
836                            query = new StringBundler(6 +
837                                            (orderByComparator.getOrderByFields().length * 6));
838                    }
839                    else {
840                            query = new StringBundler(3);
841                    }
842    
843                    query.append(_SQL_SELECT_RESOURCECODE_WHERE);
844    
845                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
846    
847                    if (orderByComparator != null) {
848                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
849    
850                            if (orderByConditionFields.length > 0) {
851                                    query.append(WHERE_AND);
852                            }
853    
854                            for (int i = 0; i < orderByConditionFields.length; i++) {
855                                    query.append(_ORDER_BY_ENTITY_ALIAS);
856                                    query.append(orderByConditionFields[i]);
857    
858                                    if ((i + 1) < orderByConditionFields.length) {
859                                            if (orderByComparator.isAscending() ^ previous) {
860                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
861                                            }
862                                            else {
863                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
864                                            }
865                                    }
866                                    else {
867                                            if (orderByComparator.isAscending() ^ previous) {
868                                                    query.append(WHERE_GREATER_THAN);
869                                            }
870                                            else {
871                                                    query.append(WHERE_LESSER_THAN);
872                                            }
873                                    }
874                            }
875    
876                            query.append(ORDER_BY_CLAUSE);
877    
878                            String[] orderByFields = orderByComparator.getOrderByFields();
879    
880                            for (int i = 0; i < orderByFields.length; i++) {
881                                    query.append(_ORDER_BY_ENTITY_ALIAS);
882                                    query.append(orderByFields[i]);
883    
884                                    if ((i + 1) < orderByFields.length) {
885                                            if (orderByComparator.isAscending() ^ previous) {
886                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
887                                            }
888                                            else {
889                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
890                                            }
891                                    }
892                                    else {
893                                            if (orderByComparator.isAscending() ^ previous) {
894                                                    query.append(ORDER_BY_ASC);
895                                            }
896                                            else {
897                                                    query.append(ORDER_BY_DESC);
898                                            }
899                                    }
900                            }
901                    }
902    
903                    String sql = query.toString();
904    
905                    Query q = session.createQuery(sql);
906    
907                    q.setFirstResult(0);
908                    q.setMaxResults(2);
909    
910                    QueryPos qPos = QueryPos.getInstance(q);
911    
912                    qPos.add(companyId);
913    
914                    if (orderByComparator != null) {
915                            Object[] values = orderByComparator.getOrderByConditionValues(resourceCode);
916    
917                            for (Object value : values) {
918                                    qPos.add(value);
919                            }
920                    }
921    
922                    List<ResourceCode> list = q.list();
923    
924                    if (list.size() == 2) {
925                            return list.get(1);
926                    }
927                    else {
928                            return null;
929                    }
930            }
931    
932            /**
933             * Returns all the resource codes where name = &#63;.
934             *
935             * @param name the name
936             * @return the matching resource codes
937             * @throws SystemException if a system exception occurred
938             */
939            public List<ResourceCode> findByName(String name) throws SystemException {
940                    return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
941            }
942    
943            /**
944             * Returns a range of all the resource codes where name = &#63;.
945             *
946             * <p>
947             * 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.
948             * </p>
949             *
950             * @param name the name
951             * @param start the lower bound of the range of resource codes
952             * @param end the upper bound of the range of resource codes (not inclusive)
953             * @return the range of matching resource codes
954             * @throws SystemException if a system exception occurred
955             */
956            public List<ResourceCode> findByName(String name, int start, int end)
957                    throws SystemException {
958                    return findByName(name, start, end, null);
959            }
960    
961            /**
962             * Returns an ordered range of all the resource codes where name = &#63;.
963             *
964             * <p>
965             * 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.
966             * </p>
967             *
968             * @param name the name
969             * @param start the lower bound of the range of resource codes
970             * @param end the upper bound of the range of resource codes (not inclusive)
971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
972             * @return the ordered range of matching resource codes
973             * @throws SystemException if a system exception occurred
974             */
975            public List<ResourceCode> findByName(String name, int start, int end,
976                    OrderByComparator orderByComparator) throws SystemException {
977                    FinderPath finderPath = null;
978                    Object[] finderArgs = null;
979    
980                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
981                                    (orderByComparator == null)) {
982                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_NAME;
983                            finderArgs = new Object[] { name };
984                    }
985                    else {
986                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_NAME;
987                            finderArgs = new Object[] { name, start, end, orderByComparator };
988                    }
989    
990                    List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(finderPath,
991                                    finderArgs, this);
992    
993                    if ((list != null) && !list.isEmpty()) {
994                            for (ResourceCode resourceCode : list) {
995                                    if (!Validator.equals(name, resourceCode.getName())) {
996                                            list = null;
997    
998                                            break;
999                                    }
1000                            }
1001                    }
1002    
1003                    if (list == null) {
1004                            StringBundler query = null;
1005    
1006                            if (orderByComparator != null) {
1007                                    query = new StringBundler(3 +
1008                                                    (orderByComparator.getOrderByFields().length * 3));
1009                            }
1010                            else {
1011                                    query = new StringBundler(2);
1012                            }
1013    
1014                            query.append(_SQL_SELECT_RESOURCECODE_WHERE);
1015    
1016                            if (name == null) {
1017                                    query.append(_FINDER_COLUMN_NAME_NAME_1);
1018                            }
1019                            else {
1020                                    if (name.equals(StringPool.BLANK)) {
1021                                            query.append(_FINDER_COLUMN_NAME_NAME_3);
1022                                    }
1023                                    else {
1024                                            query.append(_FINDER_COLUMN_NAME_NAME_2);
1025                                    }
1026                            }
1027    
1028                            if (orderByComparator != null) {
1029                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1030                                            orderByComparator);
1031                            }
1032    
1033                            String sql = query.toString();
1034    
1035                            Session session = null;
1036    
1037                            try {
1038                                    session = openSession();
1039    
1040                                    Query q = session.createQuery(sql);
1041    
1042                                    QueryPos qPos = QueryPos.getInstance(q);
1043    
1044                                    if (name != null) {
1045                                            qPos.add(name);
1046                                    }
1047    
1048                                    list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
1049                                                    start, end);
1050                            }
1051                            catch (Exception e) {
1052                                    throw processException(e);
1053                            }
1054                            finally {
1055                                    if (list == null) {
1056                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1057                                    }
1058                                    else {
1059                                            cacheResult(list);
1060    
1061                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1062                                    }
1063    
1064                                    closeSession(session);
1065                            }
1066                    }
1067    
1068                    return list;
1069            }
1070    
1071            /**
1072             * Returns the first resource code in the ordered set where name = &#63;.
1073             *
1074             * @param name the name
1075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1076             * @return the first matching resource code
1077             * @throws com.liferay.portal.NoSuchResourceCodeException if a matching resource code could not be found
1078             * @throws SystemException if a system exception occurred
1079             */
1080            public ResourceCode findByName_First(String name,
1081                    OrderByComparator orderByComparator)
1082                    throws NoSuchResourceCodeException, SystemException {
1083                    ResourceCode resourceCode = fetchByName_First(name, orderByComparator);
1084    
1085                    if (resourceCode != null) {
1086                            return resourceCode;
1087                    }
1088    
1089                    StringBundler msg = new StringBundler(4);
1090    
1091                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1092    
1093                    msg.append("name=");
1094                    msg.append(name);
1095    
1096                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1097    
1098                    throw new NoSuchResourceCodeException(msg.toString());
1099            }
1100    
1101            /**
1102             * Returns the first resource code in the ordered set where name = &#63;.
1103             *
1104             * @param name the name
1105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1106             * @return the first matching resource code, or <code>null</code> if a matching resource code could not be found
1107             * @throws SystemException if a system exception occurred
1108             */
1109            public ResourceCode fetchByName_First(String name,
1110                    OrderByComparator orderByComparator) throws SystemException {
1111                    List<ResourceCode> list = findByName(name, 0, 1, orderByComparator);
1112    
1113                    if (!list.isEmpty()) {
1114                            return list.get(0);
1115                    }
1116    
1117                    return null;
1118            }
1119    
1120            /**
1121             * Returns the last resource code in the ordered set where name = &#63;.
1122             *
1123             * @param name the name
1124             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1125             * @return the last matching resource code
1126             * @throws com.liferay.portal.NoSuchResourceCodeException if a matching resource code could not be found
1127             * @throws SystemException if a system exception occurred
1128             */
1129            public ResourceCode findByName_Last(String name,
1130                    OrderByComparator orderByComparator)
1131                    throws NoSuchResourceCodeException, SystemException {
1132                    ResourceCode resourceCode = fetchByName_Last(name, orderByComparator);
1133    
1134                    if (resourceCode != null) {
1135                            return resourceCode;
1136                    }
1137    
1138                    StringBundler msg = new StringBundler(4);
1139    
1140                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1141    
1142                    msg.append("name=");
1143                    msg.append(name);
1144    
1145                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1146    
1147                    throw new NoSuchResourceCodeException(msg.toString());
1148            }
1149    
1150            /**
1151             * Returns the last resource code in the ordered set where name = &#63;.
1152             *
1153             * @param name the name
1154             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1155             * @return the last matching resource code, or <code>null</code> if a matching resource code could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            public ResourceCode fetchByName_Last(String name,
1159                    OrderByComparator orderByComparator) throws SystemException {
1160                    int count = countByName(name);
1161    
1162                    List<ResourceCode> list = findByName(name, count - 1, count,
1163                                    orderByComparator);
1164    
1165                    if (!list.isEmpty()) {
1166                            return list.get(0);
1167                    }
1168    
1169                    return null;
1170            }
1171    
1172            /**
1173             * Returns the resource codes before and after the current resource code in the ordered set where name = &#63;.
1174             *
1175             * @param codeId the primary key of the current resource code
1176             * @param name the name
1177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1178             * @return the previous, current, and next resource code
1179             * @throws com.liferay.portal.NoSuchResourceCodeException if a resource code with the primary key could not be found
1180             * @throws SystemException if a system exception occurred
1181             */
1182            public ResourceCode[] findByName_PrevAndNext(long codeId, String name,
1183                    OrderByComparator orderByComparator)
1184                    throws NoSuchResourceCodeException, SystemException {
1185                    ResourceCode resourceCode = findByPrimaryKey(codeId);
1186    
1187                    Session session = null;
1188    
1189                    try {
1190                            session = openSession();
1191    
1192                            ResourceCode[] array = new ResourceCodeImpl[3];
1193    
1194                            array[0] = getByName_PrevAndNext(session, resourceCode, name,
1195                                            orderByComparator, true);
1196    
1197                            array[1] = resourceCode;
1198    
1199                            array[2] = getByName_PrevAndNext(session, resourceCode, name,
1200                                            orderByComparator, false);
1201    
1202                            return array;
1203                    }
1204                    catch (Exception e) {
1205                            throw processException(e);
1206                    }
1207                    finally {
1208                            closeSession(session);
1209                    }
1210            }
1211    
1212            protected ResourceCode getByName_PrevAndNext(Session session,
1213                    ResourceCode resourceCode, String name,
1214                    OrderByComparator orderByComparator, boolean previous) {
1215                    StringBundler query = null;
1216    
1217                    if (orderByComparator != null) {
1218                            query = new StringBundler(6 +
1219                                            (orderByComparator.getOrderByFields().length * 6));
1220                    }
1221                    else {
1222                            query = new StringBundler(3);
1223                    }
1224    
1225                    query.append(_SQL_SELECT_RESOURCECODE_WHERE);
1226    
1227                    if (name == null) {
1228                            query.append(_FINDER_COLUMN_NAME_NAME_1);
1229                    }
1230                    else {
1231                            if (name.equals(StringPool.BLANK)) {
1232                                    query.append(_FINDER_COLUMN_NAME_NAME_3);
1233                            }
1234                            else {
1235                                    query.append(_FINDER_COLUMN_NAME_NAME_2);
1236                            }
1237                    }
1238    
1239                    if (orderByComparator != null) {
1240                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1241    
1242                            if (orderByConditionFields.length > 0) {
1243                                    query.append(WHERE_AND);
1244                            }
1245    
1246                            for (int i = 0; i < orderByConditionFields.length; i++) {
1247                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1248                                    query.append(orderByConditionFields[i]);
1249    
1250                                    if ((i + 1) < orderByConditionFields.length) {
1251                                            if (orderByComparator.isAscending() ^ previous) {
1252                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1253                                            }
1254                                            else {
1255                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1256                                            }
1257                                    }
1258                                    else {
1259                                            if (orderByComparator.isAscending() ^ previous) {
1260                                                    query.append(WHERE_GREATER_THAN);
1261                                            }
1262                                            else {
1263                                                    query.append(WHERE_LESSER_THAN);
1264                                            }
1265                                    }
1266                            }
1267    
1268                            query.append(ORDER_BY_CLAUSE);
1269    
1270                            String[] orderByFields = orderByComparator.getOrderByFields();
1271    
1272                            for (int i = 0; i < orderByFields.length; i++) {
1273                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1274                                    query.append(orderByFields[i]);
1275    
1276                                    if ((i + 1) < orderByFields.length) {
1277                                            if (orderByComparator.isAscending() ^ previous) {
1278                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1279                                            }
1280                                            else {
1281                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1282                                            }
1283                                    }
1284                                    else {
1285                                            if (orderByComparator.isAscending() ^ previous) {
1286                                                    query.append(ORDER_BY_ASC);
1287                                            }
1288                                            else {
1289                                                    query.append(ORDER_BY_DESC);
1290                                            }
1291                                    }
1292                            }
1293                    }
1294    
1295                    String sql = query.toString();
1296    
1297                    Query q = session.createQuery(sql);
1298    
1299                    q.setFirstResult(0);
1300                    q.setMaxResults(2);
1301    
1302                    QueryPos qPos = QueryPos.getInstance(q);
1303    
1304                    if (name != null) {
1305                            qPos.add(name);
1306                    }
1307    
1308                    if (orderByComparator != null) {
1309                            Object[] values = orderByComparator.getOrderByConditionValues(resourceCode);
1310    
1311                            for (Object value : values) {
1312                                    qPos.add(value);
1313                            }
1314                    }
1315    
1316                    List<ResourceCode> list = q.list();
1317    
1318                    if (list.size() == 2) {
1319                            return list.get(1);
1320                    }
1321                    else {
1322                            return null;
1323                    }
1324            }
1325    
1326            /**
1327             * Returns the resource code where companyId = &#63; and name = &#63; and scope = &#63; or throws a {@link com.liferay.portal.NoSuchResourceCodeException} if it could not be found.
1328             *
1329             * @param companyId the company ID
1330             * @param name the name
1331             * @param scope the scope
1332             * @return the matching resource code
1333             * @throws com.liferay.portal.NoSuchResourceCodeException if a matching resource code could not be found
1334             * @throws SystemException if a system exception occurred
1335             */
1336            public ResourceCode findByC_N_S(long companyId, String name, int scope)
1337                    throws NoSuchResourceCodeException, SystemException {
1338                    ResourceCode resourceCode = fetchByC_N_S(companyId, name, scope);
1339    
1340                    if (resourceCode == null) {
1341                            StringBundler msg = new StringBundler(8);
1342    
1343                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1344    
1345                            msg.append("companyId=");
1346                            msg.append(companyId);
1347    
1348                            msg.append(", name=");
1349                            msg.append(name);
1350    
1351                            msg.append(", scope=");
1352                            msg.append(scope);
1353    
1354                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1355    
1356                            if (_log.isWarnEnabled()) {
1357                                    _log.warn(msg.toString());
1358                            }
1359    
1360                            throw new NoSuchResourceCodeException(msg.toString());
1361                    }
1362    
1363                    return resourceCode;
1364            }
1365    
1366            /**
1367             * Returns the resource code where companyId = &#63; and name = &#63; and scope = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1368             *
1369             * @param companyId the company ID
1370             * @param name the name
1371             * @param scope the scope
1372             * @return the matching resource code, or <code>null</code> if a matching resource code could not be found
1373             * @throws SystemException if a system exception occurred
1374             */
1375            public ResourceCode fetchByC_N_S(long companyId, String name, int scope)
1376                    throws SystemException {
1377                    return fetchByC_N_S(companyId, name, scope, true);
1378            }
1379    
1380            /**
1381             * Returns the resource code where companyId = &#63; and name = &#63; and scope = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1382             *
1383             * @param companyId the company ID
1384             * @param name the name
1385             * @param scope the scope
1386             * @param retrieveFromCache whether to use the finder cache
1387             * @return the matching resource code, or <code>null</code> if a matching resource code could not be found
1388             * @throws SystemException if a system exception occurred
1389             */
1390            public ResourceCode fetchByC_N_S(long companyId, String name, int scope,
1391                    boolean retrieveFromCache) throws SystemException {
1392                    Object[] finderArgs = new Object[] { companyId, name, scope };
1393    
1394                    Object result = null;
1395    
1396                    if (retrieveFromCache) {
1397                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N_S,
1398                                            finderArgs, this);
1399                    }
1400    
1401                    if (result instanceof ResourceCode) {
1402                            ResourceCode resourceCode = (ResourceCode)result;
1403    
1404                            if ((companyId != resourceCode.getCompanyId()) ||
1405                                            !Validator.equals(name, resourceCode.getName()) ||
1406                                            (scope != resourceCode.getScope())) {
1407                                    result = null;
1408                            }
1409                    }
1410    
1411                    if (result == null) {
1412                            StringBundler query = new StringBundler(4);
1413    
1414                            query.append(_SQL_SELECT_RESOURCECODE_WHERE);
1415    
1416                            query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
1417    
1418                            if (name == null) {
1419                                    query.append(_FINDER_COLUMN_C_N_S_NAME_1);
1420                            }
1421                            else {
1422                                    if (name.equals(StringPool.BLANK)) {
1423                                            query.append(_FINDER_COLUMN_C_N_S_NAME_3);
1424                                    }
1425                                    else {
1426                                            query.append(_FINDER_COLUMN_C_N_S_NAME_2);
1427                                    }
1428                            }
1429    
1430                            query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
1431    
1432                            String sql = query.toString();
1433    
1434                            Session session = null;
1435    
1436                            try {
1437                                    session = openSession();
1438    
1439                                    Query q = session.createQuery(sql);
1440    
1441                                    QueryPos qPos = QueryPos.getInstance(q);
1442    
1443                                    qPos.add(companyId);
1444    
1445                                    if (name != null) {
1446                                            qPos.add(name);
1447                                    }
1448    
1449                                    qPos.add(scope);
1450    
1451                                    List<ResourceCode> list = q.list();
1452    
1453                                    result = list;
1454    
1455                                    ResourceCode resourceCode = null;
1456    
1457                                    if (list.isEmpty()) {
1458                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
1459                                                    finderArgs, list);
1460                                    }
1461                                    else {
1462                                            resourceCode = list.get(0);
1463    
1464                                            cacheResult(resourceCode);
1465    
1466                                            if ((resourceCode.getCompanyId() != companyId) ||
1467                                                            (resourceCode.getName() == null) ||
1468                                                            !resourceCode.getName().equals(name) ||
1469                                                            (resourceCode.getScope() != scope)) {
1470                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S,
1471                                                            finderArgs, resourceCode);
1472                                            }
1473                                    }
1474    
1475                                    return resourceCode;
1476                            }
1477                            catch (Exception e) {
1478                                    throw processException(e);
1479                            }
1480                            finally {
1481                                    if (result == null) {
1482                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S,
1483                                                    finderArgs);
1484                                    }
1485    
1486                                    closeSession(session);
1487                            }
1488                    }
1489                    else {
1490                            if (result instanceof List<?>) {
1491                                    return null;
1492                            }
1493                            else {
1494                                    return (ResourceCode)result;
1495                            }
1496                    }
1497            }
1498    
1499            /**
1500             * Returns all the resource codes.
1501             *
1502             * @return the resource codes
1503             * @throws SystemException if a system exception occurred
1504             */
1505            public List<ResourceCode> findAll() throws SystemException {
1506                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1507            }
1508    
1509            /**
1510             * Returns a range of all the resource codes.
1511             *
1512             * <p>
1513             * 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.
1514             * </p>
1515             *
1516             * @param start the lower bound of the range of resource codes
1517             * @param end the upper bound of the range of resource codes (not inclusive)
1518             * @return the range of resource codes
1519             * @throws SystemException if a system exception occurred
1520             */
1521            public List<ResourceCode> findAll(int start, int end)
1522                    throws SystemException {
1523                    return findAll(start, end, null);
1524            }
1525    
1526            /**
1527             * Returns an ordered range of all the resource codes.
1528             *
1529             * <p>
1530             * 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.
1531             * </p>
1532             *
1533             * @param start the lower bound of the range of resource codes
1534             * @param end the upper bound of the range of resource codes (not inclusive)
1535             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1536             * @return the ordered range of resource codes
1537             * @throws SystemException if a system exception occurred
1538             */
1539            public List<ResourceCode> findAll(int start, int end,
1540                    OrderByComparator orderByComparator) throws SystemException {
1541                    FinderPath finderPath = null;
1542                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1543    
1544                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1545                                    (orderByComparator == null)) {
1546                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1547                            finderArgs = FINDER_ARGS_EMPTY;
1548                    }
1549                    else {
1550                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1551                            finderArgs = new Object[] { start, end, orderByComparator };
1552                    }
1553    
1554                    List<ResourceCode> list = (List<ResourceCode>)FinderCacheUtil.getResult(finderPath,
1555                                    finderArgs, this);
1556    
1557                    if (list == null) {
1558                            StringBundler query = null;
1559                            String sql = null;
1560    
1561                            if (orderByComparator != null) {
1562                                    query = new StringBundler(2 +
1563                                                    (orderByComparator.getOrderByFields().length * 3));
1564    
1565                                    query.append(_SQL_SELECT_RESOURCECODE);
1566    
1567                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1568                                            orderByComparator);
1569    
1570                                    sql = query.toString();
1571                            }
1572                            else {
1573                                    sql = _SQL_SELECT_RESOURCECODE;
1574                            }
1575    
1576                            Session session = null;
1577    
1578                            try {
1579                                    session = openSession();
1580    
1581                                    Query q = session.createQuery(sql);
1582    
1583                                    if (orderByComparator == null) {
1584                                            list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
1585                                                            start, end, false);
1586    
1587                                            Collections.sort(list);
1588                                    }
1589                                    else {
1590                                            list = (List<ResourceCode>)QueryUtil.list(q, getDialect(),
1591                                                            start, end);
1592                                    }
1593                            }
1594                            catch (Exception e) {
1595                                    throw processException(e);
1596                            }
1597                            finally {
1598                                    if (list == null) {
1599                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1600                                    }
1601                                    else {
1602                                            cacheResult(list);
1603    
1604                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1605                                    }
1606    
1607                                    closeSession(session);
1608                            }
1609                    }
1610    
1611                    return list;
1612            }
1613    
1614            /**
1615             * Removes all the resource codes where companyId = &#63; from the database.
1616             *
1617             * @param companyId the company ID
1618             * @throws SystemException if a system exception occurred
1619             */
1620            public void removeByCompanyId(long companyId) throws SystemException {
1621                    for (ResourceCode resourceCode : findByCompanyId(companyId)) {
1622                            remove(resourceCode);
1623                    }
1624            }
1625    
1626            /**
1627             * Removes all the resource codes where name = &#63; from the database.
1628             *
1629             * @param name the name
1630             * @throws SystemException if a system exception occurred
1631             */
1632            public void removeByName(String name) throws SystemException {
1633                    for (ResourceCode resourceCode : findByName(name)) {
1634                            remove(resourceCode);
1635                    }
1636            }
1637    
1638            /**
1639             * Removes the resource code where companyId = &#63; and name = &#63; and scope = &#63; from the database.
1640             *
1641             * @param companyId the company ID
1642             * @param name the name
1643             * @param scope the scope
1644             * @return the resource code that was removed
1645             * @throws SystemException if a system exception occurred
1646             */
1647            public ResourceCode removeByC_N_S(long companyId, String name, int scope)
1648                    throws NoSuchResourceCodeException, SystemException {
1649                    ResourceCode resourceCode = findByC_N_S(companyId, name, scope);
1650    
1651                    return remove(resourceCode);
1652            }
1653    
1654            /**
1655             * Removes all the resource codes from the database.
1656             *
1657             * @throws SystemException if a system exception occurred
1658             */
1659            public void removeAll() throws SystemException {
1660                    for (ResourceCode resourceCode : findAll()) {
1661                            remove(resourceCode);
1662                    }
1663            }
1664    
1665            /**
1666             * Returns the number of resource codes where companyId = &#63;.
1667             *
1668             * @param companyId the company ID
1669             * @return the number of matching resource codes
1670             * @throws SystemException if a system exception occurred
1671             */
1672            public int countByCompanyId(long companyId) throws SystemException {
1673                    Object[] finderArgs = new Object[] { companyId };
1674    
1675                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1676                                    finderArgs, this);
1677    
1678                    if (count == null) {
1679                            StringBundler query = new StringBundler(2);
1680    
1681                            query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1682    
1683                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1684    
1685                            String sql = query.toString();
1686    
1687                            Session session = null;
1688    
1689                            try {
1690                                    session = openSession();
1691    
1692                                    Query q = session.createQuery(sql);
1693    
1694                                    QueryPos qPos = QueryPos.getInstance(q);
1695    
1696                                    qPos.add(companyId);
1697    
1698                                    count = (Long)q.uniqueResult();
1699                            }
1700                            catch (Exception e) {
1701                                    throw processException(e);
1702                            }
1703                            finally {
1704                                    if (count == null) {
1705                                            count = Long.valueOf(0);
1706                                    }
1707    
1708                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1709                                            finderArgs, count);
1710    
1711                                    closeSession(session);
1712                            }
1713                    }
1714    
1715                    return count.intValue();
1716            }
1717    
1718            /**
1719             * Returns the number of resource codes where name = &#63;.
1720             *
1721             * @param name the name
1722             * @return the number of matching resource codes
1723             * @throws SystemException if a system exception occurred
1724             */
1725            public int countByName(String name) throws SystemException {
1726                    Object[] finderArgs = new Object[] { name };
1727    
1728                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
1729                                    finderArgs, this);
1730    
1731                    if (count == null) {
1732                            StringBundler query = new StringBundler(2);
1733    
1734                            query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1735    
1736                            if (name == null) {
1737                                    query.append(_FINDER_COLUMN_NAME_NAME_1);
1738                            }
1739                            else {
1740                                    if (name.equals(StringPool.BLANK)) {
1741                                            query.append(_FINDER_COLUMN_NAME_NAME_3);
1742                                    }
1743                                    else {
1744                                            query.append(_FINDER_COLUMN_NAME_NAME_2);
1745                                    }
1746                            }
1747    
1748                            String sql = query.toString();
1749    
1750                            Session session = null;
1751    
1752                            try {
1753                                    session = openSession();
1754    
1755                                    Query q = session.createQuery(sql);
1756    
1757                                    QueryPos qPos = QueryPos.getInstance(q);
1758    
1759                                    if (name != null) {
1760                                            qPos.add(name);
1761                                    }
1762    
1763                                    count = (Long)q.uniqueResult();
1764                            }
1765                            catch (Exception e) {
1766                                    throw processException(e);
1767                            }
1768                            finally {
1769                                    if (count == null) {
1770                                            count = Long.valueOf(0);
1771                                    }
1772    
1773                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
1774                                            finderArgs, count);
1775    
1776                                    closeSession(session);
1777                            }
1778                    }
1779    
1780                    return count.intValue();
1781            }
1782    
1783            /**
1784             * Returns the number of resource codes where companyId = &#63; and name = &#63; and scope = &#63;.
1785             *
1786             * @param companyId the company ID
1787             * @param name the name
1788             * @param scope the scope
1789             * @return the number of matching resource codes
1790             * @throws SystemException if a system exception occurred
1791             */
1792            public int countByC_N_S(long companyId, String name, int scope)
1793                    throws SystemException {
1794                    Object[] finderArgs = new Object[] { companyId, name, scope };
1795    
1796                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N_S,
1797                                    finderArgs, this);
1798    
1799                    if (count == null) {
1800                            StringBundler query = new StringBundler(4);
1801    
1802                            query.append(_SQL_COUNT_RESOURCECODE_WHERE);
1803    
1804                            query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
1805    
1806                            if (name == null) {
1807                                    query.append(_FINDER_COLUMN_C_N_S_NAME_1);
1808                            }
1809                            else {
1810                                    if (name.equals(StringPool.BLANK)) {
1811                                            query.append(_FINDER_COLUMN_C_N_S_NAME_3);
1812                                    }
1813                                    else {
1814                                            query.append(_FINDER_COLUMN_C_N_S_NAME_2);
1815                                    }
1816                            }
1817    
1818                            query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
1819    
1820                            String sql = query.toString();
1821    
1822                            Session session = null;
1823    
1824                            try {
1825                                    session = openSession();
1826    
1827                                    Query q = session.createQuery(sql);
1828    
1829                                    QueryPos qPos = QueryPos.getInstance(q);
1830    
1831                                    qPos.add(companyId);
1832    
1833                                    if (name != null) {
1834                                            qPos.add(name);
1835                                    }
1836    
1837                                    qPos.add(scope);
1838    
1839                                    count = (Long)q.uniqueResult();
1840                            }
1841                            catch (Exception e) {
1842                                    throw processException(e);
1843                            }
1844                            finally {
1845                                    if (count == null) {
1846                                            count = Long.valueOf(0);
1847                                    }
1848    
1849                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N_S,
1850                                            finderArgs, count);
1851    
1852                                    closeSession(session);
1853                            }
1854                    }
1855    
1856                    return count.intValue();
1857            }
1858    
1859            /**
1860             * Returns the number of resource codes.
1861             *
1862             * @return the number of resource codes
1863             * @throws SystemException if a system exception occurred
1864             */
1865            public int countAll() throws SystemException {
1866                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1867                                    FINDER_ARGS_EMPTY, this);
1868    
1869                    if (count == null) {
1870                            Session session = null;
1871    
1872                            try {
1873                                    session = openSession();
1874    
1875                                    Query q = session.createQuery(_SQL_COUNT_RESOURCECODE);
1876    
1877                                    count = (Long)q.uniqueResult();
1878                            }
1879                            catch (Exception e) {
1880                                    throw processException(e);
1881                            }
1882                            finally {
1883                                    if (count == null) {
1884                                            count = Long.valueOf(0);
1885                                    }
1886    
1887                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1888                                            FINDER_ARGS_EMPTY, count);
1889    
1890                                    closeSession(session);
1891                            }
1892                    }
1893    
1894                    return count.intValue();
1895            }
1896    
1897            /**
1898             * Initializes the resource code persistence.
1899             */
1900            public void afterPropertiesSet() {
1901                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1902                                            com.liferay.portal.util.PropsUtil.get(
1903                                                    "value.object.listener.com.liferay.portal.model.ResourceCode")));
1904    
1905                    if (listenerClassNames.length > 0) {
1906                            try {
1907                                    List<ModelListener<ResourceCode>> listenersList = new ArrayList<ModelListener<ResourceCode>>();
1908    
1909                                    for (String listenerClassName : listenerClassNames) {
1910                                            listenersList.add((ModelListener<ResourceCode>)InstanceFactory.newInstance(
1911                                                            listenerClassName));
1912                                    }
1913    
1914                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1915                            }
1916                            catch (Exception e) {
1917                                    _log.error(e);
1918                            }
1919                    }
1920            }
1921    
1922            public void destroy() {
1923                    EntityCacheUtil.removeCache(ResourceCodeImpl.class.getName());
1924                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1925                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1926            }
1927    
1928            @BeanReference(type = AccountPersistence.class)
1929            protected AccountPersistence accountPersistence;
1930            @BeanReference(type = AddressPersistence.class)
1931            protected AddressPersistence addressPersistence;
1932            @BeanReference(type = BrowserTrackerPersistence.class)
1933            protected BrowserTrackerPersistence browserTrackerPersistence;
1934            @BeanReference(type = ClassNamePersistence.class)
1935            protected ClassNamePersistence classNamePersistence;
1936            @BeanReference(type = ClusterGroupPersistence.class)
1937            protected ClusterGroupPersistence clusterGroupPersistence;
1938            @BeanReference(type = CompanyPersistence.class)
1939            protected CompanyPersistence companyPersistence;
1940            @BeanReference(type = ContactPersistence.class)
1941            protected ContactPersistence contactPersistence;
1942            @BeanReference(type = CountryPersistence.class)
1943            protected CountryPersistence countryPersistence;
1944            @BeanReference(type = EmailAddressPersistence.class)
1945            protected EmailAddressPersistence emailAddressPersistence;
1946            @BeanReference(type = GroupPersistence.class)
1947            protected GroupPersistence groupPersistence;
1948            @BeanReference(type = ImagePersistence.class)
1949            protected ImagePersistence imagePersistence;
1950            @BeanReference(type = LayoutPersistence.class)
1951            protected LayoutPersistence layoutPersistence;
1952            @BeanReference(type = LayoutBranchPersistence.class)
1953            protected LayoutBranchPersistence layoutBranchPersistence;
1954            @BeanReference(type = LayoutPrototypePersistence.class)
1955            protected LayoutPrototypePersistence layoutPrototypePersistence;
1956            @BeanReference(type = LayoutRevisionPersistence.class)
1957            protected LayoutRevisionPersistence layoutRevisionPersistence;
1958            @BeanReference(type = LayoutSetPersistence.class)
1959            protected LayoutSetPersistence layoutSetPersistence;
1960            @BeanReference(type = LayoutSetBranchPersistence.class)
1961            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1962            @BeanReference(type = LayoutSetPrototypePersistence.class)
1963            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1964            @BeanReference(type = ListTypePersistence.class)
1965            protected ListTypePersistence listTypePersistence;
1966            @BeanReference(type = LockPersistence.class)
1967            protected LockPersistence lockPersistence;
1968            @BeanReference(type = MembershipRequestPersistence.class)
1969            protected MembershipRequestPersistence membershipRequestPersistence;
1970            @BeanReference(type = OrganizationPersistence.class)
1971            protected OrganizationPersistence organizationPersistence;
1972            @BeanReference(type = OrgGroupPermissionPersistence.class)
1973            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1974            @BeanReference(type = OrgGroupRolePersistence.class)
1975            protected OrgGroupRolePersistence orgGroupRolePersistence;
1976            @BeanReference(type = OrgLaborPersistence.class)
1977            protected OrgLaborPersistence orgLaborPersistence;
1978            @BeanReference(type = PasswordPolicyPersistence.class)
1979            protected PasswordPolicyPersistence passwordPolicyPersistence;
1980            @BeanReference(type = PasswordPolicyRelPersistence.class)
1981            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1982            @BeanReference(type = PasswordTrackerPersistence.class)
1983            protected PasswordTrackerPersistence passwordTrackerPersistence;
1984            @BeanReference(type = PermissionPersistence.class)
1985            protected PermissionPersistence permissionPersistence;
1986            @BeanReference(type = PhonePersistence.class)
1987            protected PhonePersistence phonePersistence;
1988            @BeanReference(type = PluginSettingPersistence.class)
1989            protected PluginSettingPersistence pluginSettingPersistence;
1990            @BeanReference(type = PortalPreferencesPersistence.class)
1991            protected PortalPreferencesPersistence portalPreferencesPersistence;
1992            @BeanReference(type = PortletPersistence.class)
1993            protected PortletPersistence portletPersistence;
1994            @BeanReference(type = PortletItemPersistence.class)
1995            protected PortletItemPersistence portletItemPersistence;
1996            @BeanReference(type = PortletPreferencesPersistence.class)
1997            protected PortletPreferencesPersistence portletPreferencesPersistence;
1998            @BeanReference(type = RegionPersistence.class)
1999            protected RegionPersistence regionPersistence;
2000            @BeanReference(type = ReleasePersistence.class)
2001            protected ReleasePersistence releasePersistence;
2002            @BeanReference(type = RepositoryPersistence.class)
2003            protected RepositoryPersistence repositoryPersistence;
2004            @BeanReference(type = RepositoryEntryPersistence.class)
2005            protected RepositoryEntryPersistence repositoryEntryPersistence;
2006            @BeanReference(type = ResourcePersistence.class)
2007            protected ResourcePersistence resourcePersistence;
2008            @BeanReference(type = ResourceActionPersistence.class)
2009            protected ResourceActionPersistence resourceActionPersistence;
2010            @BeanReference(type = ResourceBlockPersistence.class)
2011            protected ResourceBlockPersistence resourceBlockPersistence;
2012            @BeanReference(type = ResourceBlockPermissionPersistence.class)
2013            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2014            @BeanReference(type = ResourceCodePersistence.class)
2015            protected ResourceCodePersistence resourceCodePersistence;
2016            @BeanReference(type = ResourcePermissionPersistence.class)
2017            protected ResourcePermissionPersistence resourcePermissionPersistence;
2018            @BeanReference(type = ResourceTypePermissionPersistence.class)
2019            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2020            @BeanReference(type = RolePersistence.class)
2021            protected RolePersistence rolePersistence;
2022            @BeanReference(type = ServiceComponentPersistence.class)
2023            protected ServiceComponentPersistence serviceComponentPersistence;
2024            @BeanReference(type = ShardPersistence.class)
2025            protected ShardPersistence shardPersistence;
2026            @BeanReference(type = SubscriptionPersistence.class)
2027            protected SubscriptionPersistence subscriptionPersistence;
2028            @BeanReference(type = TeamPersistence.class)
2029            protected TeamPersistence teamPersistence;
2030            @BeanReference(type = TicketPersistence.class)
2031            protected TicketPersistence ticketPersistence;
2032            @BeanReference(type = UserPersistence.class)
2033            protected UserPersistence userPersistence;
2034            @BeanReference(type = UserGroupPersistence.class)
2035            protected UserGroupPersistence userGroupPersistence;
2036            @BeanReference(type = UserGroupGroupRolePersistence.class)
2037            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2038            @BeanReference(type = UserGroupRolePersistence.class)
2039            protected UserGroupRolePersistence userGroupRolePersistence;
2040            @BeanReference(type = UserIdMapperPersistence.class)
2041            protected UserIdMapperPersistence userIdMapperPersistence;
2042            @BeanReference(type = UserNotificationEventPersistence.class)
2043            protected UserNotificationEventPersistence userNotificationEventPersistence;
2044            @BeanReference(type = UserTrackerPersistence.class)
2045            protected UserTrackerPersistence userTrackerPersistence;
2046            @BeanReference(type = UserTrackerPathPersistence.class)
2047            protected UserTrackerPathPersistence userTrackerPathPersistence;
2048            @BeanReference(type = VirtualHostPersistence.class)
2049            protected VirtualHostPersistence virtualHostPersistence;
2050            @BeanReference(type = WebDAVPropsPersistence.class)
2051            protected WebDAVPropsPersistence webDAVPropsPersistence;
2052            @BeanReference(type = WebsitePersistence.class)
2053            protected WebsitePersistence websitePersistence;
2054            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2055            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2056            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2057            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2058            private static final String _SQL_SELECT_RESOURCECODE = "SELECT resourceCode FROM ResourceCode resourceCode";
2059            private static final String _SQL_SELECT_RESOURCECODE_WHERE = "SELECT resourceCode FROM ResourceCode resourceCode WHERE ";
2060            private static final String _SQL_COUNT_RESOURCECODE = "SELECT COUNT(resourceCode) FROM ResourceCode resourceCode";
2061            private static final String _SQL_COUNT_RESOURCECODE_WHERE = "SELECT COUNT(resourceCode) FROM ResourceCode resourceCode WHERE ";
2062            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "resourceCode.companyId = ?";
2063            private static final String _FINDER_COLUMN_NAME_NAME_1 = "resourceCode.name IS NULL";
2064            private static final String _FINDER_COLUMN_NAME_NAME_2 = "resourceCode.name = ?";
2065            private static final String _FINDER_COLUMN_NAME_NAME_3 = "(resourceCode.name IS NULL OR resourceCode.name = ?)";
2066            private static final String _FINDER_COLUMN_C_N_S_COMPANYID_2 = "resourceCode.companyId = ? AND ";
2067            private static final String _FINDER_COLUMN_C_N_S_NAME_1 = "resourceCode.name IS NULL AND ";
2068            private static final String _FINDER_COLUMN_C_N_S_NAME_2 = "resourceCode.name = ? AND ";
2069            private static final String _FINDER_COLUMN_C_N_S_NAME_3 = "(resourceCode.name IS NULL OR resourceCode.name = ?) AND ";
2070            private static final String _FINDER_COLUMN_C_N_S_SCOPE_2 = "resourceCode.scope = ?";
2071            private static final String _ORDER_BY_ENTITY_ALIAS = "resourceCode.";
2072            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ResourceCode exists with the primary key ";
2073            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ResourceCode exists with the key {";
2074            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2075            private static Log _log = LogFactoryUtil.getLog(ResourceCodePersistenceImpl.class);
2076            private static ResourceCode _nullResourceCode = new ResourceCodeImpl() {
2077                            @Override
2078                            public Object clone() {
2079                                    return this;
2080                            }
2081    
2082                            @Override
2083                            public CacheModel<ResourceCode> toCacheModel() {
2084                                    return _nullResourceCodeCacheModel;
2085                            }
2086                    };
2087    
2088            private static CacheModel<ResourceCode> _nullResourceCodeCacheModel = new CacheModel<ResourceCode>() {
2089                            public ResourceCode toEntityModel() {
2090                                    return _nullResourceCode;
2091                            }
2092                    };
2093    }