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