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