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