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