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