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