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.NoSuchTeamException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.SetUtil;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
038    import com.liferay.portal.kernel.util.UnmodifiableList;
039    import com.liferay.portal.kernel.util.Validator;
040    import com.liferay.portal.model.CacheModel;
041    import com.liferay.portal.model.ModelListener;
042    import com.liferay.portal.model.Team;
043    import com.liferay.portal.model.impl.TeamImpl;
044    import com.liferay.portal.model.impl.TeamModelImpl;
045    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047    import com.liferay.portal.service.persistence.impl.TableMapper;
048    import com.liferay.portal.service.persistence.impl.TableMapperFactory;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.HashSet;
055    import java.util.List;
056    import java.util.Set;
057    
058    /**
059     * The persistence implementation for the team service.
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see TeamPersistence
067     * @see TeamUtil
068     * @generated
069     */
070    public class TeamPersistenceImpl extends BasePersistenceImpl<Team>
071            implements TeamPersistence {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link TeamUtil} to access the team persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
076             */
077            public static final String FINDER_CLASS_NAME_ENTITY = TeamImpl.class.getName();
078            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List1";
080            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List2";
082            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
083                            TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
086                            TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
089                            TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
092                            TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
094                            new String[] {
095                                    Long.class.getName(),
096                                    
097                            Integer.class.getName(), Integer.class.getName(),
098                                    OrderByComparator.class.getName()
099                            });
100            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
101                    new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
102                            TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
104                            new String[] { Long.class.getName() },
105                            TeamModelImpl.GROUPID_COLUMN_BITMASK |
106                            TeamModelImpl.NAME_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
108                            TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
110                            new String[] { Long.class.getName() });
111    
112            /**
113             * Returns all the teams where groupId = &#63;.
114             *
115             * @param groupId the group ID
116             * @return the matching teams
117             * @throws SystemException if a system exception occurred
118             */
119            @Override
120            public List<Team> findByGroupId(long groupId) throws SystemException {
121                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122            }
123    
124            /**
125             * Returns a range of all the teams where groupId = &#63;.
126             *
127             * <p>
128             * 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.TeamModelImpl}. 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.
129             * </p>
130             *
131             * @param groupId the group ID
132             * @param start the lower bound of the range of teams
133             * @param end the upper bound of the range of teams (not inclusive)
134             * @return the range of matching teams
135             * @throws SystemException if a system exception occurred
136             */
137            @Override
138            public List<Team> findByGroupId(long groupId, int start, int end)
139                    throws SystemException {
140                    return findByGroupId(groupId, start, end, null);
141            }
142    
143            /**
144             * Returns an ordered range of all the teams where groupId = &#63;.
145             *
146             * <p>
147             * 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.TeamModelImpl}. 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.
148             * </p>
149             *
150             * @param groupId the group ID
151             * @param start the lower bound of the range of teams
152             * @param end the upper bound of the range of teams (not inclusive)
153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
154             * @return the ordered range of matching teams
155             * @throws SystemException if a system exception occurred
156             */
157            @Override
158            public List<Team> findByGroupId(long groupId, int start, int end,
159                    OrderByComparator orderByComparator) throws SystemException {
160                    boolean pagination = true;
161                    FinderPath finderPath = null;
162                    Object[] finderArgs = null;
163    
164                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
165                                    (orderByComparator == null)) {
166                            pagination = false;
167                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
168                            finderArgs = new Object[] { groupId };
169                    }
170                    else {
171                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
172                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
173                    }
174    
175                    List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
176                                    finderArgs, this);
177    
178                    if ((list != null) && !list.isEmpty()) {
179                            for (Team team : list) {
180                                    if ((groupId != team.getGroupId())) {
181                                            list = null;
182    
183                                            break;
184                                    }
185                            }
186                    }
187    
188                    if (list == null) {
189                            StringBundler query = null;
190    
191                            if (orderByComparator != null) {
192                                    query = new StringBundler(3 +
193                                                    (orderByComparator.getOrderByFields().length * 3));
194                            }
195                            else {
196                                    query = new StringBundler(3);
197                            }
198    
199                            query.append(_SQL_SELECT_TEAM_WHERE);
200    
201                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
202    
203                            if (orderByComparator != null) {
204                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
205                                            orderByComparator);
206                            }
207                            else
208                             if (pagination) {
209                                    query.append(TeamModelImpl.ORDER_BY_JPQL);
210                            }
211    
212                            String sql = query.toString();
213    
214                            Session session = null;
215    
216                            try {
217                                    session = openSession();
218    
219                                    Query q = session.createQuery(sql);
220    
221                                    QueryPos qPos = QueryPos.getInstance(q);
222    
223                                    qPos.add(groupId);
224    
225                                    if (!pagination) {
226                                            list = (List<Team>)QueryUtil.list(q, getDialect(), start,
227                                                            end, false);
228    
229                                            Collections.sort(list);
230    
231                                            list = new UnmodifiableList<Team>(list);
232                                    }
233                                    else {
234                                            list = (List<Team>)QueryUtil.list(q, getDialect(), start,
235                                                            end);
236                                    }
237    
238                                    cacheResult(list);
239    
240                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
241                            }
242                            catch (Exception e) {
243                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
244    
245                                    throw processException(e);
246                            }
247                            finally {
248                                    closeSession(session);
249                            }
250                    }
251    
252                    return list;
253            }
254    
255            /**
256             * Returns the first team in the ordered set where groupId = &#63;.
257             *
258             * @param groupId the group ID
259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
260             * @return the first matching team
261             * @throws com.liferay.portal.NoSuchTeamException if a matching team could not be found
262             * @throws SystemException if a system exception occurred
263             */
264            @Override
265            public Team findByGroupId_First(long groupId,
266                    OrderByComparator orderByComparator)
267                    throws NoSuchTeamException, SystemException {
268                    Team team = fetchByGroupId_First(groupId, orderByComparator);
269    
270                    if (team != null) {
271                            return team;
272                    }
273    
274                    StringBundler msg = new StringBundler(4);
275    
276                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
277    
278                    msg.append("groupId=");
279                    msg.append(groupId);
280    
281                    msg.append(StringPool.CLOSE_CURLY_BRACE);
282    
283                    throw new NoSuchTeamException(msg.toString());
284            }
285    
286            /**
287             * Returns the first team in the ordered set where groupId = &#63;.
288             *
289             * @param groupId the group ID
290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
291             * @return the first matching team, or <code>null</code> if a matching team could not be found
292             * @throws SystemException if a system exception occurred
293             */
294            @Override
295            public Team fetchByGroupId_First(long groupId,
296                    OrderByComparator orderByComparator) throws SystemException {
297                    List<Team> list = findByGroupId(groupId, 0, 1, orderByComparator);
298    
299                    if (!list.isEmpty()) {
300                            return list.get(0);
301                    }
302    
303                    return null;
304            }
305    
306            /**
307             * Returns the last team in the ordered set where groupId = &#63;.
308             *
309             * @param groupId the group ID
310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
311             * @return the last matching team
312             * @throws com.liferay.portal.NoSuchTeamException if a matching team could not be found
313             * @throws SystemException if a system exception occurred
314             */
315            @Override
316            public Team findByGroupId_Last(long groupId,
317                    OrderByComparator orderByComparator)
318                    throws NoSuchTeamException, SystemException {
319                    Team team = fetchByGroupId_Last(groupId, orderByComparator);
320    
321                    if (team != null) {
322                            return team;
323                    }
324    
325                    StringBundler msg = new StringBundler(4);
326    
327                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
328    
329                    msg.append("groupId=");
330                    msg.append(groupId);
331    
332                    msg.append(StringPool.CLOSE_CURLY_BRACE);
333    
334                    throw new NoSuchTeamException(msg.toString());
335            }
336    
337            /**
338             * Returns the last team in the ordered set where groupId = &#63;.
339             *
340             * @param groupId the group ID
341             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
342             * @return the last matching team, or <code>null</code> if a matching team could not be found
343             * @throws SystemException if a system exception occurred
344             */
345            @Override
346            public Team fetchByGroupId_Last(long groupId,
347                    OrderByComparator orderByComparator) throws SystemException {
348                    int count = countByGroupId(groupId);
349    
350                    if (count == 0) {
351                            return null;
352                    }
353    
354                    List<Team> list = findByGroupId(groupId, count - 1, count,
355                                    orderByComparator);
356    
357                    if (!list.isEmpty()) {
358                            return list.get(0);
359                    }
360    
361                    return null;
362            }
363    
364            /**
365             * Returns the teams before and after the current team in the ordered set where groupId = &#63;.
366             *
367             * @param teamId the primary key of the current team
368             * @param groupId the group ID
369             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
370             * @return the previous, current, and next team
371             * @throws com.liferay.portal.NoSuchTeamException if a team with the primary key could not be found
372             * @throws SystemException if a system exception occurred
373             */
374            @Override
375            public Team[] findByGroupId_PrevAndNext(long teamId, long groupId,
376                    OrderByComparator orderByComparator)
377                    throws NoSuchTeamException, SystemException {
378                    Team team = findByPrimaryKey(teamId);
379    
380                    Session session = null;
381    
382                    try {
383                            session = openSession();
384    
385                            Team[] array = new TeamImpl[3];
386    
387                            array[0] = getByGroupId_PrevAndNext(session, team, groupId,
388                                            orderByComparator, true);
389    
390                            array[1] = team;
391    
392                            array[2] = getByGroupId_PrevAndNext(session, team, groupId,
393                                            orderByComparator, false);
394    
395                            return array;
396                    }
397                    catch (Exception e) {
398                            throw processException(e);
399                    }
400                    finally {
401                            closeSession(session);
402                    }
403            }
404    
405            protected Team getByGroupId_PrevAndNext(Session session, Team team,
406                    long groupId, OrderByComparator orderByComparator, boolean previous) {
407                    StringBundler query = null;
408    
409                    if (orderByComparator != null) {
410                            query = new StringBundler(6 +
411                                            (orderByComparator.getOrderByFields().length * 6));
412                    }
413                    else {
414                            query = new StringBundler(3);
415                    }
416    
417                    query.append(_SQL_SELECT_TEAM_WHERE);
418    
419                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
420    
421                    if (orderByComparator != null) {
422                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
423    
424                            if (orderByConditionFields.length > 0) {
425                                    query.append(WHERE_AND);
426                            }
427    
428                            for (int i = 0; i < orderByConditionFields.length; i++) {
429                                    query.append(_ORDER_BY_ENTITY_ALIAS);
430                                    query.append(orderByConditionFields[i]);
431    
432                                    if ((i + 1) < orderByConditionFields.length) {
433                                            if (orderByComparator.isAscending() ^ previous) {
434                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
435                                            }
436                                            else {
437                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
438                                            }
439                                    }
440                                    else {
441                                            if (orderByComparator.isAscending() ^ previous) {
442                                                    query.append(WHERE_GREATER_THAN);
443                                            }
444                                            else {
445                                                    query.append(WHERE_LESSER_THAN);
446                                            }
447                                    }
448                            }
449    
450                            query.append(ORDER_BY_CLAUSE);
451    
452                            String[] orderByFields = orderByComparator.getOrderByFields();
453    
454                            for (int i = 0; i < orderByFields.length; i++) {
455                                    query.append(_ORDER_BY_ENTITY_ALIAS);
456                                    query.append(orderByFields[i]);
457    
458                                    if ((i + 1) < orderByFields.length) {
459                                            if (orderByComparator.isAscending() ^ previous) {
460                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
461                                            }
462                                            else {
463                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
464                                            }
465                                    }
466                                    else {
467                                            if (orderByComparator.isAscending() ^ previous) {
468                                                    query.append(ORDER_BY_ASC);
469                                            }
470                                            else {
471                                                    query.append(ORDER_BY_DESC);
472                                            }
473                                    }
474                            }
475                    }
476                    else {
477                            query.append(TeamModelImpl.ORDER_BY_JPQL);
478                    }
479    
480                    String sql = query.toString();
481    
482                    Query q = session.createQuery(sql);
483    
484                    q.setFirstResult(0);
485                    q.setMaxResults(2);
486    
487                    QueryPos qPos = QueryPos.getInstance(q);
488    
489                    qPos.add(groupId);
490    
491                    if (orderByComparator != null) {
492                            Object[] values = orderByComparator.getOrderByConditionValues(team);
493    
494                            for (Object value : values) {
495                                    qPos.add(value);
496                            }
497                    }
498    
499                    List<Team> list = q.list();
500    
501                    if (list.size() == 2) {
502                            return list.get(1);
503                    }
504                    else {
505                            return null;
506                    }
507            }
508    
509            /**
510             * Returns all the teams that the user has permission to view where groupId = &#63;.
511             *
512             * @param groupId the group ID
513             * @return the matching teams that the user has permission to view
514             * @throws SystemException if a system exception occurred
515             */
516            @Override
517            public List<Team> filterFindByGroupId(long groupId)
518                    throws SystemException {
519                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
520                            QueryUtil.ALL_POS, null);
521            }
522    
523            /**
524             * Returns a range of all the teams that the user has permission to view where groupId = &#63;.
525             *
526             * <p>
527             * 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.TeamModelImpl}. 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.
528             * </p>
529             *
530             * @param groupId the group ID
531             * @param start the lower bound of the range of teams
532             * @param end the upper bound of the range of teams (not inclusive)
533             * @return the range of matching teams that the user has permission to view
534             * @throws SystemException if a system exception occurred
535             */
536            @Override
537            public List<Team> filterFindByGroupId(long groupId, int start, int end)
538                    throws SystemException {
539                    return filterFindByGroupId(groupId, start, end, null);
540            }
541    
542            /**
543             * Returns an ordered range of all the teams that the user has permissions to view where groupId = &#63;.
544             *
545             * <p>
546             * 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.TeamModelImpl}. 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.
547             * </p>
548             *
549             * @param groupId the group ID
550             * @param start the lower bound of the range of teams
551             * @param end the upper bound of the range of teams (not inclusive)
552             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
553             * @return the ordered range of matching teams that the user has permission to view
554             * @throws SystemException if a system exception occurred
555             */
556            @Override
557            public List<Team> filterFindByGroupId(long groupId, int start, int end,
558                    OrderByComparator orderByComparator) throws SystemException {
559                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
560                            return findByGroupId(groupId, start, end, orderByComparator);
561                    }
562    
563                    StringBundler query = null;
564    
565                    if (orderByComparator != null) {
566                            query = new StringBundler(3 +
567                                            (orderByComparator.getOrderByFields().length * 3));
568                    }
569                    else {
570                            query = new StringBundler(3);
571                    }
572    
573                    if (getDB().isSupportsInlineDistinct()) {
574                            query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
575                    }
576                    else {
577                            query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
578                    }
579    
580                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
581    
582                    if (!getDB().isSupportsInlineDistinct()) {
583                            query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
584                    }
585    
586                    if (orderByComparator != null) {
587                            if (getDB().isSupportsInlineDistinct()) {
588                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
589                                            orderByComparator, true);
590                            }
591                            else {
592                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
593                                            orderByComparator, true);
594                            }
595                    }
596                    else {
597                            if (getDB().isSupportsInlineDistinct()) {
598                                    query.append(TeamModelImpl.ORDER_BY_JPQL);
599                            }
600                            else {
601                                    query.append(TeamModelImpl.ORDER_BY_SQL);
602                            }
603                    }
604    
605                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
606                                    Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
607                                    groupId);
608    
609                    Session session = null;
610    
611                    try {
612                            session = openSession();
613    
614                            SQLQuery q = session.createSQLQuery(sql);
615    
616                            if (getDB().isSupportsInlineDistinct()) {
617                                    q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
618                            }
619                            else {
620                                    q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
621                            }
622    
623                            QueryPos qPos = QueryPos.getInstance(q);
624    
625                            qPos.add(groupId);
626    
627                            return (List<Team>)QueryUtil.list(q, getDialect(), start, end);
628                    }
629                    catch (Exception e) {
630                            throw processException(e);
631                    }
632                    finally {
633                            closeSession(session);
634                    }
635            }
636    
637            /**
638             * Returns the teams before and after the current team in the ordered set of teams that the user has permission to view where groupId = &#63;.
639             *
640             * @param teamId the primary key of the current team
641             * @param groupId the group ID
642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
643             * @return the previous, current, and next team
644             * @throws com.liferay.portal.NoSuchTeamException if a team with the primary key could not be found
645             * @throws SystemException if a system exception occurred
646             */
647            @Override
648            public Team[] filterFindByGroupId_PrevAndNext(long teamId, long groupId,
649                    OrderByComparator orderByComparator)
650                    throws NoSuchTeamException, SystemException {
651                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
652                            return findByGroupId_PrevAndNext(teamId, groupId, orderByComparator);
653                    }
654    
655                    Team team = findByPrimaryKey(teamId);
656    
657                    Session session = null;
658    
659                    try {
660                            session = openSession();
661    
662                            Team[] array = new TeamImpl[3];
663    
664                            array[0] = filterGetByGroupId_PrevAndNext(session, team, groupId,
665                                            orderByComparator, true);
666    
667                            array[1] = team;
668    
669                            array[2] = filterGetByGroupId_PrevAndNext(session, team, groupId,
670                                            orderByComparator, false);
671    
672                            return array;
673                    }
674                    catch (Exception e) {
675                            throw processException(e);
676                    }
677                    finally {
678                            closeSession(session);
679                    }
680            }
681    
682            protected Team filterGetByGroupId_PrevAndNext(Session session, Team team,
683                    long groupId, OrderByComparator orderByComparator, boolean previous) {
684                    StringBundler query = null;
685    
686                    if (orderByComparator != null) {
687                            query = new StringBundler(6 +
688                                            (orderByComparator.getOrderByFields().length * 6));
689                    }
690                    else {
691                            query = new StringBundler(3);
692                    }
693    
694                    if (getDB().isSupportsInlineDistinct()) {
695                            query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
696                    }
697                    else {
698                            query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
699                    }
700    
701                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
702    
703                    if (!getDB().isSupportsInlineDistinct()) {
704                            query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
705                    }
706    
707                    if (orderByComparator != null) {
708                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
709    
710                            if (orderByConditionFields.length > 0) {
711                                    query.append(WHERE_AND);
712                            }
713    
714                            for (int i = 0; i < orderByConditionFields.length; i++) {
715                                    if (getDB().isSupportsInlineDistinct()) {
716                                            query.append(_ORDER_BY_ENTITY_ALIAS);
717                                    }
718                                    else {
719                                            query.append(_ORDER_BY_ENTITY_TABLE);
720                                    }
721    
722                                    query.append(orderByConditionFields[i]);
723    
724                                    if ((i + 1) < orderByConditionFields.length) {
725                                            if (orderByComparator.isAscending() ^ previous) {
726                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
727                                            }
728                                            else {
729                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
730                                            }
731                                    }
732                                    else {
733                                            if (orderByComparator.isAscending() ^ previous) {
734                                                    query.append(WHERE_GREATER_THAN);
735                                            }
736                                            else {
737                                                    query.append(WHERE_LESSER_THAN);
738                                            }
739                                    }
740                            }
741    
742                            query.append(ORDER_BY_CLAUSE);
743    
744                            String[] orderByFields = orderByComparator.getOrderByFields();
745    
746                            for (int i = 0; i < orderByFields.length; i++) {
747                                    if (getDB().isSupportsInlineDistinct()) {
748                                            query.append(_ORDER_BY_ENTITY_ALIAS);
749                                    }
750                                    else {
751                                            query.append(_ORDER_BY_ENTITY_TABLE);
752                                    }
753    
754                                    query.append(orderByFields[i]);
755    
756                                    if ((i + 1) < orderByFields.length) {
757                                            if (orderByComparator.isAscending() ^ previous) {
758                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
759                                            }
760                                            else {
761                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
762                                            }
763                                    }
764                                    else {
765                                            if (orderByComparator.isAscending() ^ previous) {
766                                                    query.append(ORDER_BY_ASC);
767                                            }
768                                            else {
769                                                    query.append(ORDER_BY_DESC);
770                                            }
771                                    }
772                            }
773                    }
774                    else {
775                            if (getDB().isSupportsInlineDistinct()) {
776                                    query.append(TeamModelImpl.ORDER_BY_JPQL);
777                            }
778                            else {
779                                    query.append(TeamModelImpl.ORDER_BY_SQL);
780                            }
781                    }
782    
783                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
784                                    Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
785                                    groupId);
786    
787                    SQLQuery q = session.createSQLQuery(sql);
788    
789                    q.setFirstResult(0);
790                    q.setMaxResults(2);
791    
792                    if (getDB().isSupportsInlineDistinct()) {
793                            q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
794                    }
795                    else {
796                            q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
797                    }
798    
799                    QueryPos qPos = QueryPos.getInstance(q);
800    
801                    qPos.add(groupId);
802    
803                    if (orderByComparator != null) {
804                            Object[] values = orderByComparator.getOrderByConditionValues(team);
805    
806                            for (Object value : values) {
807                                    qPos.add(value);
808                            }
809                    }
810    
811                    List<Team> list = q.list();
812    
813                    if (list.size() == 2) {
814                            return list.get(1);
815                    }
816                    else {
817                            return null;
818                    }
819            }
820    
821            /**
822             * Removes all the teams where groupId = &#63; from the database.
823             *
824             * @param groupId the group ID
825             * @throws SystemException if a system exception occurred
826             */
827            @Override
828            public void removeByGroupId(long groupId) throws SystemException {
829                    for (Team team : findByGroupId(groupId, QueryUtil.ALL_POS,
830                                    QueryUtil.ALL_POS, null)) {
831                            remove(team);
832                    }
833            }
834    
835            /**
836             * Returns the number of teams where groupId = &#63;.
837             *
838             * @param groupId the group ID
839             * @return the number of matching teams
840             * @throws SystemException if a system exception occurred
841             */
842            @Override
843            public int countByGroupId(long groupId) throws SystemException {
844                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
845    
846                    Object[] finderArgs = new Object[] { groupId };
847    
848                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
849                                    this);
850    
851                    if (count == null) {
852                            StringBundler query = new StringBundler(2);
853    
854                            query.append(_SQL_COUNT_TEAM_WHERE);
855    
856                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
857    
858                            String sql = query.toString();
859    
860                            Session session = null;
861    
862                            try {
863                                    session = openSession();
864    
865                                    Query q = session.createQuery(sql);
866    
867                                    QueryPos qPos = QueryPos.getInstance(q);
868    
869                                    qPos.add(groupId);
870    
871                                    count = (Long)q.uniqueResult();
872    
873                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
874                            }
875                            catch (Exception e) {
876                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
877    
878                                    throw processException(e);
879                            }
880                            finally {
881                                    closeSession(session);
882                            }
883                    }
884    
885                    return count.intValue();
886            }
887    
888            /**
889             * Returns the number of teams that the user has permission to view where groupId = &#63;.
890             *
891             * @param groupId the group ID
892             * @return the number of matching teams that the user has permission to view
893             * @throws SystemException if a system exception occurred
894             */
895            @Override
896            public int filterCountByGroupId(long groupId) throws SystemException {
897                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
898                            return countByGroupId(groupId);
899                    }
900    
901                    StringBundler query = new StringBundler(2);
902    
903                    query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
904    
905                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
906    
907                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
908                                    Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
909                                    groupId);
910    
911                    Session session = null;
912    
913                    try {
914                            session = openSession();
915    
916                            SQLQuery q = session.createSQLQuery(sql);
917    
918                            q.addScalar(COUNT_COLUMN_NAME,
919                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
920    
921                            QueryPos qPos = QueryPos.getInstance(q);
922    
923                            qPos.add(groupId);
924    
925                            Long count = (Long)q.uniqueResult();
926    
927                            return count.intValue();
928                    }
929                    catch (Exception e) {
930                            throw processException(e);
931                    }
932                    finally {
933                            closeSession(session);
934                    }
935            }
936    
937            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?";
938            public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
939                            TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
940                            FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
941                            new String[] { Long.class.getName(), String.class.getName() },
942                            TeamModelImpl.GROUPID_COLUMN_BITMASK |
943                            TeamModelImpl.NAME_COLUMN_BITMASK);
944            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
945                            TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
946                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
947                            new String[] { Long.class.getName(), String.class.getName() });
948    
949            /**
950             * Returns the team where groupId = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchTeamException} if it could not be found.
951             *
952             * @param groupId the group ID
953             * @param name the name
954             * @return the matching team
955             * @throws com.liferay.portal.NoSuchTeamException if a matching team could not be found
956             * @throws SystemException if a system exception occurred
957             */
958            @Override
959            public Team findByG_N(long groupId, String name)
960                    throws NoSuchTeamException, SystemException {
961                    Team team = fetchByG_N(groupId, name);
962    
963                    if (team == null) {
964                            StringBundler msg = new StringBundler(6);
965    
966                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
967    
968                            msg.append("groupId=");
969                            msg.append(groupId);
970    
971                            msg.append(", name=");
972                            msg.append(name);
973    
974                            msg.append(StringPool.CLOSE_CURLY_BRACE);
975    
976                            if (_log.isWarnEnabled()) {
977                                    _log.warn(msg.toString());
978                            }
979    
980                            throw new NoSuchTeamException(msg.toString());
981                    }
982    
983                    return team;
984            }
985    
986            /**
987             * Returns the team where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
988             *
989             * @param groupId the group ID
990             * @param name the name
991             * @return the matching team, or <code>null</code> if a matching team could not be found
992             * @throws SystemException if a system exception occurred
993             */
994            @Override
995            public Team fetchByG_N(long groupId, String name) throws SystemException {
996                    return fetchByG_N(groupId, name, true);
997            }
998    
999            /**
1000             * Returns the team where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1001             *
1002             * @param groupId the group ID
1003             * @param name the name
1004             * @param retrieveFromCache whether to use the finder cache
1005             * @return the matching team, or <code>null</code> if a matching team could not be found
1006             * @throws SystemException if a system exception occurred
1007             */
1008            @Override
1009            public Team fetchByG_N(long groupId, String name, boolean retrieveFromCache)
1010                    throws SystemException {
1011                    Object[] finderArgs = new Object[] { groupId, name };
1012    
1013                    Object result = null;
1014    
1015                    if (retrieveFromCache) {
1016                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1017                                            finderArgs, this);
1018                    }
1019    
1020                    if (result instanceof Team) {
1021                            Team team = (Team)result;
1022    
1023                            if ((groupId != team.getGroupId()) ||
1024                                            !Validator.equals(name, team.getName())) {
1025                                    result = null;
1026                            }
1027                    }
1028    
1029                    if (result == null) {
1030                            StringBundler query = new StringBundler(4);
1031    
1032                            query.append(_SQL_SELECT_TEAM_WHERE);
1033    
1034                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1035    
1036                            boolean bindName = false;
1037    
1038                            if (name == null) {
1039                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
1040                            }
1041                            else if (name.equals(StringPool.BLANK)) {
1042                                    query.append(_FINDER_COLUMN_G_N_NAME_3);
1043                            }
1044                            else {
1045                                    bindName = true;
1046    
1047                                    query.append(_FINDER_COLUMN_G_N_NAME_2);
1048                            }
1049    
1050                            String sql = query.toString();
1051    
1052                            Session session = null;
1053    
1054                            try {
1055                                    session = openSession();
1056    
1057                                    Query q = session.createQuery(sql);
1058    
1059                                    QueryPos qPos = QueryPos.getInstance(q);
1060    
1061                                    qPos.add(groupId);
1062    
1063                                    if (bindName) {
1064                                            qPos.add(name);
1065                                    }
1066    
1067                                    List<Team> list = q.list();
1068    
1069                                    if (list.isEmpty()) {
1070                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1071                                                    finderArgs, list);
1072                                    }
1073                                    else {
1074                                            Team team = list.get(0);
1075    
1076                                            result = team;
1077    
1078                                            cacheResult(team);
1079    
1080                                            if ((team.getGroupId() != groupId) ||
1081                                                            (team.getName() == null) ||
1082                                                            !team.getName().equals(name)) {
1083                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1084                                                            finderArgs, team);
1085                                            }
1086                                    }
1087                            }
1088                            catch (Exception e) {
1089                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1090                                            finderArgs);
1091    
1092                                    throw processException(e);
1093                            }
1094                            finally {
1095                                    closeSession(session);
1096                            }
1097                    }
1098    
1099                    if (result instanceof List<?>) {
1100                            return null;
1101                    }
1102                    else {
1103                            return (Team)result;
1104                    }
1105            }
1106    
1107            /**
1108             * Removes the team where groupId = &#63; and name = &#63; from the database.
1109             *
1110             * @param groupId the group ID
1111             * @param name the name
1112             * @return the team that was removed
1113             * @throws SystemException if a system exception occurred
1114             */
1115            @Override
1116            public Team removeByG_N(long groupId, String name)
1117                    throws NoSuchTeamException, SystemException {
1118                    Team team = findByG_N(groupId, name);
1119    
1120                    return remove(team);
1121            }
1122    
1123            /**
1124             * Returns the number of teams where groupId = &#63; and name = &#63;.
1125             *
1126             * @param groupId the group ID
1127             * @param name the name
1128             * @return the number of matching teams
1129             * @throws SystemException if a system exception occurred
1130             */
1131            @Override
1132            public int countByG_N(long groupId, String name) throws SystemException {
1133                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
1134    
1135                    Object[] finderArgs = new Object[] { groupId, name };
1136    
1137                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1138                                    this);
1139    
1140                    if (count == null) {
1141                            StringBundler query = new StringBundler(3);
1142    
1143                            query.append(_SQL_COUNT_TEAM_WHERE);
1144    
1145                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1146    
1147                            boolean bindName = false;
1148    
1149                            if (name == null) {
1150                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
1151                            }
1152                            else if (name.equals(StringPool.BLANK)) {
1153                                    query.append(_FINDER_COLUMN_G_N_NAME_3);
1154                            }
1155                            else {
1156                                    bindName = true;
1157    
1158                                    query.append(_FINDER_COLUMN_G_N_NAME_2);
1159                            }
1160    
1161                            String sql = query.toString();
1162    
1163                            Session session = null;
1164    
1165                            try {
1166                                    session = openSession();
1167    
1168                                    Query q = session.createQuery(sql);
1169    
1170                                    QueryPos qPos = QueryPos.getInstance(q);
1171    
1172                                    qPos.add(groupId);
1173    
1174                                    if (bindName) {
1175                                            qPos.add(name);
1176                                    }
1177    
1178                                    count = (Long)q.uniqueResult();
1179    
1180                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1181                            }
1182                            catch (Exception e) {
1183                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1184    
1185                                    throw processException(e);
1186                            }
1187                            finally {
1188                                    closeSession(session);
1189                            }
1190                    }
1191    
1192                    return count.intValue();
1193            }
1194    
1195            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND ";
1196            private static final String _FINDER_COLUMN_G_N_NAME_1 = "team.name IS NULL";
1197            private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?";
1198            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = '')";
1199    
1200            public TeamPersistenceImpl() {
1201                    setModelClass(Team.class);
1202            }
1203    
1204            /**
1205             * Caches the team in the entity cache if it is enabled.
1206             *
1207             * @param team the team
1208             */
1209            @Override
1210            public void cacheResult(Team team) {
1211                    EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1212                            TeamImpl.class, team.getPrimaryKey(), team);
1213    
1214                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1215                            new Object[] { team.getGroupId(), team.getName() }, team);
1216    
1217                    team.resetOriginalValues();
1218            }
1219    
1220            /**
1221             * Caches the teams in the entity cache if it is enabled.
1222             *
1223             * @param teams the teams
1224             */
1225            @Override
1226            public void cacheResult(List<Team> teams) {
1227                    for (Team team : teams) {
1228                            if (EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1229                                                    TeamImpl.class, team.getPrimaryKey()) == null) {
1230                                    cacheResult(team);
1231                            }
1232                            else {
1233                                    team.resetOriginalValues();
1234                            }
1235                    }
1236            }
1237    
1238            /**
1239             * Clears the cache for all teams.
1240             *
1241             * <p>
1242             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1243             * </p>
1244             */
1245            @Override
1246            public void clearCache() {
1247                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1248                            CacheRegistryUtil.clear(TeamImpl.class.getName());
1249                    }
1250    
1251                    EntityCacheUtil.clearCache(TeamImpl.class.getName());
1252    
1253                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1254                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1255                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1256            }
1257    
1258            /**
1259             * Clears the cache for the team.
1260             *
1261             * <p>
1262             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1263             * </p>
1264             */
1265            @Override
1266            public void clearCache(Team team) {
1267                    EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1268                            TeamImpl.class, team.getPrimaryKey());
1269    
1270                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1271                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1272    
1273                    clearUniqueFindersCache(team);
1274            }
1275    
1276            @Override
1277            public void clearCache(List<Team> teams) {
1278                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1279                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1280    
1281                    for (Team team : teams) {
1282                            EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1283                                    TeamImpl.class, team.getPrimaryKey());
1284    
1285                            clearUniqueFindersCache(team);
1286                    }
1287            }
1288    
1289            protected void cacheUniqueFindersCache(Team team) {
1290                    if (team.isNew()) {
1291                            Object[] args = new Object[] { team.getGroupId(), team.getName() };
1292    
1293                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
1294                                    Long.valueOf(1));
1295                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args, team);
1296                    }
1297                    else {
1298                            TeamModelImpl teamModelImpl = (TeamModelImpl)team;
1299    
1300                            if ((teamModelImpl.getColumnBitmask() &
1301                                            FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
1302                                    Object[] args = new Object[] { team.getGroupId(), team.getName() };
1303    
1304                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
1305                                            Long.valueOf(1));
1306                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args, team);
1307                            }
1308                    }
1309            }
1310    
1311            protected void clearUniqueFindersCache(Team team) {
1312                    TeamModelImpl teamModelImpl = (TeamModelImpl)team;
1313    
1314                    Object[] args = new Object[] { team.getGroupId(), team.getName() };
1315    
1316                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
1317                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
1318    
1319                    if ((teamModelImpl.getColumnBitmask() &
1320                                    FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
1321                            args = new Object[] {
1322                                            teamModelImpl.getOriginalGroupId(),
1323                                            teamModelImpl.getOriginalName()
1324                                    };
1325    
1326                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
1327                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
1328                    }
1329            }
1330    
1331            /**
1332             * Creates a new team with the primary key. Does not add the team to the database.
1333             *
1334             * @param teamId the primary key for the new team
1335             * @return the new team
1336             */
1337            @Override
1338            public Team create(long teamId) {
1339                    Team team = new TeamImpl();
1340    
1341                    team.setNew(true);
1342                    team.setPrimaryKey(teamId);
1343    
1344                    return team;
1345            }
1346    
1347            /**
1348             * Removes the team with the primary key from the database. Also notifies the appropriate model listeners.
1349             *
1350             * @param teamId the primary key of the team
1351             * @return the team that was removed
1352             * @throws com.liferay.portal.NoSuchTeamException if a team with the primary key could not be found
1353             * @throws SystemException if a system exception occurred
1354             */
1355            @Override
1356            public Team remove(long teamId) throws NoSuchTeamException, SystemException {
1357                    return remove((Serializable)teamId);
1358            }
1359    
1360            /**
1361             * Removes the team with the primary key from the database. Also notifies the appropriate model listeners.
1362             *
1363             * @param primaryKey the primary key of the team
1364             * @return the team that was removed
1365             * @throws com.liferay.portal.NoSuchTeamException if a team with the primary key could not be found
1366             * @throws SystemException if a system exception occurred
1367             */
1368            @Override
1369            public Team remove(Serializable primaryKey)
1370                    throws NoSuchTeamException, SystemException {
1371                    Session session = null;
1372    
1373                    try {
1374                            session = openSession();
1375    
1376                            Team team = (Team)session.get(TeamImpl.class, primaryKey);
1377    
1378                            if (team == null) {
1379                                    if (_log.isWarnEnabled()) {
1380                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1381                                    }
1382    
1383                                    throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1384                                            primaryKey);
1385                            }
1386    
1387                            return remove(team);
1388                    }
1389                    catch (NoSuchTeamException nsee) {
1390                            throw nsee;
1391                    }
1392                    catch (Exception e) {
1393                            throw processException(e);
1394                    }
1395                    finally {
1396                            closeSession(session);
1397                    }
1398            }
1399    
1400            @Override
1401            protected Team removeImpl(Team team) throws SystemException {
1402                    team = toUnwrappedModel(team);
1403    
1404                    teamToUserTableMapper.deleteLeftPrimaryKeyTableMappings(team.getPrimaryKey());
1405    
1406                    teamToUserGroupTableMapper.deleteLeftPrimaryKeyTableMappings(team.getPrimaryKey());
1407    
1408                    Session session = null;
1409    
1410                    try {
1411                            session = openSession();
1412    
1413                            if (!session.contains(team)) {
1414                                    team = (Team)session.get(TeamImpl.class, team.getPrimaryKeyObj());
1415                            }
1416    
1417                            if (team != null) {
1418                                    session.delete(team);
1419                            }
1420                    }
1421                    catch (Exception e) {
1422                            throw processException(e);
1423                    }
1424                    finally {
1425                            closeSession(session);
1426                    }
1427    
1428                    if (team != null) {
1429                            clearCache(team);
1430                    }
1431    
1432                    return team;
1433            }
1434    
1435            @Override
1436            public Team updateImpl(com.liferay.portal.model.Team team)
1437                    throws SystemException {
1438                    team = toUnwrappedModel(team);
1439    
1440                    boolean isNew = team.isNew();
1441    
1442                    TeamModelImpl teamModelImpl = (TeamModelImpl)team;
1443    
1444                    Session session = null;
1445    
1446                    try {
1447                            session = openSession();
1448    
1449                            if (team.isNew()) {
1450                                    session.save(team);
1451    
1452                                    team.setNew(false);
1453                            }
1454                            else {
1455                                    session.merge(team);
1456                            }
1457                    }
1458                    catch (Exception e) {
1459                            throw processException(e);
1460                    }
1461                    finally {
1462                            closeSession(session);
1463                    }
1464    
1465                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1466    
1467                    if (isNew || !TeamModelImpl.COLUMN_BITMASK_ENABLED) {
1468                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1469                    }
1470    
1471                    else {
1472                            if ((teamModelImpl.getColumnBitmask() &
1473                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
1474                                    Object[] args = new Object[] { teamModelImpl.getOriginalGroupId() };
1475    
1476                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1477                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1478                                            args);
1479    
1480                                    args = new Object[] { teamModelImpl.getGroupId() };
1481    
1482                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1483                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1484                                            args);
1485                            }
1486                    }
1487    
1488                    EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1489                            TeamImpl.class, team.getPrimaryKey(), team);
1490    
1491                    clearUniqueFindersCache(team);
1492                    cacheUniqueFindersCache(team);
1493    
1494                    return team;
1495            }
1496    
1497            protected Team toUnwrappedModel(Team team) {
1498                    if (team instanceof TeamImpl) {
1499                            return team;
1500                    }
1501    
1502                    TeamImpl teamImpl = new TeamImpl();
1503    
1504                    teamImpl.setNew(team.isNew());
1505                    teamImpl.setPrimaryKey(team.getPrimaryKey());
1506    
1507                    teamImpl.setTeamId(team.getTeamId());
1508                    teamImpl.setCompanyId(team.getCompanyId());
1509                    teamImpl.setUserId(team.getUserId());
1510                    teamImpl.setUserName(team.getUserName());
1511                    teamImpl.setCreateDate(team.getCreateDate());
1512                    teamImpl.setModifiedDate(team.getModifiedDate());
1513                    teamImpl.setGroupId(team.getGroupId());
1514                    teamImpl.setName(team.getName());
1515                    teamImpl.setDescription(team.getDescription());
1516    
1517                    return teamImpl;
1518            }
1519    
1520            /**
1521             * Returns the team with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1522             *
1523             * @param primaryKey the primary key of the team
1524             * @return the team
1525             * @throws com.liferay.portal.NoSuchTeamException if a team with the primary key could not be found
1526             * @throws SystemException if a system exception occurred
1527             */
1528            @Override
1529            public Team findByPrimaryKey(Serializable primaryKey)
1530                    throws NoSuchTeamException, SystemException {
1531                    Team team = fetchByPrimaryKey(primaryKey);
1532    
1533                    if (team == null) {
1534                            if (_log.isWarnEnabled()) {
1535                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1536                            }
1537    
1538                            throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1539                                    primaryKey);
1540                    }
1541    
1542                    return team;
1543            }
1544    
1545            /**
1546             * Returns the team with the primary key or throws a {@link com.liferay.portal.NoSuchTeamException} if it could not be found.
1547             *
1548             * @param teamId the primary key of the team
1549             * @return the team
1550             * @throws com.liferay.portal.NoSuchTeamException if a team with the primary key could not be found
1551             * @throws SystemException if a system exception occurred
1552             */
1553            @Override
1554            public Team findByPrimaryKey(long teamId)
1555                    throws NoSuchTeamException, SystemException {
1556                    return findByPrimaryKey((Serializable)teamId);
1557            }
1558    
1559            /**
1560             * Returns the team with the primary key or returns <code>null</code> if it could not be found.
1561             *
1562             * @param primaryKey the primary key of the team
1563             * @return the team, or <code>null</code> if a team with the primary key could not be found
1564             * @throws SystemException if a system exception occurred
1565             */
1566            @Override
1567            public Team fetchByPrimaryKey(Serializable primaryKey)
1568                    throws SystemException {
1569                    Team team = (Team)EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1570                                    TeamImpl.class, primaryKey);
1571    
1572                    if (team == _nullTeam) {
1573                            return null;
1574                    }
1575    
1576                    if (team == null) {
1577                            Session session = null;
1578    
1579                            try {
1580                                    session = openSession();
1581    
1582                                    team = (Team)session.get(TeamImpl.class, primaryKey);
1583    
1584                                    if (team != null) {
1585                                            cacheResult(team);
1586                                    }
1587                                    else {
1588                                            EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1589                                                    TeamImpl.class, primaryKey, _nullTeam);
1590                                    }
1591                            }
1592                            catch (Exception e) {
1593                                    EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
1594                                            TeamImpl.class, primaryKey);
1595    
1596                                    throw processException(e);
1597                            }
1598                            finally {
1599                                    closeSession(session);
1600                            }
1601                    }
1602    
1603                    return team;
1604            }
1605    
1606            /**
1607             * Returns the team with the primary key or returns <code>null</code> if it could not be found.
1608             *
1609             * @param teamId the primary key of the team
1610             * @return the team, or <code>null</code> if a team with the primary key could not be found
1611             * @throws SystemException if a system exception occurred
1612             */
1613            @Override
1614            public Team fetchByPrimaryKey(long teamId) throws SystemException {
1615                    return fetchByPrimaryKey((Serializable)teamId);
1616            }
1617    
1618            /**
1619             * Returns all the teams.
1620             *
1621             * @return the teams
1622             * @throws SystemException if a system exception occurred
1623             */
1624            @Override
1625            public List<Team> findAll() throws SystemException {
1626                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1627            }
1628    
1629            /**
1630             * Returns a range of all the teams.
1631             *
1632             * <p>
1633             * 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.TeamModelImpl}. 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.
1634             * </p>
1635             *
1636             * @param start the lower bound of the range of teams
1637             * @param end the upper bound of the range of teams (not inclusive)
1638             * @return the range of teams
1639             * @throws SystemException if a system exception occurred
1640             */
1641            @Override
1642            public List<Team> findAll(int start, int end) throws SystemException {
1643                    return findAll(start, end, null);
1644            }
1645    
1646            /**
1647             * Returns an ordered range of all the teams.
1648             *
1649             * <p>
1650             * 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.TeamModelImpl}. 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.
1651             * </p>
1652             *
1653             * @param start the lower bound of the range of teams
1654             * @param end the upper bound of the range of teams (not inclusive)
1655             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1656             * @return the ordered range of teams
1657             * @throws SystemException if a system exception occurred
1658             */
1659            @Override
1660            public List<Team> findAll(int start, int end,
1661                    OrderByComparator orderByComparator) throws SystemException {
1662                    boolean pagination = true;
1663                    FinderPath finderPath = null;
1664                    Object[] finderArgs = null;
1665    
1666                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1667                                    (orderByComparator == null)) {
1668                            pagination = false;
1669                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1670                            finderArgs = FINDER_ARGS_EMPTY;
1671                    }
1672                    else {
1673                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1674                            finderArgs = new Object[] { start, end, orderByComparator };
1675                    }
1676    
1677                    List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
1678                                    finderArgs, this);
1679    
1680                    if (list == null) {
1681                            StringBundler query = null;
1682                            String sql = null;
1683    
1684                            if (orderByComparator != null) {
1685                                    query = new StringBundler(2 +
1686                                                    (orderByComparator.getOrderByFields().length * 3));
1687    
1688                                    query.append(_SQL_SELECT_TEAM);
1689    
1690                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1691                                            orderByComparator);
1692    
1693                                    sql = query.toString();
1694                            }
1695                            else {
1696                                    sql = _SQL_SELECT_TEAM;
1697    
1698                                    if (pagination) {
1699                                            sql = sql.concat(TeamModelImpl.ORDER_BY_JPQL);
1700                                    }
1701                            }
1702    
1703                            Session session = null;
1704    
1705                            try {
1706                                    session = openSession();
1707    
1708                                    Query q = session.createQuery(sql);
1709    
1710                                    if (!pagination) {
1711                                            list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1712                                                            end, false);
1713    
1714                                            Collections.sort(list);
1715    
1716                                            list = new UnmodifiableList<Team>(list);
1717                                    }
1718                                    else {
1719                                            list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1720                                                            end);
1721                                    }
1722    
1723                                    cacheResult(list);
1724    
1725                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1726                            }
1727                            catch (Exception e) {
1728                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1729    
1730                                    throw processException(e);
1731                            }
1732                            finally {
1733                                    closeSession(session);
1734                            }
1735                    }
1736    
1737                    return list;
1738            }
1739    
1740            /**
1741             * Removes all the teams from the database.
1742             *
1743             * @throws SystemException if a system exception occurred
1744             */
1745            @Override
1746            public void removeAll() throws SystemException {
1747                    for (Team team : findAll()) {
1748                            remove(team);
1749                    }
1750            }
1751    
1752            /**
1753             * Returns the number of teams.
1754             *
1755             * @return the number of teams
1756             * @throws SystemException if a system exception occurred
1757             */
1758            @Override
1759            public int countAll() throws SystemException {
1760                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1761                                    FINDER_ARGS_EMPTY, this);
1762    
1763                    if (count == null) {
1764                            Session session = null;
1765    
1766                            try {
1767                                    session = openSession();
1768    
1769                                    Query q = session.createQuery(_SQL_COUNT_TEAM);
1770    
1771                                    count = (Long)q.uniqueResult();
1772    
1773                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1774                                            FINDER_ARGS_EMPTY, count);
1775                            }
1776                            catch (Exception e) {
1777                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1778                                            FINDER_ARGS_EMPTY);
1779    
1780                                    throw processException(e);
1781                            }
1782                            finally {
1783                                    closeSession(session);
1784                            }
1785                    }
1786    
1787                    return count.intValue();
1788            }
1789    
1790            /**
1791             * Returns all the users associated with the team.
1792             *
1793             * @param pk the primary key of the team
1794             * @return the users associated with the team
1795             * @throws SystemException if a system exception occurred
1796             */
1797            @Override
1798            public List<com.liferay.portal.model.User> getUsers(long pk)
1799                    throws SystemException {
1800                    return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1801            }
1802    
1803            /**
1804             * Returns a range of all the users associated with the team.
1805             *
1806             * <p>
1807             * 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.TeamModelImpl}. 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.
1808             * </p>
1809             *
1810             * @param pk the primary key of the team
1811             * @param start the lower bound of the range of teams
1812             * @param end the upper bound of the range of teams (not inclusive)
1813             * @return the range of users associated with the team
1814             * @throws SystemException if a system exception occurred
1815             */
1816            @Override
1817            public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1818                    int end) throws SystemException {
1819                    return getUsers(pk, start, end, null);
1820            }
1821    
1822            /**
1823             * Returns an ordered range of all the users associated with the team.
1824             *
1825             * <p>
1826             * 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.TeamModelImpl}. 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.
1827             * </p>
1828             *
1829             * @param pk the primary key of the team
1830             * @param start the lower bound of the range of teams
1831             * @param end the upper bound of the range of teams (not inclusive)
1832             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1833             * @return the ordered range of users associated with the team
1834             * @throws SystemException if a system exception occurred
1835             */
1836            @Override
1837            public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1838                    int end, OrderByComparator orderByComparator) throws SystemException {
1839                    return teamToUserTableMapper.getRightBaseModels(pk, start, end,
1840                            orderByComparator);
1841            }
1842    
1843            /**
1844             * Returns the number of users associated with the team.
1845             *
1846             * @param pk the primary key of the team
1847             * @return the number of users associated with the team
1848             * @throws SystemException if a system exception occurred
1849             */
1850            @Override
1851            public int getUsersSize(long pk) throws SystemException {
1852                    long[] pks = teamToUserTableMapper.getRightPrimaryKeys(pk);
1853    
1854                    return pks.length;
1855            }
1856    
1857            /**
1858             * Returns <code>true</code> if the user is associated with the team.
1859             *
1860             * @param pk the primary key of the team
1861             * @param userPK the primary key of the user
1862             * @return <code>true</code> if the user is associated with the team; <code>false</code> otherwise
1863             * @throws SystemException if a system exception occurred
1864             */
1865            @Override
1866            public boolean containsUser(long pk, long userPK) throws SystemException {
1867                    return teamToUserTableMapper.containsTableMapping(pk, userPK);
1868            }
1869    
1870            /**
1871             * Returns <code>true</code> if the team has any users associated with it.
1872             *
1873             * @param pk the primary key of the team to check for associations with users
1874             * @return <code>true</code> if the team has any users associated with it; <code>false</code> otherwise
1875             * @throws SystemException if a system exception occurred
1876             */
1877            @Override
1878            public boolean containsUsers(long pk) throws SystemException {
1879                    if (getUsersSize(pk) > 0) {
1880                            return true;
1881                    }
1882                    else {
1883                            return false;
1884                    }
1885            }
1886    
1887            /**
1888             * Adds an association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1889             *
1890             * @param pk the primary key of the team
1891             * @param userPK the primary key of the user
1892             * @throws SystemException if a system exception occurred
1893             */
1894            @Override
1895            public void addUser(long pk, long userPK) throws SystemException {
1896                    teamToUserTableMapper.addTableMapping(pk, userPK);
1897            }
1898    
1899            /**
1900             * Adds an association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1901             *
1902             * @param pk the primary key of the team
1903             * @param user the user
1904             * @throws SystemException if a system exception occurred
1905             */
1906            @Override
1907            public void addUser(long pk, com.liferay.portal.model.User user)
1908                    throws SystemException {
1909                    teamToUserTableMapper.addTableMapping(pk, user.getPrimaryKey());
1910            }
1911    
1912            /**
1913             * Adds an association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1914             *
1915             * @param pk the primary key of the team
1916             * @param userPKs the primary keys of the users
1917             * @throws SystemException if a system exception occurred
1918             */
1919            @Override
1920            public void addUsers(long pk, long[] userPKs) throws SystemException {
1921                    for (long userPK : userPKs) {
1922                            teamToUserTableMapper.addTableMapping(pk, userPK);
1923                    }
1924            }
1925    
1926            /**
1927             * Adds an association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1928             *
1929             * @param pk the primary key of the team
1930             * @param users the users
1931             * @throws SystemException if a system exception occurred
1932             */
1933            @Override
1934            public void addUsers(long pk, List<com.liferay.portal.model.User> users)
1935                    throws SystemException {
1936                    for (com.liferay.portal.model.User user : users) {
1937                            teamToUserTableMapper.addTableMapping(pk, user.getPrimaryKey());
1938                    }
1939            }
1940    
1941            /**
1942             * Clears all associations between the team and its users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1943             *
1944             * @param pk the primary key of the team to clear the associated users from
1945             * @throws SystemException if a system exception occurred
1946             */
1947            @Override
1948            public void clearUsers(long pk) throws SystemException {
1949                    teamToUserTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
1950            }
1951    
1952            /**
1953             * Removes the association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1954             *
1955             * @param pk the primary key of the team
1956             * @param userPK the primary key of the user
1957             * @throws SystemException if a system exception occurred
1958             */
1959            @Override
1960            public void removeUser(long pk, long userPK) throws SystemException {
1961                    teamToUserTableMapper.deleteTableMapping(pk, userPK);
1962            }
1963    
1964            /**
1965             * Removes the association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1966             *
1967             * @param pk the primary key of the team
1968             * @param user the user
1969             * @throws SystemException if a system exception occurred
1970             */
1971            @Override
1972            public void removeUser(long pk, com.liferay.portal.model.User user)
1973                    throws SystemException {
1974                    teamToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey());
1975            }
1976    
1977            /**
1978             * Removes the association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1979             *
1980             * @param pk the primary key of the team
1981             * @param userPKs the primary keys of the users
1982             * @throws SystemException if a system exception occurred
1983             */
1984            @Override
1985            public void removeUsers(long pk, long[] userPKs) throws SystemException {
1986                    for (long userPK : userPKs) {
1987                            teamToUserTableMapper.deleteTableMapping(pk, userPK);
1988                    }
1989            }
1990    
1991            /**
1992             * Removes the association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1993             *
1994             * @param pk the primary key of the team
1995             * @param users the users
1996             * @throws SystemException if a system exception occurred
1997             */
1998            @Override
1999            public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2000                    throws SystemException {
2001                    for (com.liferay.portal.model.User user : users) {
2002                            teamToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey());
2003                    }
2004            }
2005    
2006            /**
2007             * Sets the users associated with the team, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2008             *
2009             * @param pk the primary key of the team
2010             * @param userPKs the primary keys of the users to be associated with the team
2011             * @throws SystemException if a system exception occurred
2012             */
2013            @Override
2014            public void setUsers(long pk, long[] userPKs) throws SystemException {
2015                    Set<Long> newUserPKsSet = SetUtil.fromArray(userPKs);
2016                    Set<Long> oldUserPKsSet = SetUtil.fromArray(teamToUserTableMapper.getRightPrimaryKeys(
2017                                            pk));
2018    
2019                    Set<Long> removeUserPKsSet = new HashSet<Long>(oldUserPKsSet);
2020    
2021                    removeUserPKsSet.removeAll(newUserPKsSet);
2022    
2023                    for (long removeUserPK : removeUserPKsSet) {
2024                            teamToUserTableMapper.deleteTableMapping(pk, removeUserPK);
2025                    }
2026    
2027                    newUserPKsSet.removeAll(oldUserPKsSet);
2028    
2029                    for (long newUserPK : newUserPKsSet) {
2030                            teamToUserTableMapper.addTableMapping(pk, newUserPK);
2031                    }
2032            }
2033    
2034            /**
2035             * Sets the users associated with the team, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2036             *
2037             * @param pk the primary key of the team
2038             * @param users the users to be associated with the team
2039             * @throws SystemException if a system exception occurred
2040             */
2041            @Override
2042            public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2043                    throws SystemException {
2044                    try {
2045                            long[] userPKs = new long[users.size()];
2046    
2047                            for (int i = 0; i < users.size(); i++) {
2048                                    com.liferay.portal.model.User user = users.get(i);
2049    
2050                                    userPKs[i] = user.getPrimaryKey();
2051                            }
2052    
2053                            setUsers(pk, userPKs);
2054                    }
2055                    catch (Exception e) {
2056                            throw processException(e);
2057                    }
2058                    finally {
2059                            FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2060                    }
2061            }
2062    
2063            /**
2064             * Returns all the user groups associated with the team.
2065             *
2066             * @param pk the primary key of the team
2067             * @return the user groups associated with the team
2068             * @throws SystemException if a system exception occurred
2069             */
2070            @Override
2071            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
2072                    throws SystemException {
2073                    return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2074            }
2075    
2076            /**
2077             * Returns a range of all the user groups associated with the team.
2078             *
2079             * <p>
2080             * 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.TeamModelImpl}. 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.
2081             * </p>
2082             *
2083             * @param pk the primary key of the team
2084             * @param start the lower bound of the range of teams
2085             * @param end the upper bound of the range of teams (not inclusive)
2086             * @return the range of user groups associated with the team
2087             * @throws SystemException if a system exception occurred
2088             */
2089            @Override
2090            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2091                    int start, int end) throws SystemException {
2092                    return getUserGroups(pk, start, end, null);
2093            }
2094    
2095            /**
2096             * Returns an ordered range of all the user groups associated with the team.
2097             *
2098             * <p>
2099             * 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.TeamModelImpl}. 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.
2100             * </p>
2101             *
2102             * @param pk the primary key of the team
2103             * @param start the lower bound of the range of teams
2104             * @param end the upper bound of the range of teams (not inclusive)
2105             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2106             * @return the ordered range of user groups associated with the team
2107             * @throws SystemException if a system exception occurred
2108             */
2109            @Override
2110            public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2111                    int start, int end, OrderByComparator orderByComparator)
2112                    throws SystemException {
2113                    return teamToUserGroupTableMapper.getRightBaseModels(pk, start, end,
2114                            orderByComparator);
2115            }
2116    
2117            /**
2118             * Returns the number of user groups associated with the team.
2119             *
2120             * @param pk the primary key of the team
2121             * @return the number of user groups associated with the team
2122             * @throws SystemException if a system exception occurred
2123             */
2124            @Override
2125            public int getUserGroupsSize(long pk) throws SystemException {
2126                    long[] pks = teamToUserGroupTableMapper.getRightPrimaryKeys(pk);
2127    
2128                    return pks.length;
2129            }
2130    
2131            /**
2132             * Returns <code>true</code> if the user group is associated with the team.
2133             *
2134             * @param pk the primary key of the team
2135             * @param userGroupPK the primary key of the user group
2136             * @return <code>true</code> if the user group is associated with the team; <code>false</code> otherwise
2137             * @throws SystemException if a system exception occurred
2138             */
2139            @Override
2140            public boolean containsUserGroup(long pk, long userGroupPK)
2141                    throws SystemException {
2142                    return teamToUserGroupTableMapper.containsTableMapping(pk, userGroupPK);
2143            }
2144    
2145            /**
2146             * Returns <code>true</code> if the team has any user groups associated with it.
2147             *
2148             * @param pk the primary key of the team to check for associations with user groups
2149             * @return <code>true</code> if the team has any user groups associated with it; <code>false</code> otherwise
2150             * @throws SystemException if a system exception occurred
2151             */
2152            @Override
2153            public boolean containsUserGroups(long pk) throws SystemException {
2154                    if (getUserGroupsSize(pk) > 0) {
2155                            return true;
2156                    }
2157                    else {
2158                            return false;
2159                    }
2160            }
2161    
2162            /**
2163             * Adds an association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2164             *
2165             * @param pk the primary key of the team
2166             * @param userGroupPK the primary key of the user group
2167             * @throws SystemException if a system exception occurred
2168             */
2169            @Override
2170            public void addUserGroup(long pk, long userGroupPK)
2171                    throws SystemException {
2172                    teamToUserGroupTableMapper.addTableMapping(pk, userGroupPK);
2173            }
2174    
2175            /**
2176             * Adds an association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2177             *
2178             * @param pk the primary key of the team
2179             * @param userGroup the user group
2180             * @throws SystemException if a system exception occurred
2181             */
2182            @Override
2183            public void addUserGroup(long pk,
2184                    com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2185                    teamToUserGroupTableMapper.addTableMapping(pk, userGroup.getPrimaryKey());
2186            }
2187    
2188            /**
2189             * Adds an association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2190             *
2191             * @param pk the primary key of the team
2192             * @param userGroupPKs the primary keys of the user groups
2193             * @throws SystemException if a system exception occurred
2194             */
2195            @Override
2196            public void addUserGroups(long pk, long[] userGroupPKs)
2197                    throws SystemException {
2198                    for (long userGroupPK : userGroupPKs) {
2199                            teamToUserGroupTableMapper.addTableMapping(pk, userGroupPK);
2200                    }
2201            }
2202    
2203            /**
2204             * Adds an association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2205             *
2206             * @param pk the primary key of the team
2207             * @param userGroups the user groups
2208             * @throws SystemException if a system exception occurred
2209             */
2210            @Override
2211            public void addUserGroups(long pk,
2212                    List<com.liferay.portal.model.UserGroup> userGroups)
2213                    throws SystemException {
2214                    for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2215                            teamToUserGroupTableMapper.addTableMapping(pk,
2216                                    userGroup.getPrimaryKey());
2217                    }
2218            }
2219    
2220            /**
2221             * Clears all associations between the team and its user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2222             *
2223             * @param pk the primary key of the team to clear the associated user groups from
2224             * @throws SystemException if a system exception occurred
2225             */
2226            @Override
2227            public void clearUserGroups(long pk) throws SystemException {
2228                    teamToUserGroupTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
2229            }
2230    
2231            /**
2232             * Removes the association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2233             *
2234             * @param pk the primary key of the team
2235             * @param userGroupPK the primary key of the user group
2236             * @throws SystemException if a system exception occurred
2237             */
2238            @Override
2239            public void removeUserGroup(long pk, long userGroupPK)
2240                    throws SystemException {
2241                    teamToUserGroupTableMapper.deleteTableMapping(pk, userGroupPK);
2242            }
2243    
2244            /**
2245             * Removes the association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2246             *
2247             * @param pk the primary key of the team
2248             * @param userGroup the user group
2249             * @throws SystemException if a system exception occurred
2250             */
2251            @Override
2252            public void removeUserGroup(long pk,
2253                    com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2254                    teamToUserGroupTableMapper.deleteTableMapping(pk,
2255                            userGroup.getPrimaryKey());
2256            }
2257    
2258            /**
2259             * Removes the association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2260             *
2261             * @param pk the primary key of the team
2262             * @param userGroupPKs the primary keys of the user groups
2263             * @throws SystemException if a system exception occurred
2264             */
2265            @Override
2266            public void removeUserGroups(long pk, long[] userGroupPKs)
2267                    throws SystemException {
2268                    for (long userGroupPK : userGroupPKs) {
2269                            teamToUserGroupTableMapper.deleteTableMapping(pk, userGroupPK);
2270                    }
2271            }
2272    
2273            /**
2274             * Removes the association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2275             *
2276             * @param pk the primary key of the team
2277             * @param userGroups the user groups
2278             * @throws SystemException if a system exception occurred
2279             */
2280            @Override
2281            public void removeUserGroups(long pk,
2282                    List<com.liferay.portal.model.UserGroup> userGroups)
2283                    throws SystemException {
2284                    for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2285                            teamToUserGroupTableMapper.deleteTableMapping(pk,
2286                                    userGroup.getPrimaryKey());
2287                    }
2288            }
2289    
2290            /**
2291             * Sets the user groups associated with the team, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2292             *
2293             * @param pk the primary key of the team
2294             * @param userGroupPKs the primary keys of the user groups to be associated with the team
2295             * @throws SystemException if a system exception occurred
2296             */
2297            @Override
2298            public void setUserGroups(long pk, long[] userGroupPKs)
2299                    throws SystemException {
2300                    Set<Long> newUserGroupPKsSet = SetUtil.fromArray(userGroupPKs);
2301                    Set<Long> oldUserGroupPKsSet = SetUtil.fromArray(teamToUserGroupTableMapper.getRightPrimaryKeys(
2302                                            pk));
2303    
2304                    Set<Long> removeUserGroupPKsSet = new HashSet<Long>(oldUserGroupPKsSet);
2305    
2306                    removeUserGroupPKsSet.removeAll(newUserGroupPKsSet);
2307    
2308                    for (long removeUserGroupPK : removeUserGroupPKsSet) {
2309                            teamToUserGroupTableMapper.deleteTableMapping(pk, removeUserGroupPK);
2310                    }
2311    
2312                    newUserGroupPKsSet.removeAll(oldUserGroupPKsSet);
2313    
2314                    for (long newUserGroupPK : newUserGroupPKsSet) {
2315                            teamToUserGroupTableMapper.addTableMapping(pk, newUserGroupPK);
2316                    }
2317            }
2318    
2319            /**
2320             * Sets the user groups associated with the team, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2321             *
2322             * @param pk the primary key of the team
2323             * @param userGroups the user groups to be associated with the team
2324             * @throws SystemException if a system exception occurred
2325             */
2326            @Override
2327            public void setUserGroups(long pk,
2328                    List<com.liferay.portal.model.UserGroup> userGroups)
2329                    throws SystemException {
2330                    try {
2331                            long[] userGroupPKs = new long[userGroups.size()];
2332    
2333                            for (int i = 0; i < userGroups.size(); i++) {
2334                                    com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
2335    
2336                                    userGroupPKs[i] = userGroup.getPrimaryKey();
2337                            }
2338    
2339                            setUserGroups(pk, userGroupPKs);
2340                    }
2341                    catch (Exception e) {
2342                            throw processException(e);
2343                    }
2344                    finally {
2345                            FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2346                    }
2347            }
2348    
2349            /**
2350             * Initializes the team persistence.
2351             */
2352            public void afterPropertiesSet() {
2353                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2354                                            com.liferay.portal.util.PropsUtil.get(
2355                                                    "value.object.listener.com.liferay.portal.model.Team")));
2356    
2357                    if (listenerClassNames.length > 0) {
2358                            try {
2359                                    List<ModelListener<Team>> listenersList = new ArrayList<ModelListener<Team>>();
2360    
2361                                    for (String listenerClassName : listenerClassNames) {
2362                                            listenersList.add((ModelListener<Team>)InstanceFactory.newInstance(
2363                                                            getClassLoader(), listenerClassName));
2364                                    }
2365    
2366                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2367                            }
2368                            catch (Exception e) {
2369                                    _log.error(e);
2370                            }
2371                    }
2372    
2373                    teamToUserTableMapper = TableMapperFactory.getTableMapper("Users_Teams",
2374                                    "teamId", "userId", this, userPersistence);
2375    
2376                    teamToUserGroupTableMapper = TableMapperFactory.getTableMapper("UserGroups_Teams",
2377                                    "teamId", "userGroupId", this, userGroupPersistence);
2378            }
2379    
2380            public void destroy() {
2381                    EntityCacheUtil.removeCache(TeamImpl.class.getName());
2382                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2383                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2384                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2385            }
2386    
2387            @BeanReference(type = UserPersistence.class)
2388            protected UserPersistence userPersistence;
2389            protected TableMapper<Team, com.liferay.portal.model.User> teamToUserTableMapper;
2390            @BeanReference(type = UserGroupPersistence.class)
2391            protected UserGroupPersistence userGroupPersistence;
2392            protected TableMapper<Team, com.liferay.portal.model.UserGroup> teamToUserGroupTableMapper;
2393            private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team";
2394            private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE ";
2395            private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team";
2396            private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE ";
2397            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "team.teamId";
2398            private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE ";
2399            private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1 =
2400                    "SELECT {Team.*} FROM (SELECT DISTINCT team.teamId FROM Team team WHERE ";
2401            private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2 =
2402                    ") TEMP_TABLE INNER JOIN Team ON TEMP_TABLE.teamId = Team.teamId";
2403            private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE ";
2404            private static final String _FILTER_ENTITY_ALIAS = "team";
2405            private static final String _FILTER_ENTITY_TABLE = "Team";
2406            private static final String _ORDER_BY_ENTITY_ALIAS = "team.";
2407            private static final String _ORDER_BY_ENTITY_TABLE = "Team.";
2408            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key ";
2409            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {";
2410            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2411            private static Log _log = LogFactoryUtil.getLog(TeamPersistenceImpl.class);
2412            private static Team _nullTeam = new TeamImpl() {
2413                            @Override
2414                            public Object clone() {
2415                                    return this;
2416                            }
2417    
2418                            @Override
2419                            public CacheModel<Team> toCacheModel() {
2420                                    return _nullTeamCacheModel;
2421                            }
2422                    };
2423    
2424            private static CacheModel<Team> _nullTeamCacheModel = new CacheModel<Team>() {
2425                            @Override
2426                            public Team toEntityModel() {
2427                                    return _nullTeam;
2428                            }
2429                    };
2430    }