1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.persistence;
24  
25  import com.liferay.portal.NoSuchUserException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.annotation.BeanReference;
28  import com.liferay.portal.kernel.cache.CacheRegistry;
29  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
30  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
31  import com.liferay.portal.kernel.dao.jdbc.RowMapper;
32  import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
33  import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
34  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
35  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
36  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
37  import com.liferay.portal.kernel.dao.orm.FinderPath;
38  import com.liferay.portal.kernel.dao.orm.Query;
39  import com.liferay.portal.kernel.dao.orm.QueryPos;
40  import com.liferay.portal.kernel.dao.orm.QueryUtil;
41  import com.liferay.portal.kernel.dao.orm.SQLQuery;
42  import com.liferay.portal.kernel.dao.orm.Session;
43  import com.liferay.portal.kernel.dao.orm.Type;
44  import com.liferay.portal.kernel.log.Log;
45  import com.liferay.portal.kernel.log.LogFactoryUtil;
46  import com.liferay.portal.kernel.util.GetterUtil;
47  import com.liferay.portal.kernel.util.OrderByComparator;
48  import com.liferay.portal.kernel.util.StringPool;
49  import com.liferay.portal.kernel.util.StringUtil;
50  import com.liferay.portal.kernel.util.Validator;
51  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
52  import com.liferay.portal.model.ModelListener;
53  import com.liferay.portal.model.User;
54  import com.liferay.portal.model.impl.UserImpl;
55  import com.liferay.portal.model.impl.UserModelImpl;
56  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
57  
58  import java.sql.Types;
59  
60  import java.util.ArrayList;
61  import java.util.Collections;
62  import java.util.List;
63  
64  /**
65   * <a href="UserPersistenceImpl.java.html"><b><i>View Source</i></b></a>
66   *
67   * @author Brian Wing Shun Chan
68   *
69   */
70  public class UserPersistenceImpl extends BasePersistenceImpl
71      implements UserPersistence {
72      public static final String FINDER_CLASS_NAME_ENTITY = UserImpl.class.getName();
73      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74          ".List";
75      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
76              UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
77              "findByUuid", new String[] { String.class.getName() });
78      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
79              UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80              "findByUuid",
81              new String[] {
82                  String.class.getName(),
83                  
84              "java.lang.Integer", "java.lang.Integer",
85                  "com.liferay.portal.kernel.util.OrderByComparator"
86              });
87      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
88              UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89              "countByUuid", new String[] { String.class.getName() });
90      public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
91              UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
92              "findByCompanyId", new String[] { Long.class.getName() });
93      public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
94              UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
95              "findByCompanyId",
96              new String[] {
97                  Long.class.getName(),
98                  
99              "java.lang.Integer", "java.lang.Integer",
100                 "com.liferay.portal.kernel.util.OrderByComparator"
101             });
102     public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
103             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104             "countByCompanyId", new String[] { Long.class.getName() });
105     public static final FinderPath FINDER_PATH_FETCH_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
106             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
107             "fetchByContactId", new String[] { Long.class.getName() });
108     public static final FinderPath FINDER_PATH_COUNT_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
109             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110             "countByContactId", new String[] { Long.class.getName() });
111     public static final FinderPath FINDER_PATH_FIND_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
112             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113             "findByEmailAddress", new String[] { String.class.getName() });
114     public static final FinderPath FINDER_PATH_FIND_BY_OBC_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
115             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116             "findByEmailAddress",
117             new String[] {
118                 String.class.getName(),
119                 
120             "java.lang.Integer", "java.lang.Integer",
121                 "com.liferay.portal.kernel.util.OrderByComparator"
122             });
123     public static final FinderPath FINDER_PATH_COUNT_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
124             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
125             "countByEmailAddress", new String[] { String.class.getName() });
126     public static final FinderPath FINDER_PATH_FETCH_BY_OPENID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
127             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
128             "fetchByOpenId", new String[] { String.class.getName() });
129     public static final FinderPath FINDER_PATH_COUNT_BY_OPENID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
130             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131             "countByOpenId", new String[] { String.class.getName() });
132     public static final FinderPath FINDER_PATH_FETCH_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
133             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
134             "fetchByPortraitId", new String[] { Long.class.getName() });
135     public static final FinderPath FINDER_PATH_COUNT_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
136             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
137             "countByPortraitId", new String[] { Long.class.getName() });
138     public static final FinderPath FINDER_PATH_FETCH_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
139             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
140             "fetchByC_U",
141             new String[] { Long.class.getName(), Long.class.getName() });
142     public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
143             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
144             "countByC_U",
145             new String[] { Long.class.getName(), Long.class.getName() });
146     public static final FinderPath FINDER_PATH_FETCH_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
147             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
148             "fetchByC_DU",
149             new String[] { Long.class.getName(), Boolean.class.getName() });
150     public static final FinderPath FINDER_PATH_COUNT_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
151             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
152             "countByC_DU",
153             new String[] { Long.class.getName(), Boolean.class.getName() });
154     public static final FinderPath FINDER_PATH_FETCH_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
155             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
156             "fetchByC_SN",
157             new String[] { Long.class.getName(), String.class.getName() });
158     public static final FinderPath FINDER_PATH_COUNT_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
159             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
160             "countByC_SN",
161             new String[] { Long.class.getName(), String.class.getName() });
162     public static final FinderPath FINDER_PATH_FETCH_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
163             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
164             "fetchByC_EA",
165             new String[] { Long.class.getName(), String.class.getName() });
166     public static final FinderPath FINDER_PATH_COUNT_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
167             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
168             "countByC_EA",
169             new String[] { Long.class.getName(), String.class.getName() });
170     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
171             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
172             "findAll", new String[0]);
173     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
174             UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
175             "countAll", new String[0]);
176 
177     public void cacheResult(User user) {
178         EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
179             UserImpl.class, user.getPrimaryKey(), user);
180 
181         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
182             new Object[] { new Long(user.getContactId()) }, user);
183 
184         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
185             new Object[] { user.getOpenId() }, user);
186 
187         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
188             new Object[] { new Long(user.getPortraitId()) }, user);
189 
190         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
191             new Object[] {
192                 new Long(user.getCompanyId()), new Long(user.getUserId())
193             }, user);
194 
195         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
196             new Object[] {
197                 new Long(user.getCompanyId()),
198                 Boolean.valueOf(user.getDefaultUser())
199             }, user);
200 
201         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
202             new Object[] { new Long(user.getCompanyId()), user.getScreenName() },
203             user);
204 
205         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
206             new Object[] { new Long(user.getCompanyId()), user.getEmailAddress() },
207             user);
208     }
209 
210     public void cacheResult(List<User> users) {
211         for (User user : users) {
212             if (EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
213                         UserImpl.class, user.getPrimaryKey(), this) == null) {
214                 cacheResult(user);
215             }
216         }
217     }
218 
219     public void clearCache() {
220         CacheRegistry.clear(UserImpl.class.getName());
221         EntityCacheUtil.clearCache(UserImpl.class.getName());
222         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
223         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
224     }
225 
226     public User create(long userId) {
227         User user = new UserImpl();
228 
229         user.setNew(true);
230         user.setPrimaryKey(userId);
231 
232         String uuid = PortalUUIDUtil.generate();
233 
234         user.setUuid(uuid);
235 
236         return user;
237     }
238 
239     public User remove(long userId) throws NoSuchUserException, SystemException {
240         Session session = null;
241 
242         try {
243             session = openSession();
244 
245             User user = (User)session.get(UserImpl.class, new Long(userId));
246 
247             if (user == null) {
248                 if (_log.isWarnEnabled()) {
249                     _log.warn("No User exists with the primary key " + userId);
250                 }
251 
252                 throw new NoSuchUserException(
253                     "No User exists with the primary key " + userId);
254             }
255 
256             return remove(user);
257         }
258         catch (NoSuchUserException nsee) {
259             throw nsee;
260         }
261         catch (Exception e) {
262             throw processException(e);
263         }
264         finally {
265             closeSession(session);
266         }
267     }
268 
269     public User remove(User user) throws SystemException {
270         for (ModelListener<User> listener : listeners) {
271             listener.onBeforeRemove(user);
272         }
273 
274         user = removeImpl(user);
275 
276         for (ModelListener<User> listener : listeners) {
277             listener.onAfterRemove(user);
278         }
279 
280         return user;
281     }
282 
283     protected User removeImpl(User user) throws SystemException {
284         try {
285             clearGroups.clear(user.getPrimaryKey());
286         }
287         catch (Exception e) {
288             throw processException(e);
289         }
290         finally {
291             FinderCacheUtil.clearCache("Users_Groups");
292         }
293 
294         try {
295             clearOrganizations.clear(user.getPrimaryKey());
296         }
297         catch (Exception e) {
298             throw processException(e);
299         }
300         finally {
301             FinderCacheUtil.clearCache("Users_Orgs");
302         }
303 
304         try {
305             clearPermissions.clear(user.getPrimaryKey());
306         }
307         catch (Exception e) {
308             throw processException(e);
309         }
310         finally {
311             FinderCacheUtil.clearCache("Users_Permissions");
312         }
313 
314         try {
315             clearRoles.clear(user.getPrimaryKey());
316         }
317         catch (Exception e) {
318             throw processException(e);
319         }
320         finally {
321             FinderCacheUtil.clearCache("Users_Roles");
322         }
323 
324         try {
325             clearUserGroups.clear(user.getPrimaryKey());
326         }
327         catch (Exception e) {
328             throw processException(e);
329         }
330         finally {
331             FinderCacheUtil.clearCache("Users_UserGroups");
332         }
333 
334         Session session = null;
335 
336         try {
337             session = openSession();
338 
339             if (user.isCachedModel() || BatchSessionUtil.isEnabled()) {
340                 Object staleObject = session.get(UserImpl.class,
341                         user.getPrimaryKeyObj());
342 
343                 if (staleObject != null) {
344                     session.evict(staleObject);
345                 }
346             }
347 
348             session.delete(user);
349 
350             session.flush();
351         }
352         catch (Exception e) {
353             throw processException(e);
354         }
355         finally {
356             closeSession(session);
357         }
358 
359         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
360 
361         UserModelImpl userModelImpl = (UserModelImpl)user;
362 
363         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
364             new Object[] { new Long(userModelImpl.getOriginalContactId()) });
365 
366         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPENID,
367             new Object[] { userModelImpl.getOriginalOpenId() });
368 
369         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
370             new Object[] { new Long(userModelImpl.getOriginalPortraitId()) });
371 
372         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
373             new Object[] {
374                 new Long(userModelImpl.getOriginalCompanyId()),
375                 new Long(userModelImpl.getOriginalUserId())
376             });
377 
378         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
379             new Object[] {
380                 new Long(userModelImpl.getOriginalCompanyId()),
381                 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
382             });
383 
384         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
385             new Object[] {
386                 new Long(userModelImpl.getOriginalCompanyId()),
387                 
388             userModelImpl.getOriginalScreenName()
389             });
390 
391         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
392             new Object[] {
393                 new Long(userModelImpl.getOriginalCompanyId()),
394                 
395             userModelImpl.getOriginalEmailAddress()
396             });
397 
398         EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
399             UserImpl.class, user.getPrimaryKey());
400 
401         return user;
402     }
403 
404     /**
405      * @deprecated Use <code>update(User user, boolean merge)</code>.
406      */
407     public User update(User user) throws SystemException {
408         if (_log.isWarnEnabled()) {
409             _log.warn(
410                 "Using the deprecated update(User user) method. Use update(User user, boolean merge) instead.");
411         }
412 
413         return update(user, false);
414     }
415 
416     /**
417      * Add, update, or merge, the entity. This method also calls the model
418      * listeners to trigger the proper events associated with adding, deleting,
419      * or updating an entity.
420      *
421      * @param        user the entity to add, update, or merge
422      * @param        merge boolean value for whether to merge the entity. The
423      *                default value is false. Setting merge to true is more
424      *                expensive and should only be true when user is
425      *                transient. See LEP-5473 for a detailed discussion of this
426      *                method.
427      * @return        true if the portlet can be displayed via Ajax
428      */
429     public User update(User user, boolean merge) throws SystemException {
430         boolean isNew = user.isNew();
431 
432         for (ModelListener<User> listener : listeners) {
433             if (isNew) {
434                 listener.onBeforeCreate(user);
435             }
436             else {
437                 listener.onBeforeUpdate(user);
438             }
439         }
440 
441         user = updateImpl(user, merge);
442 
443         for (ModelListener<User> listener : listeners) {
444             if (isNew) {
445                 listener.onAfterCreate(user);
446             }
447             else {
448                 listener.onAfterUpdate(user);
449             }
450         }
451 
452         return user;
453     }
454 
455     public User updateImpl(com.liferay.portal.model.User user, boolean merge)
456         throws SystemException {
457         boolean isNew = user.isNew();
458 
459         UserModelImpl userModelImpl = (UserModelImpl)user;
460 
461         if (Validator.isNull(user.getUuid())) {
462             String uuid = PortalUUIDUtil.generate();
463 
464             user.setUuid(uuid);
465         }
466 
467         Session session = null;
468 
469         try {
470             session = openSession();
471 
472             BatchSessionUtil.update(session, user, merge);
473 
474             user.setNew(false);
475         }
476         catch (Exception e) {
477             throw processException(e);
478         }
479         finally {
480             closeSession(session);
481         }
482 
483         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
484 
485         EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
486             UserImpl.class, user.getPrimaryKey(), user);
487 
488         if (!isNew &&
489                 (user.getContactId() != userModelImpl.getOriginalContactId())) {
490             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
491                 new Object[] { new Long(userModelImpl.getOriginalContactId()) });
492         }
493 
494         if (isNew ||
495                 (user.getContactId() != userModelImpl.getOriginalContactId())) {
496             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
497                 new Object[] { new Long(user.getContactId()) }, user);
498         }
499 
500         if (!isNew &&
501                 (!user.getOpenId().equals(userModelImpl.getOriginalOpenId()))) {
502             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPENID,
503                 new Object[] { userModelImpl.getOriginalOpenId() });
504         }
505 
506         if (isNew ||
507                 (!user.getOpenId().equals(userModelImpl.getOriginalOpenId()))) {
508             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
509                 new Object[] { user.getOpenId() }, user);
510         }
511 
512         if (!isNew &&
513                 (user.getPortraitId() != userModelImpl.getOriginalPortraitId())) {
514             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
515                 new Object[] { new Long(userModelImpl.getOriginalPortraitId()) });
516         }
517 
518         if (isNew ||
519                 (user.getPortraitId() != userModelImpl.getOriginalPortraitId())) {
520             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
521                 new Object[] { new Long(user.getPortraitId()) }, user);
522         }
523 
524         if (!isNew &&
525                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
526                 (user.getUserId() != userModelImpl.getOriginalUserId()))) {
527             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
528                 new Object[] {
529                     new Long(userModelImpl.getOriginalCompanyId()),
530                     new Long(userModelImpl.getOriginalUserId())
531                 });
532         }
533 
534         if (isNew ||
535                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
536                 (user.getUserId() != userModelImpl.getOriginalUserId()))) {
537             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
538                 new Object[] {
539                     new Long(user.getCompanyId()), new Long(user.getUserId())
540                 }, user);
541         }
542 
543         if (!isNew &&
544                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
545                 (user.getDefaultUser() != userModelImpl.getOriginalDefaultUser()))) {
546             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
547                 new Object[] {
548                     new Long(userModelImpl.getOriginalCompanyId()),
549                     Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
550                 });
551         }
552 
553         if (isNew ||
554                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
555                 (user.getDefaultUser() != userModelImpl.getOriginalDefaultUser()))) {
556             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
557                 new Object[] {
558                     new Long(user.getCompanyId()),
559                     Boolean.valueOf(user.getDefaultUser())
560                 }, user);
561         }
562 
563         if (!isNew &&
564                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
565                 !user.getScreenName()
566                          .equals(userModelImpl.getOriginalScreenName()))) {
567             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
568                 new Object[] {
569                     new Long(userModelImpl.getOriginalCompanyId()),
570                     
571                 userModelImpl.getOriginalScreenName()
572                 });
573         }
574 
575         if (isNew ||
576                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
577                 !user.getScreenName()
578                          .equals(userModelImpl.getOriginalScreenName()))) {
579             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
580                 new Object[] { new Long(user.getCompanyId()), user.getScreenName() },
581                 user);
582         }
583 
584         if (!isNew &&
585                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
586                 !user.getEmailAddress()
587                          .equals(userModelImpl.getOriginalEmailAddress()))) {
588             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
589                 new Object[] {
590                     new Long(userModelImpl.getOriginalCompanyId()),
591                     
592                 userModelImpl.getOriginalEmailAddress()
593                 });
594         }
595 
596         if (isNew ||
597                 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
598                 !user.getEmailAddress()
599                          .equals(userModelImpl.getOriginalEmailAddress()))) {
600             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
601                 new Object[] {
602                     new Long(user.getCompanyId()),
603                     
604                 user.getEmailAddress()
605                 }, user);
606         }
607 
608         return user;
609     }
610 
611     public User findByPrimaryKey(long userId)
612         throws NoSuchUserException, SystemException {
613         User user = fetchByPrimaryKey(userId);
614 
615         if (user == null) {
616             if (_log.isWarnEnabled()) {
617                 _log.warn("No User exists with the primary key " + userId);
618             }
619 
620             throw new NoSuchUserException(
621                 "No User exists with the primary key " + userId);
622         }
623 
624         return user;
625     }
626 
627     public User fetchByPrimaryKey(long userId) throws SystemException {
628         User user = (User)EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
629                 UserImpl.class, userId, this);
630 
631         if (user == null) {
632             Session session = null;
633 
634             try {
635                 session = openSession();
636 
637                 user = (User)session.get(UserImpl.class, new Long(userId));
638             }
639             catch (Exception e) {
640                 throw processException(e);
641             }
642             finally {
643                 if (user != null) {
644                     cacheResult(user);
645                 }
646 
647                 closeSession(session);
648             }
649         }
650 
651         return user;
652     }
653 
654     public List<User> findByUuid(String uuid) throws SystemException {
655         Object[] finderArgs = new Object[] { uuid };
656 
657         List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
658                 finderArgs, this);
659 
660         if (list == null) {
661             Session session = null;
662 
663             try {
664                 session = openSession();
665 
666                 StringBuilder query = new StringBuilder();
667 
668                 query.append("FROM com.liferay.portal.model.User WHERE ");
669 
670                 if (uuid == null) {
671                     query.append("uuid_ IS NULL");
672                 }
673                 else {
674                     query.append("uuid_ = ?");
675                 }
676 
677                 query.append(" ");
678 
679                 Query q = session.createQuery(query.toString());
680 
681                 QueryPos qPos = QueryPos.getInstance(q);
682 
683                 if (uuid != null) {
684                     qPos.add(uuid);
685                 }
686 
687                 list = q.list();
688             }
689             catch (Exception e) {
690                 throw processException(e);
691             }
692             finally {
693                 if (list == null) {
694                     list = new ArrayList<User>();
695                 }
696 
697                 cacheResult(list);
698 
699                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
700                     list);
701 
702                 closeSession(session);
703             }
704         }
705 
706         return list;
707     }
708 
709     public List<User> findByUuid(String uuid, int start, int end)
710         throws SystemException {
711         return findByUuid(uuid, start, end, null);
712     }
713 
714     public List<User> findByUuid(String uuid, int start, int end,
715         OrderByComparator obc) throws SystemException {
716         Object[] finderArgs = new Object[] {
717                 uuid,
718                 
719                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
720             };
721 
722         List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
723                 finderArgs, this);
724 
725         if (list == null) {
726             Session session = null;
727 
728             try {
729                 session = openSession();
730 
731                 StringBuilder query = new StringBuilder();
732 
733                 query.append("FROM com.liferay.portal.model.User WHERE ");
734 
735                 if (uuid == null) {
736                     query.append("uuid_ IS NULL");
737                 }
738                 else {
739                     query.append("uuid_ = ?");
740                 }
741 
742                 query.append(" ");
743 
744                 if (obc != null) {
745                     query.append("ORDER BY ");
746                     query.append(obc.getOrderBy());
747                 }
748 
749                 Query q = session.createQuery(query.toString());
750 
751                 QueryPos qPos = QueryPos.getInstance(q);
752 
753                 if (uuid != null) {
754                     qPos.add(uuid);
755                 }
756 
757                 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
758             }
759             catch (Exception e) {
760                 throw processException(e);
761             }
762             finally {
763                 if (list == null) {
764                     list = new ArrayList<User>();
765                 }
766 
767                 cacheResult(list);
768 
769                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
770                     finderArgs, list);
771 
772                 closeSession(session);
773             }
774         }
775 
776         return list;
777     }
778 
779     public User findByUuid_First(String uuid, OrderByComparator obc)
780         throws NoSuchUserException, SystemException {
781         List<User> list = findByUuid(uuid, 0, 1, obc);
782 
783         if (list.isEmpty()) {
784             StringBuilder msg = new StringBuilder();
785 
786             msg.append("No User exists with the key {");
787 
788             msg.append("uuid=" + uuid);
789 
790             msg.append(StringPool.CLOSE_CURLY_BRACE);
791 
792             throw new NoSuchUserException(msg.toString());
793         }
794         else {
795             return list.get(0);
796         }
797     }
798 
799     public User findByUuid_Last(String uuid, OrderByComparator obc)
800         throws NoSuchUserException, SystemException {
801         int count = countByUuid(uuid);
802 
803         List<User> list = findByUuid(uuid, count - 1, count, obc);
804 
805         if (list.isEmpty()) {
806             StringBuilder msg = new StringBuilder();
807 
808             msg.append("No User exists with the key {");
809 
810             msg.append("uuid=" + uuid);
811 
812             msg.append(StringPool.CLOSE_CURLY_BRACE);
813 
814             throw new NoSuchUserException(msg.toString());
815         }
816         else {
817             return list.get(0);
818         }
819     }
820 
821     public User[] findByUuid_PrevAndNext(long userId, String uuid,
822         OrderByComparator obc) throws NoSuchUserException, SystemException {
823         User user = findByPrimaryKey(userId);
824 
825         int count = countByUuid(uuid);
826 
827         Session session = null;
828 
829         try {
830             session = openSession();
831 
832             StringBuilder query = new StringBuilder();
833 
834             query.append("FROM com.liferay.portal.model.User WHERE ");
835 
836             if (uuid == null) {
837                 query.append("uuid_ IS NULL");
838             }
839             else {
840                 query.append("uuid_ = ?");
841             }
842 
843             query.append(" ");
844 
845             if (obc != null) {
846                 query.append("ORDER BY ");
847                 query.append(obc.getOrderBy());
848             }
849 
850             Query q = session.createQuery(query.toString());
851 
852             QueryPos qPos = QueryPos.getInstance(q);
853 
854             if (uuid != null) {
855                 qPos.add(uuid);
856             }
857 
858             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, user);
859 
860             User[] array = new UserImpl[3];
861 
862             array[0] = (User)objArray[0];
863             array[1] = (User)objArray[1];
864             array[2] = (User)objArray[2];
865 
866             return array;
867         }
868         catch (Exception e) {
869             throw processException(e);
870         }
871         finally {
872             closeSession(session);
873         }
874     }
875 
876     public List<User> findByCompanyId(long companyId) throws SystemException {
877         Object[] finderArgs = new Object[] { new Long(companyId) };
878 
879         List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
880                 finderArgs, this);
881 
882         if (list == null) {
883             Session session = null;
884 
885             try {
886                 session = openSession();
887 
888                 StringBuilder query = new StringBuilder();
889 
890                 query.append("FROM com.liferay.portal.model.User WHERE ");
891 
892                 query.append("companyId = ?");
893 
894                 query.append(" ");
895 
896                 Query q = session.createQuery(query.toString());
897 
898                 QueryPos qPos = QueryPos.getInstance(q);
899 
900                 qPos.add(companyId);
901 
902                 list = q.list();
903             }
904             catch (Exception e) {
905                 throw processException(e);
906             }
907             finally {
908                 if (list == null) {
909                     list = new ArrayList<User>();
910                 }
911 
912                 cacheResult(list);
913 
914                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
915                     finderArgs, list);
916 
917                 closeSession(session);
918             }
919         }
920 
921         return list;
922     }
923 
924     public List<User> findByCompanyId(long companyId, int start, int end)
925         throws SystemException {
926         return findByCompanyId(companyId, start, end, null);
927     }
928 
929     public List<User> findByCompanyId(long companyId, int start, int end,
930         OrderByComparator obc) throws SystemException {
931         Object[] finderArgs = new Object[] {
932                 new Long(companyId),
933                 
934                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
935             };
936 
937         List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
938                 finderArgs, this);
939 
940         if (list == null) {
941             Session session = null;
942 
943             try {
944                 session = openSession();
945 
946                 StringBuilder query = new StringBuilder();
947 
948                 query.append("FROM com.liferay.portal.model.User WHERE ");
949 
950                 query.append("companyId = ?");
951 
952                 query.append(" ");
953 
954                 if (obc != null) {
955                     query.append("ORDER BY ");
956                     query.append(obc.getOrderBy());
957                 }
958 
959                 Query q = session.createQuery(query.toString());
960 
961                 QueryPos qPos = QueryPos.getInstance(q);
962 
963                 qPos.add(companyId);
964 
965                 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
966             }
967             catch (Exception e) {
968                 throw processException(e);
969             }
970             finally {
971                 if (list == null) {
972                     list = new ArrayList<User>();
973                 }
974 
975                 cacheResult(list);
976 
977                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
978                     finderArgs, list);
979 
980                 closeSession(session);
981             }
982         }
983 
984         return list;
985     }
986 
987     public User findByCompanyId_First(long companyId, OrderByComparator obc)
988         throws NoSuchUserException, SystemException {
989         List<User> list = findByCompanyId(companyId, 0, 1, obc);
990 
991         if (list.isEmpty()) {
992             StringBuilder msg = new StringBuilder();
993 
994             msg.append("No User exists with the key {");
995 
996             msg.append("companyId=" + companyId);
997 
998             msg.append(StringPool.CLOSE_CURLY_BRACE);
999 
1000            throw new NoSuchUserException(msg.toString());
1001        }
1002        else {
1003            return list.get(0);
1004        }
1005    }
1006
1007    public User findByCompanyId_Last(long companyId, OrderByComparator obc)
1008        throws NoSuchUserException, SystemException {
1009        int count = countByCompanyId(companyId);
1010
1011        List<User> list = findByCompanyId(companyId, count - 1, count, obc);
1012
1013        if (list.isEmpty()) {
1014            StringBuilder msg = new StringBuilder();
1015
1016            msg.append("No User exists with the key {");
1017
1018            msg.append("companyId=" + companyId);
1019
1020            msg.append(StringPool.CLOSE_CURLY_BRACE);
1021
1022            throw new NoSuchUserException(msg.toString());
1023        }
1024        else {
1025            return list.get(0);
1026        }
1027    }
1028
1029    public User[] findByCompanyId_PrevAndNext(long userId, long companyId,
1030        OrderByComparator obc) throws NoSuchUserException, SystemException {
1031        User user = findByPrimaryKey(userId);
1032
1033        int count = countByCompanyId(companyId);
1034
1035        Session session = null;
1036
1037        try {
1038            session = openSession();
1039
1040            StringBuilder query = new StringBuilder();
1041
1042            query.append("FROM com.liferay.portal.model.User WHERE ");
1043
1044            query.append("companyId = ?");
1045
1046            query.append(" ");
1047
1048            if (obc != null) {
1049                query.append("ORDER BY ");
1050                query.append(obc.getOrderBy());
1051            }
1052
1053            Query q = session.createQuery(query.toString());
1054
1055            QueryPos qPos = QueryPos.getInstance(q);
1056
1057            qPos.add(companyId);
1058
1059            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, user);
1060
1061            User[] array = new UserImpl[3];
1062
1063            array[0] = (User)objArray[0];
1064            array[1] = (User)objArray[1];
1065            array[2] = (User)objArray[2];
1066
1067            return array;
1068        }
1069        catch (Exception e) {
1070            throw processException(e);
1071        }
1072        finally {
1073            closeSession(session);
1074        }
1075    }
1076
1077    public User findByContactId(long contactId)
1078        throws NoSuchUserException, SystemException {
1079        User user = fetchByContactId(contactId);
1080
1081        if (user == null) {
1082            StringBuilder msg = new StringBuilder();
1083
1084            msg.append("No User exists with the key {");
1085
1086            msg.append("contactId=" + contactId);
1087
1088            msg.append(StringPool.CLOSE_CURLY_BRACE);
1089
1090            if (_log.isWarnEnabled()) {
1091                _log.warn(msg.toString());
1092            }
1093
1094            throw new NoSuchUserException(msg.toString());
1095        }
1096
1097        return user;
1098    }
1099
1100    public User fetchByContactId(long contactId) throws SystemException {
1101        return fetchByContactId(contactId, true);
1102    }
1103
1104    public User fetchByContactId(long contactId, boolean retrieveFromCache)
1105        throws SystemException {
1106        Object[] finderArgs = new Object[] { new Long(contactId) };
1107
1108        Object result = null;
1109
1110        if (retrieveFromCache) {
1111            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CONTACTID,
1112                    finderArgs, this);
1113        }
1114
1115        if (result == null) {
1116            Session session = null;
1117
1118            try {
1119                session = openSession();
1120
1121                StringBuilder query = new StringBuilder();
1122
1123                query.append("FROM com.liferay.portal.model.User WHERE ");
1124
1125                query.append("contactId = ?");
1126
1127                query.append(" ");
1128
1129                Query q = session.createQuery(query.toString());
1130
1131                QueryPos qPos = QueryPos.getInstance(q);
1132
1133                qPos.add(contactId);
1134
1135                List<User> list = q.list();
1136
1137                result = list;
1138
1139                User user = null;
1140
1141                if (list.isEmpty()) {
1142                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1143                        finderArgs, list);
1144                }
1145                else {
1146                    user = list.get(0);
1147
1148                    cacheResult(user);
1149
1150                    if ((user.getContactId() != contactId)) {
1151                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1152                            finderArgs, list);
1153                    }
1154                }
1155
1156                return user;
1157            }
1158            catch (Exception e) {
1159                throw processException(e);
1160            }
1161            finally {
1162                if (result == null) {
1163                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1164                        finderArgs, new ArrayList<User>());
1165                }
1166
1167                closeSession(session);
1168            }
1169        }
1170        else {
1171            if (result instanceof List) {
1172                return null;
1173            }
1174            else {
1175                return (User)result;
1176            }
1177        }
1178    }
1179
1180    public List<User> findByEmailAddress(String emailAddress)
1181        throws SystemException {
1182        Object[] finderArgs = new Object[] { emailAddress };
1183
1184        List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_EMAILADDRESS,
1185                finderArgs, this);
1186
1187        if (list == null) {
1188            Session session = null;
1189
1190            try {
1191                session = openSession();
1192
1193                StringBuilder query = new StringBuilder();
1194
1195                query.append("FROM com.liferay.portal.model.User WHERE ");
1196
1197                if (emailAddress == null) {
1198                    query.append("emailAddress IS NULL");
1199                }
1200                else {
1201                    query.append("emailAddress = ?");
1202                }
1203
1204                query.append(" ");
1205
1206                Query q = session.createQuery(query.toString());
1207
1208                QueryPos qPos = QueryPos.getInstance(q);
1209
1210                if (emailAddress != null) {
1211                    qPos.add(emailAddress);
1212                }
1213
1214                list = q.list();
1215            }
1216            catch (Exception e) {
1217                throw processException(e);
1218            }
1219            finally {
1220                if (list == null) {
1221                    list = new ArrayList<User>();
1222                }
1223
1224                cacheResult(list);
1225
1226                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_EMAILADDRESS,
1227                    finderArgs, list);
1228
1229                closeSession(session);
1230            }
1231        }
1232
1233        return list;
1234    }
1235
1236    public List<User> findByEmailAddress(String emailAddress, int start, int end)
1237        throws SystemException {
1238        return findByEmailAddress(emailAddress, start, end, null);
1239    }
1240
1241    public List<User> findByEmailAddress(String emailAddress, int start,
1242        int end, OrderByComparator obc) throws SystemException {
1243        Object[] finderArgs = new Object[] {
1244                emailAddress,
1245                
1246                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1247            };
1248
1249        List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_EMAILADDRESS,
1250                finderArgs, this);
1251
1252        if (list == null) {
1253            Session session = null;
1254
1255            try {
1256                session = openSession();
1257
1258                StringBuilder query = new StringBuilder();
1259
1260                query.append("FROM com.liferay.portal.model.User WHERE ");
1261
1262                if (emailAddress == null) {
1263                    query.append("emailAddress IS NULL");
1264                }
1265                else {
1266                    query.append("emailAddress = ?");
1267                }
1268
1269                query.append(" ");
1270
1271                if (obc != null) {
1272                    query.append("ORDER BY ");
1273                    query.append(obc.getOrderBy());
1274                }
1275
1276                Query q = session.createQuery(query.toString());
1277
1278                QueryPos qPos = QueryPos.getInstance(q);
1279
1280                if (emailAddress != null) {
1281                    qPos.add(emailAddress);
1282                }
1283
1284                list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1285            }
1286            catch (Exception e) {
1287                throw processException(e);
1288            }
1289            finally {
1290                if (list == null) {
1291                    list = new ArrayList<User>();
1292                }
1293
1294                cacheResult(list);
1295
1296                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_EMAILADDRESS,
1297                    finderArgs, list);
1298
1299                closeSession(session);
1300            }
1301        }
1302
1303        return list;
1304    }
1305
1306    public User findByEmailAddress_First(String emailAddress,
1307        OrderByComparator obc) throws NoSuchUserException, SystemException {
1308        List<User> list = findByEmailAddress(emailAddress, 0, 1, obc);
1309
1310        if (list.isEmpty()) {
1311            StringBuilder msg = new StringBuilder();
1312
1313            msg.append("No User exists with the key {");
1314
1315            msg.append("emailAddress=" + emailAddress);
1316
1317            msg.append(StringPool.CLOSE_CURLY_BRACE);
1318
1319            throw new NoSuchUserException(msg.toString());
1320        }
1321        else {
1322            return list.get(0);
1323        }
1324    }
1325
1326    public User findByEmailAddress_Last(String emailAddress,
1327        OrderByComparator obc) throws NoSuchUserException, SystemException {
1328        int count = countByEmailAddress(emailAddress);
1329
1330        List<User> list = findByEmailAddress(emailAddress, count - 1, count, obc);
1331
1332        if (list.isEmpty()) {
1333            StringBuilder msg = new StringBuilder();
1334
1335            msg.append("No User exists with the key {");
1336
1337            msg.append("emailAddress=" + emailAddress);
1338
1339            msg.append(StringPool.CLOSE_CURLY_BRACE);
1340
1341            throw new NoSuchUserException(msg.toString());
1342        }
1343        else {
1344            return list.get(0);
1345        }
1346    }
1347
1348    public User[] findByEmailAddress_PrevAndNext(long userId,
1349        String emailAddress, OrderByComparator obc)
1350        throws NoSuchUserException, SystemException {
1351        User user = findByPrimaryKey(userId);
1352
1353        int count = countByEmailAddress(emailAddress);
1354
1355        Session session = null;
1356
1357        try {
1358            session = openSession();
1359
1360            StringBuilder query = new StringBuilder();
1361
1362            query.append("FROM com.liferay.portal.model.User WHERE ");
1363
1364            if (emailAddress == null) {
1365                query.append("emailAddress IS NULL");
1366            }
1367            else {
1368                query.append("emailAddress = ?");
1369            }
1370
1371            query.append(" ");
1372
1373            if (obc != null) {
1374                query.append("ORDER BY ");
1375                query.append(obc.getOrderBy());
1376            }
1377
1378            Query q = session.createQuery(query.toString());
1379
1380            QueryPos qPos = QueryPos.getInstance(q);
1381
1382            if (emailAddress != null) {
1383                qPos.add(emailAddress);
1384            }
1385
1386            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, user);
1387
1388            User[] array = new UserImpl[3];
1389
1390            array[0] = (User)objArray[0];
1391            array[1] = (User)objArray[1];
1392            array[2] = (User)objArray[2];
1393
1394            return array;
1395        }
1396        catch (Exception e) {
1397            throw processException(e);
1398        }
1399        finally {
1400            closeSession(session);
1401        }
1402    }
1403
1404    public User findByOpenId(String openId)
1405        throws NoSuchUserException, SystemException {
1406        User user = fetchByOpenId(openId);
1407
1408        if (user == null) {
1409            StringBuilder msg = new StringBuilder();
1410
1411            msg.append("No User exists with the key {");
1412
1413            msg.append("openId=" + openId);
1414
1415            msg.append(StringPool.CLOSE_CURLY_BRACE);
1416
1417            if (_log.isWarnEnabled()) {
1418                _log.warn(msg.toString());
1419            }
1420
1421            throw new NoSuchUserException(msg.toString());
1422        }
1423
1424        return user;
1425    }
1426
1427    public User fetchByOpenId(String openId) throws SystemException {
1428        return fetchByOpenId(openId, true);
1429    }
1430
1431    public User fetchByOpenId(String openId, boolean retrieveFromCache)
1432        throws SystemException {
1433        Object[] finderArgs = new Object[] { openId };
1434
1435        Object result = null;
1436
1437        if (retrieveFromCache) {
1438            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_OPENID,
1439                    finderArgs, this);
1440        }
1441
1442        if (result == null) {
1443            Session session = null;
1444
1445            try {
1446                session = openSession();
1447
1448                StringBuilder query = new StringBuilder();
1449
1450                query.append("FROM com.liferay.portal.model.User WHERE ");
1451
1452                if (openId == null) {
1453                    query.append("openId IS NULL");
1454                }
1455                else {
1456                    query.append("openId = ?");
1457                }
1458
1459                query.append(" ");
1460
1461                Query q = session.createQuery(query.toString());
1462
1463                QueryPos qPos = QueryPos.getInstance(q);
1464
1465                if (openId != null) {
1466                    qPos.add(openId);
1467                }
1468
1469                List<User> list = q.list();
1470
1471                result = list;
1472
1473                User user = null;
1474
1475                if (list.isEmpty()) {
1476                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1477                        finderArgs, list);
1478                }
1479                else {
1480                    user = list.get(0);
1481
1482                    cacheResult(user);
1483
1484                    if ((user.getOpenId() == null) ||
1485                            !user.getOpenId().equals(openId)) {
1486                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1487                            finderArgs, list);
1488                    }
1489                }
1490
1491                return user;
1492            }
1493            catch (Exception e) {
1494                throw processException(e);
1495            }
1496            finally {
1497                if (result == null) {
1498                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1499                        finderArgs, new ArrayList<User>());
1500                }
1501
1502                closeSession(session);
1503            }
1504        }
1505        else {
1506            if (result instanceof List) {
1507                return null;
1508            }
1509            else {
1510                return (User)result;
1511            }
1512        }
1513    }
1514
1515    public User findByPortraitId(long portraitId)
1516        throws NoSuchUserException, SystemException {
1517        User user = fetchByPortraitId(portraitId);
1518
1519        if (user == null) {
1520            StringBuilder msg = new StringBuilder();
1521
1522            msg.append("No User exists with the key {");
1523
1524            msg.append("portraitId=" + portraitId);
1525
1526            msg.append(StringPool.CLOSE_CURLY_BRACE);
1527
1528            if (_log.isWarnEnabled()) {
1529                _log.warn(msg.toString());
1530            }
1531
1532            throw new NoSuchUserException(msg.toString());
1533        }
1534
1535        return user;
1536    }
1537
1538    public User fetchByPortraitId(long portraitId) throws SystemException {
1539        return fetchByPortraitId(portraitId, true);
1540    }
1541
1542    public User fetchByPortraitId(long portraitId, boolean retrieveFromCache)
1543        throws SystemException {
1544        Object[] finderArgs = new Object[] { new Long(portraitId) };
1545
1546        Object result = null;
1547
1548        if (retrieveFromCache) {
1549            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1550                    finderArgs, this);
1551        }
1552
1553        if (result == null) {
1554            Session session = null;
1555
1556            try {
1557                session = openSession();
1558
1559                StringBuilder query = new StringBuilder();
1560
1561                query.append("FROM com.liferay.portal.model.User WHERE ");
1562
1563                query.append("portraitId = ?");
1564
1565                query.append(" ");
1566
1567                Query q = session.createQuery(query.toString());
1568
1569                QueryPos qPos = QueryPos.getInstance(q);
1570
1571                qPos.add(portraitId);
1572
1573                List<User> list = q.list();
1574
1575                result = list;
1576
1577                User user = null;
1578
1579                if (list.isEmpty()) {
1580                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1581                        finderArgs, list);
1582                }
1583                else {
1584                    user = list.get(0);
1585
1586                    cacheResult(user);
1587
1588                    if ((user.getPortraitId() != portraitId)) {
1589                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1590                            finderArgs, list);
1591                    }
1592                }
1593
1594                return user;
1595            }
1596            catch (Exception e) {
1597                throw processException(e);
1598            }
1599            finally {
1600                if (result == null) {
1601                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1602                        finderArgs, new ArrayList<User>());
1603                }
1604
1605                closeSession(session);
1606            }
1607        }
1608        else {
1609            if (result instanceof List) {
1610                return null;
1611            }
1612            else {
1613                return (User)result;
1614            }
1615        }
1616    }
1617
1618    public User findByC_U(long companyId, long userId)
1619        throws NoSuchUserException, SystemException {
1620        User user = fetchByC_U(companyId, userId);
1621
1622        if (user == null) {
1623            StringBuilder msg = new StringBuilder();
1624
1625            msg.append("No User exists with the key {");
1626
1627            msg.append("companyId=" + companyId);
1628
1629            msg.append(", ");
1630            msg.append("userId=" + userId);
1631
1632            msg.append(StringPool.CLOSE_CURLY_BRACE);
1633
1634            if (_log.isWarnEnabled()) {
1635                _log.warn(msg.toString());
1636            }
1637
1638            throw new NoSuchUserException(msg.toString());
1639        }
1640
1641        return user;
1642    }
1643
1644    public User fetchByC_U(long companyId, long userId)
1645        throws SystemException {
1646        return fetchByC_U(companyId, userId, true);
1647    }
1648
1649    public User fetchByC_U(long companyId, long userId,
1650        boolean retrieveFromCache) throws SystemException {
1651        Object[] finderArgs = new Object[] { new Long(companyId), new Long(userId) };
1652
1653        Object result = null;
1654
1655        if (retrieveFromCache) {
1656            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U,
1657                    finderArgs, this);
1658        }
1659
1660        if (result == null) {
1661            Session session = null;
1662
1663            try {
1664                session = openSession();
1665
1666                StringBuilder query = new StringBuilder();
1667
1668                query.append("FROM com.liferay.portal.model.User WHERE ");
1669
1670                query.append("companyId = ?");
1671
1672                query.append(" AND ");
1673
1674                query.append("userId = ?");
1675
1676                query.append(" ");
1677
1678                Query q = session.createQuery(query.toString());
1679
1680                QueryPos qPos = QueryPos.getInstance(q);
1681
1682                qPos.add(companyId);
1683
1684                qPos.add(userId);
1685
1686                List<User> list = q.list();
1687
1688                result = list;
1689
1690                User user = null;
1691
1692                if (list.isEmpty()) {
1693                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1694                        finderArgs, list);
1695                }
1696                else {
1697                    user = list.get(0);
1698
1699                    cacheResult(user);
1700
1701                    if ((user.getCompanyId() != companyId) ||
1702                            (user.getUserId() != userId)) {
1703                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1704                            finderArgs, list);
1705                    }
1706                }
1707
1708                return user;
1709            }
1710            catch (Exception e) {
1711                throw processException(e);
1712            }
1713            finally {
1714                if (result == null) {
1715                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1716                        finderArgs, new ArrayList<User>());
1717                }
1718
1719                closeSession(session);
1720            }
1721        }
1722        else {
1723            if (result instanceof List) {
1724                return null;
1725            }
1726            else {
1727                return (User)result;
1728            }
1729        }
1730    }
1731
1732    public User findByC_DU(long companyId, boolean defaultUser)
1733        throws NoSuchUserException, SystemException {
1734        User user = fetchByC_DU(companyId, defaultUser);
1735
1736        if (user == null) {
1737            StringBuilder msg = new StringBuilder();
1738
1739            msg.append("No User exists with the key {");
1740
1741            msg.append("companyId=" + companyId);
1742
1743            msg.append(", ");
1744            msg.append("defaultUser=" + defaultUser);
1745
1746            msg.append(StringPool.CLOSE_CURLY_BRACE);
1747
1748            if (_log.isWarnEnabled()) {
1749                _log.warn(msg.toString());
1750            }
1751
1752            throw new NoSuchUserException(msg.toString());
1753        }
1754
1755        return user;
1756    }
1757
1758    public User fetchByC_DU(long companyId, boolean defaultUser)
1759        throws SystemException {
1760        return fetchByC_DU(companyId, defaultUser, true);
1761    }
1762
1763    public User fetchByC_DU(long companyId, boolean defaultUser,
1764        boolean retrieveFromCache) throws SystemException {
1765        Object[] finderArgs = new Object[] {
1766                new Long(companyId), Boolean.valueOf(defaultUser)
1767            };
1768
1769        Object result = null;
1770
1771        if (retrieveFromCache) {
1772            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DU,
1773                    finderArgs, this);
1774        }
1775
1776        if (result == null) {
1777            Session session = null;
1778
1779            try {
1780                session = openSession();
1781
1782                StringBuilder query = new StringBuilder();
1783
1784                query.append("FROM com.liferay.portal.model.User WHERE ");
1785
1786                query.append("companyId = ?");
1787
1788                query.append(" AND ");
1789
1790                query.append("defaultUser = ?");
1791
1792                query.append(" ");
1793
1794                Query q = session.createQuery(query.toString());
1795
1796                QueryPos qPos = QueryPos.getInstance(q);
1797
1798                qPos.add(companyId);
1799
1800                qPos.add(defaultUser);
1801
1802                List<User> list = q.list();
1803
1804                result = list;
1805
1806                User user = null;
1807
1808                if (list.isEmpty()) {
1809                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1810                        finderArgs, list);
1811                }
1812                else {
1813                    user = list.get(0);
1814
1815                    cacheResult(user);
1816
1817                    if ((user.getCompanyId() != companyId) ||
1818                            (user.getDefaultUser() != defaultUser)) {
1819                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1820                            finderArgs, list);
1821                    }
1822                }
1823
1824                return user;
1825            }
1826            catch (Exception e) {
1827                throw processException(e);
1828            }
1829            finally {
1830                if (result == null) {
1831                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1832                        finderArgs, new ArrayList<User>());
1833                }
1834
1835                closeSession(session);
1836            }
1837        }
1838        else {
1839            if (result instanceof List) {
1840                return null;
1841            }
1842            else {
1843                return (User)result;
1844            }
1845        }
1846    }
1847
1848    public User findByC_SN(long companyId, String screenName)
1849        throws NoSuchUserException, SystemException {
1850        User user = fetchByC_SN(companyId, screenName);
1851
1852        if (user == null) {
1853            StringBuilder msg = new StringBuilder();
1854
1855            msg.append("No User exists with the key {");
1856
1857            msg.append("companyId=" + companyId);
1858
1859            msg.append(", ");
1860            msg.append("screenName=" + screenName);
1861
1862            msg.append(StringPool.CLOSE_CURLY_BRACE);
1863
1864            if (_log.isWarnEnabled()) {
1865                _log.warn(msg.toString());
1866            }
1867
1868            throw new NoSuchUserException(msg.toString());
1869        }
1870
1871        return user;
1872    }
1873
1874    public User fetchByC_SN(long companyId, String screenName)
1875        throws SystemException {
1876        return fetchByC_SN(companyId, screenName, true);
1877    }
1878
1879    public User fetchByC_SN(long companyId, String screenName,
1880        boolean retrieveFromCache) throws SystemException {
1881        Object[] finderArgs = new Object[] { new Long(companyId), screenName };
1882
1883        Object result = null;
1884
1885        if (retrieveFromCache) {
1886            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_SN,
1887                    finderArgs, this);
1888        }
1889
1890        if (result == null) {
1891            Session session = null;
1892
1893            try {
1894                session = openSession();
1895
1896                StringBuilder query = new StringBuilder();
1897
1898                query.append("FROM com.liferay.portal.model.User WHERE ");
1899
1900                query.append("companyId = ?");
1901
1902                query.append(" AND ");
1903
1904                if (screenName == null) {
1905                    query.append("screenName IS NULL");
1906                }
1907                else {
1908                    query.append("screenName = ?");
1909                }
1910
1911                query.append(" ");
1912
1913                Query q = session.createQuery(query.toString());
1914
1915                QueryPos qPos = QueryPos.getInstance(q);
1916
1917                qPos.add(companyId);
1918
1919                if (screenName != null) {
1920                    qPos.add(screenName);
1921                }
1922
1923                List<User> list = q.list();
1924
1925                result = list;
1926
1927                User user = null;
1928
1929                if (list.isEmpty()) {
1930                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
1931                        finderArgs, list);
1932                }
1933                else {
1934                    user = list.get(0);
1935
1936                    cacheResult(user);
1937
1938                    if ((user.getCompanyId() != companyId) ||
1939                            (user.getScreenName() == null) ||
1940                            !user.getScreenName().equals(screenName)) {
1941                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
1942                            finderArgs, list);
1943                    }
1944                }
1945
1946                return user;
1947            }
1948            catch (Exception e) {
1949                throw processException(e);
1950            }
1951            finally {
1952                if (result == null) {
1953                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
1954                        finderArgs, new ArrayList<User>());
1955                }
1956
1957                closeSession(session);
1958            }
1959        }
1960        else {
1961            if (result instanceof List) {
1962                return null;
1963            }
1964            else {
1965                return (User)result;
1966            }
1967        }
1968    }
1969
1970    public User findByC_EA(long companyId, String emailAddress)
1971        throws NoSuchUserException, SystemException {
1972        User user = fetchByC_EA(companyId, emailAddress);
1973
1974        if (user == null) {
1975            StringBuilder msg = new StringBuilder();
1976
1977            msg.append("No User exists with the key {");
1978
1979            msg.append("companyId=" + companyId);
1980
1981            msg.append(", ");
1982            msg.append("emailAddress=" + emailAddress);
1983
1984            msg.append(StringPool.CLOSE_CURLY_BRACE);
1985
1986            if (_log.isWarnEnabled()) {
1987                _log.warn(msg.toString());
1988            }
1989
1990            throw new NoSuchUserException(msg.toString());
1991        }
1992
1993        return user;
1994    }
1995
1996    public User fetchByC_EA(long companyId, String emailAddress)
1997        throws SystemException {
1998        return fetchByC_EA(companyId, emailAddress, true);
1999    }
2000
2001    public User fetchByC_EA(long companyId, String emailAddress,
2002        boolean retrieveFromCache) throws SystemException {
2003        Object[] finderArgs = new Object[] { new Long(companyId), emailAddress };
2004
2005        Object result = null;
2006
2007        if (retrieveFromCache) {
2008            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_EA,
2009                    finderArgs, this);
2010        }
2011
2012        if (result == null) {
2013            Session session = null;
2014
2015            try {
2016                session = openSession();
2017
2018                StringBuilder query = new StringBuilder();
2019
2020                query.append("FROM com.liferay.portal.model.User WHERE ");
2021
2022                query.append("companyId = ?");
2023
2024                query.append(" AND ");
2025
2026                if (emailAddress == null) {
2027                    query.append("emailAddress IS NULL");
2028                }
2029                else {
2030                    query.append("emailAddress = ?");
2031                }
2032
2033                query.append(" ");
2034
2035                Query q = session.createQuery(query.toString());
2036
2037                QueryPos qPos = QueryPos.getInstance(q);
2038
2039                qPos.add(companyId);
2040
2041                if (emailAddress != null) {
2042                    qPos.add(emailAddress);
2043                }
2044
2045                List<User> list = q.list();
2046
2047                result = list;
2048
2049                User user = null;
2050
2051                if (list.isEmpty()) {
2052                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2053                        finderArgs, list);
2054                }
2055                else {
2056                    user = list.get(0);
2057
2058                    cacheResult(user);
2059
2060                    if ((user.getCompanyId() != companyId) ||
2061                            (user.getEmailAddress() == null) ||
2062                            !user.getEmailAddress().equals(emailAddress)) {
2063                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2064                            finderArgs, list);
2065                    }
2066                }
2067
2068                return user;
2069            }
2070            catch (Exception e) {
2071                throw processException(e);
2072            }
2073            finally {
2074                if (result == null) {
2075                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2076                        finderArgs, new ArrayList<User>());
2077                }
2078
2079                closeSession(session);
2080            }
2081        }
2082        else {
2083            if (result instanceof List) {
2084                return null;
2085            }
2086            else {
2087                return (User)result;
2088            }
2089        }
2090    }
2091
2092    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2093        throws SystemException {
2094        Session session = null;
2095
2096        try {
2097            session = openSession();
2098
2099            dynamicQuery.compile(session);
2100
2101            return dynamicQuery.list();
2102        }
2103        catch (Exception e) {
2104            throw processException(e);
2105        }
2106        finally {
2107            closeSession(session);
2108        }
2109    }
2110
2111    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2112        int start, int end) throws SystemException {
2113        Session session = null;
2114
2115        try {
2116            session = openSession();
2117
2118            dynamicQuery.setLimit(start, end);
2119
2120            dynamicQuery.compile(session);
2121
2122            return dynamicQuery.list();
2123        }
2124        catch (Exception e) {
2125            throw processException(e);
2126        }
2127        finally {
2128            closeSession(session);
2129        }
2130    }
2131
2132    public List<User> findAll() throws SystemException {
2133        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2134    }
2135
2136    public List<User> findAll(int start, int end) throws SystemException {
2137        return findAll(start, end, null);
2138    }
2139
2140    public List<User> findAll(int start, int end, OrderByComparator obc)
2141        throws SystemException {
2142        Object[] finderArgs = new Object[] {
2143                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2144            };
2145
2146        List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2147                finderArgs, this);
2148
2149        if (list == null) {
2150            Session session = null;
2151
2152            try {
2153                session = openSession();
2154
2155                StringBuilder query = new StringBuilder();
2156
2157                query.append("FROM com.liferay.portal.model.User ");
2158
2159                if (obc != null) {
2160                    query.append("ORDER BY ");
2161                    query.append(obc.getOrderBy());
2162                }
2163
2164                Query q = session.createQuery(query.toString());
2165
2166                if (obc == null) {
2167                    list = (List<User>)QueryUtil.list(q, getDialect(), start,
2168                            end, false);
2169
2170                    Collections.sort(list);
2171                }
2172                else {
2173                    list = (List<User>)QueryUtil.list(q, getDialect(), start,
2174                            end);
2175                }
2176            }
2177            catch (Exception e) {
2178                throw processException(e);
2179            }
2180            finally {
2181                if (list == null) {
2182                    list = new ArrayList<User>();
2183                }
2184
2185                cacheResult(list);
2186
2187                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2188
2189                closeSession(session);
2190            }
2191        }
2192
2193        return list;
2194    }
2195
2196    public void removeByUuid(String uuid) throws SystemException {
2197        for (User user : findByUuid(uuid)) {
2198            remove(user);
2199        }
2200    }
2201
2202    public void removeByCompanyId(long companyId) throws SystemException {
2203        for (User user : findByCompanyId(companyId)) {
2204            remove(user);
2205        }
2206    }
2207
2208    public void removeByContactId(long contactId)
2209        throws NoSuchUserException, SystemException {
2210        User user = findByContactId(contactId);
2211
2212        remove(user);
2213    }
2214
2215    public void removeByEmailAddress(String emailAddress)
2216        throws SystemException {
2217        for (User user : findByEmailAddress(emailAddress)) {
2218            remove(user);
2219        }
2220    }
2221
2222    public void removeByOpenId(String openId)
2223        throws NoSuchUserException, SystemException {
2224        User user = findByOpenId(openId);
2225
2226        remove(user);
2227    }
2228
2229    public void removeByPortraitId(long portraitId)
2230        throws NoSuchUserException, SystemException {
2231        User user = findByPortraitId(portraitId);
2232
2233        remove(user);
2234    }
2235
2236    public void removeByC_U(long companyId, long userId)
2237        throws NoSuchUserException, SystemException {
2238        User user = findByC_U(companyId, userId);
2239
2240        remove(user);
2241    }
2242
2243    public void removeByC_DU(long companyId, boolean defaultUser)
2244        throws NoSuchUserException, SystemException {
2245        User user = findByC_DU(companyId, defaultUser);
2246
2247        remove(user);
2248    }
2249
2250    public void removeByC_SN(long companyId, String screenName)
2251        throws NoSuchUserException, SystemException {
2252        User user = findByC_SN(companyId, screenName);
2253
2254        remove(user);
2255    }
2256
2257    public void removeByC_EA(long companyId, String emailAddress)
2258        throws NoSuchUserException, SystemException {
2259        User user = findByC_EA(companyId, emailAddress);
2260
2261        remove(user);
2262    }
2263
2264    public void removeAll() throws SystemException {
2265        for (User user : findAll()) {
2266            remove(user);
2267        }
2268    }
2269
2270    public int countByUuid(String uuid) throws SystemException {
2271        Object[] finderArgs = new Object[] { uuid };
2272
2273        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2274                finderArgs, this);
2275
2276        if (count == null) {
2277            Session session = null;
2278
2279            try {
2280                session = openSession();
2281
2282                StringBuilder query = new StringBuilder();
2283
2284                query.append("SELECT COUNT(*) ");
2285                query.append("FROM com.liferay.portal.model.User WHERE ");
2286
2287                if (uuid == null) {
2288                    query.append("uuid_ IS NULL");
2289                }
2290                else {
2291                    query.append("uuid_ = ?");
2292                }
2293
2294                query.append(" ");
2295
2296                Query q = session.createQuery(query.toString());
2297
2298                QueryPos qPos = QueryPos.getInstance(q);
2299
2300                if (uuid != null) {
2301                    qPos.add(uuid);
2302                }
2303
2304                count = (Long)q.uniqueResult();
2305            }
2306            catch (Exception e) {
2307                throw processException(e);
2308            }
2309            finally {
2310                if (count == null) {
2311                    count = Long.valueOf(0);
2312                }
2313
2314                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2315                    finderArgs, count);
2316
2317                closeSession(session);
2318            }
2319        }
2320
2321        return count.intValue();
2322    }
2323
2324    public int countByCompanyId(long companyId) throws SystemException {
2325        Object[] finderArgs = new Object[] { new Long(companyId) };
2326
2327        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2328                finderArgs, this);
2329
2330        if (count == null) {
2331            Session session = null;
2332
2333            try {
2334                session = openSession();
2335
2336                StringBuilder query = new StringBuilder();
2337
2338                query.append("SELECT COUNT(*) ");
2339                query.append("FROM com.liferay.portal.model.User WHERE ");
2340
2341                query.append("companyId = ?");
2342
2343                query.append(" ");
2344
2345                Query q = session.createQuery(query.toString());
2346
2347                QueryPos qPos = QueryPos.getInstance(q);
2348
2349                qPos.add(companyId);
2350
2351                count = (Long)q.uniqueResult();
2352            }
2353            catch (Exception e) {
2354                throw processException(e);
2355            }
2356            finally {
2357                if (count == null) {
2358                    count = Long.valueOf(0);
2359                }
2360
2361                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2362                    finderArgs, count);
2363
2364                closeSession(session);
2365            }
2366        }
2367
2368        return count.intValue();
2369    }
2370
2371    public int countByContactId(long contactId) throws SystemException {
2372        Object[] finderArgs = new Object[] { new Long(contactId) };
2373
2374        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CONTACTID,
2375                finderArgs, this);
2376
2377        if (count == null) {
2378            Session session = null;
2379
2380            try {
2381                session = openSession();
2382
2383                StringBuilder query = new StringBuilder();
2384
2385                query.append("SELECT COUNT(*) ");
2386                query.append("FROM com.liferay.portal.model.User WHERE ");
2387
2388                query.append("contactId = ?");
2389
2390                query.append(" ");
2391
2392                Query q = session.createQuery(query.toString());
2393
2394                QueryPos qPos = QueryPos.getInstance(q);
2395
2396                qPos.add(contactId);
2397
2398                count = (Long)q.uniqueResult();
2399            }
2400            catch (Exception e) {
2401                throw processException(e);
2402            }
2403            finally {
2404                if (count == null) {
2405                    count = Long.valueOf(0);
2406                }
2407
2408                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CONTACTID,
2409                    finderArgs, count);
2410
2411                closeSession(session);
2412            }
2413        }
2414
2415        return count.intValue();
2416    }
2417
2418    public int countByEmailAddress(String emailAddress)
2419        throws SystemException {
2420        Object[] finderArgs = new Object[] { emailAddress };
2421
2422        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
2423                finderArgs, this);
2424
2425        if (count == null) {
2426            Session session = null;
2427
2428            try {
2429                session = openSession();
2430
2431                StringBuilder query = new StringBuilder();
2432
2433                query.append("SELECT COUNT(*) ");
2434                query.append("FROM com.liferay.portal.model.User WHERE ");
2435
2436                if (emailAddress == null) {
2437                    query.append("emailAddress IS NULL");
2438                }
2439                else {
2440                    query.append("emailAddress = ?");
2441                }
2442
2443                query.append(" ");
2444
2445                Query q = session.createQuery(query.toString());
2446
2447                QueryPos qPos = QueryPos.getInstance(q);
2448
2449                if (emailAddress != null) {
2450                    qPos.add(emailAddress);
2451                }
2452
2453                count = (Long)q.uniqueResult();
2454            }
2455            catch (Exception e) {
2456                throw processException(e);
2457            }
2458            finally {
2459                if (count == null) {
2460                    count = Long.valueOf(0);
2461                }
2462
2463                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
2464                    finderArgs, count);
2465
2466                closeSession(session);
2467            }
2468        }
2469
2470        return count.intValue();
2471    }
2472
2473    public int countByOpenId(String openId) throws SystemException {
2474        Object[] finderArgs = new Object[] { openId };
2475
2476        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_OPENID,
2477                finderArgs, this);
2478
2479        if (count == null) {
2480            Session session = null;
2481
2482            try {
2483                session = openSession();
2484
2485                StringBuilder query = new StringBuilder();
2486
2487                query.append("SELECT COUNT(*) ");
2488                query.append("FROM com.liferay.portal.model.User WHERE ");
2489
2490                if (openId == null) {
2491                    query.append("openId IS NULL");
2492                }
2493                else {
2494                    query.append("openId = ?");
2495                }
2496
2497                query.append(" ");
2498
2499                Query q = session.createQuery(query.toString());
2500
2501                QueryPos qPos = QueryPos.getInstance(q);
2502
2503                if (openId != null) {
2504                    qPos.add(openId);
2505                }
2506
2507                count = (Long)q.uniqueResult();
2508            }
2509            catch (Exception e) {
2510                throw processException(e);
2511            }
2512            finally {
2513                if (count == null) {
2514                    count = Long.valueOf(0);
2515                }
2516
2517                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_OPENID,
2518                    finderArgs, count);
2519
2520                closeSession(session);
2521            }
2522        }
2523
2524        return count.intValue();
2525    }
2526
2527    public int countByPortraitId(long portraitId) throws SystemException {
2528        Object[] finderArgs = new Object[] { new Long(portraitId) };
2529
2530        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PORTRAITID,
2531                finderArgs, this);
2532
2533        if (count == null) {
2534            Session session = null;
2535
2536            try {
2537                session = openSession();
2538
2539                StringBuilder query = new StringBuilder();
2540
2541                query.append("SELECT COUNT(*) ");
2542                query.append("FROM com.liferay.portal.model.User WHERE ");
2543
2544                query.append("portraitId = ?");
2545
2546                query.append(" ");
2547
2548                Query q = session.createQuery(query.toString());
2549
2550                QueryPos qPos = QueryPos.getInstance(q);
2551
2552                qPos.add(portraitId);
2553
2554                count = (Long)q.uniqueResult();
2555            }
2556            catch (Exception e) {
2557                throw processException(e);
2558            }
2559            finally {
2560                if (count == null) {
2561                    count = Long.valueOf(0);
2562                }
2563
2564                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PORTRAITID,
2565                    finderArgs, count);
2566
2567                closeSession(session);
2568            }
2569        }
2570
2571        return count.intValue();
2572    }
2573
2574    public int countByC_U(long companyId, long userId)
2575        throws SystemException {
2576        Object[] finderArgs = new Object[] { new Long(companyId), new Long(userId) };
2577
2578        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U,
2579                finderArgs, this);
2580
2581        if (count == null) {
2582            Session session = null;
2583
2584            try {
2585                session = openSession();
2586
2587                StringBuilder query = new StringBuilder();
2588
2589                query.append("SELECT COUNT(*) ");
2590                query.append("FROM com.liferay.portal.model.User WHERE ");
2591
2592                query.append("companyId = ?");
2593
2594                query.append(" AND ");
2595
2596                query.append("userId = ?");
2597
2598                query.append(" ");
2599
2600                Query q = session.createQuery(query.toString());
2601
2602                QueryPos qPos = QueryPos.getInstance(q);
2603
2604                qPos.add(companyId);
2605
2606                qPos.add(userId);
2607
2608                count = (Long)q.uniqueResult();
2609            }
2610            catch (Exception e) {
2611                throw processException(e);
2612            }
2613            finally {
2614                if (count == null) {
2615                    count = Long.valueOf(0);
2616                }
2617
2618                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, finderArgs,
2619                    count);
2620
2621                closeSession(session);
2622            }
2623        }
2624
2625        return count.intValue();
2626    }
2627
2628    public int countByC_DU(long companyId, boolean defaultUser)
2629        throws SystemException {
2630        Object[] finderArgs = new Object[] {
2631                new Long(companyId), Boolean.valueOf(defaultUser)
2632            };
2633
2634        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_DU,
2635                finderArgs, this);
2636
2637        if (count == null) {
2638            Session session = null;
2639
2640            try {
2641                session = openSession();
2642
2643                StringBuilder query = new StringBuilder();
2644
2645                query.append("SELECT COUNT(*) ");
2646                query.append("FROM com.liferay.portal.model.User WHERE ");
2647
2648                query.append("companyId = ?");
2649
2650                query.append(" AND ");
2651
2652                query.append("defaultUser = ?");
2653
2654                query.append(" ");
2655
2656                Query q = session.createQuery(query.toString());
2657
2658                QueryPos qPos = QueryPos.getInstance(q);
2659
2660                qPos.add(companyId);
2661
2662                qPos.add(defaultUser);
2663
2664                count = (Long)q.uniqueResult();
2665            }
2666            catch (Exception e) {
2667                throw processException(e);
2668            }
2669            finally {
2670                if (count == null) {
2671                    count = Long.valueOf(0);
2672                }
2673
2674                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DU,
2675                    finderArgs, count);
2676
2677                closeSession(session);
2678            }
2679        }
2680
2681        return count.intValue();
2682    }
2683
2684    public int countByC_SN(long companyId, String screenName)
2685        throws SystemException {
2686        Object[] finderArgs = new Object[] { new Long(companyId), screenName };
2687
2688        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_SN,
2689                finderArgs, this);
2690
2691        if (count == null) {
2692            Session session = null;
2693
2694            try {
2695                session = openSession();
2696
2697                StringBuilder query = new StringBuilder();
2698
2699                query.append("SELECT COUNT(*) ");
2700                query.append("FROM com.liferay.portal.model.User WHERE ");
2701
2702                query.append("companyId = ?");
2703
2704                query.append(" AND ");
2705
2706                if (screenName == null) {
2707                    query.append("screenName IS NULL");
2708                }
2709                else {
2710                    query.append("screenName = ?");
2711                }
2712
2713                query.append(" ");
2714
2715                Query q = session.createQuery(query.toString());
2716
2717                QueryPos qPos = QueryPos.getInstance(q);
2718
2719                qPos.add(companyId);
2720
2721                if (screenName != null) {
2722                    qPos.add(screenName);
2723                }
2724
2725                count = (Long)q.uniqueResult();
2726            }
2727            catch (Exception e) {
2728                throw processException(e);
2729            }
2730            finally {
2731                if (count == null) {
2732                    count = Long.valueOf(0);
2733                }
2734
2735                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_SN,
2736                    finderArgs, count);
2737
2738                closeSession(session);
2739            }
2740        }
2741
2742        return count.intValue();
2743    }
2744
2745    public int countByC_EA(long companyId, String emailAddress)
2746        throws SystemException {
2747        Object[] finderArgs = new Object[] { new Long(companyId), emailAddress };
2748
2749        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_EA,
2750                finderArgs, this);
2751
2752        if (count == null) {
2753            Session session = null;
2754
2755            try {
2756                session = openSession();
2757
2758                StringBuilder query = new StringBuilder();
2759
2760                query.append("SELECT COUNT(*) ");
2761                query.append("FROM com.liferay.portal.model.User WHERE ");
2762
2763                query.append("companyId = ?");
2764
2765                query.append(" AND ");
2766
2767                if (emailAddress == null) {
2768                    query.append("emailAddress IS NULL");
2769                }
2770                else {
2771                    query.append("emailAddress = ?");
2772                }
2773
2774                query.append(" ");
2775
2776                Query q = session.createQuery(query.toString());
2777
2778                QueryPos qPos = QueryPos.getInstance(q);
2779
2780                qPos.add(companyId);
2781
2782                if (emailAddress != null) {
2783                    qPos.add(emailAddress);
2784                }
2785
2786                count = (Long)q.uniqueResult();
2787            }
2788            catch (Exception e) {
2789                throw processException(e);
2790            }
2791            finally {
2792                if (count == null) {
2793                    count = Long.valueOf(0);
2794                }
2795
2796                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_EA,
2797                    finderArgs, count);
2798
2799                closeSession(session);
2800            }
2801        }
2802
2803        return count.intValue();
2804    }
2805
2806    public int countAll() throws SystemException {
2807        Object[] finderArgs = new Object[0];
2808
2809        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2810                finderArgs, this);
2811
2812        if (count == null) {
2813            Session session = null;
2814
2815            try {
2816                session = openSession();
2817
2818                Query q = session.createQuery(
2819                        "SELECT COUNT(*) FROM com.liferay.portal.model.User");
2820
2821                count = (Long)q.uniqueResult();
2822            }
2823            catch (Exception e) {
2824                throw processException(e);
2825            }
2826            finally {
2827                if (count == null) {
2828                    count = Long.valueOf(0);
2829                }
2830
2831                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2832                    count);
2833
2834                closeSession(session);
2835            }
2836        }
2837
2838        return count.intValue();
2839    }
2840
2841    public List<com.liferay.portal.model.Group> getGroups(long pk)
2842        throws SystemException {
2843        return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2844    }
2845
2846    public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2847        int end) throws SystemException {
2848        return getGroups(pk, start, end, null);
2849    }
2850
2851    public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2852            UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
2853            "getGroups",
2854            new String[] {
2855                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2856                "com.liferay.portal.kernel.util.OrderByComparator"
2857            });
2858
2859    public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2860        int end, OrderByComparator obc) throws SystemException {
2861        Object[] finderArgs = new Object[] {
2862                new Long(pk), String.valueOf(start), String.valueOf(end),
2863                String.valueOf(obc)
2864            };
2865
2866        List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
2867                finderArgs, this);
2868
2869        if (list == null) {
2870            Session session = null;
2871
2872            try {
2873                session = openSession();
2874
2875                StringBuilder sb = new StringBuilder();
2876
2877                sb.append(_SQL_GETGROUPS);
2878
2879                if (obc != null) {
2880                    sb.append("ORDER BY ");
2881                    sb.append(obc.getOrderBy());
2882                }
2883
2884                else {
2885                    sb.append("ORDER BY ");
2886
2887                    sb.append("Group_.name ASC");
2888                }
2889
2890                String sql = sb.toString();
2891
2892                SQLQuery q = session.createSQLQuery(sql);
2893
2894                q.addEntity("Group_",
2895                    com.liferay.portal.model.impl.GroupImpl.class);
2896
2897                QueryPos qPos = QueryPos.getInstance(q);
2898
2899                qPos.add(pk);
2900
2901                list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
2902                        getDialect(), start, end);
2903            }
2904            catch (Exception e) {
2905                throw processException(e);
2906            }
2907            finally {
2908                if (list == null) {
2909                    list = new ArrayList<com.liferay.portal.model.Group>();
2910                }
2911
2912                groupPersistence.cacheResult(list);
2913
2914                FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
2915                    list);
2916
2917                closeSession(session);
2918            }
2919        }
2920
2921        return list;
2922    }
2923
2924    public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2925            UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
2926            "getGroupsSize", new String[] { Long.class.getName() });
2927
2928    public int getGroupsSize(long pk) throws SystemException {
2929        Object[] finderArgs = new Object[] { new Long(pk) };
2930
2931        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
2932                finderArgs, this);
2933
2934        if (count == null) {
2935            Session session = null;
2936
2937            try {
2938                session = openSession();
2939
2940                SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
2941
2942                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2943
2944                QueryPos qPos = QueryPos.getInstance(q);
2945
2946                qPos.add(pk);
2947
2948                count = (Long)q.uniqueResult();
2949            }
2950            catch (Exception e) {
2951                throw processException(e);
2952            }
2953            finally {
2954                if (count == null) {
2955                    count = Long.valueOf(0);
2956                }
2957
2958                FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
2959                    finderArgs, count);
2960
2961                closeSession(session);
2962            }
2963        }
2964
2965        return count.intValue();
2966    }
2967
2968    public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2969            UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
2970            "containsGroup",
2971            new String[] { Long.class.getName(), Long.class.getName() });
2972
2973    public boolean containsGroup(long pk, long groupPK)
2974        throws SystemException {
2975        Object[] finderArgs = new Object[] { new Long(pk), new Long(groupPK) };
2976
2977        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
2978                finderArgs, this);
2979
2980        if (value == null) {
2981            try {
2982                value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
2983            }
2984            catch (Exception e) {
2985                throw processException(e);
2986            }
2987            finally {
2988                if (value == null) {
2989                    value = Boolean.FALSE;
2990                }
2991
2992                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
2993                    finderArgs, value);
2994            }
2995        }
2996
2997        return value.booleanValue();
2998    }
2999
3000    public boolean containsGroups(long pk) throws SystemException {
3001        if (getGroupsSize(pk) > 0) {
3002            return true;
3003        }
3004        else {
3005            return false;
3006        }
3007    }
3008
3009    public void addGroup(long pk, long groupPK) throws SystemException {
3010        try {
3011            addGroup.add(pk, groupPK);
3012        }
3013        catch (Exception e) {
3014            throw processException(e);
3015        }
3016        finally {
3017            FinderCacheUtil.clearCache("Users_Groups");
3018        }
3019    }
3020
3021    public void addGroup(long pk, com.liferay.portal.model.Group group)
3022        throws SystemException {
3023        try {
3024            addGroup.add(pk, group.getPrimaryKey());
3025        }
3026        catch (Exception e) {
3027            throw processException(e);
3028        }
3029        finally {
3030            FinderCacheUtil.clearCache("Users_Groups");
3031        }
3032    }
3033
3034    public void addGroups(long pk, long[] groupPKs) throws SystemException {
3035        try {
3036            for (long groupPK : groupPKs) {
3037                addGroup.add(pk, groupPK);
3038            }
3039        }
3040        catch (Exception e) {
3041            throw processException(e);
3042        }
3043        finally {
3044            FinderCacheUtil.clearCache("Users_Groups");
3045        }
3046    }
3047
3048    public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
3049        throws SystemException {
3050        try {
3051            for (com.liferay.portal.model.Group group : groups) {
3052                addGroup.add(pk, group.getPrimaryKey());
3053            }
3054        }
3055        catch (Exception e) {
3056            throw processException(e);
3057        }
3058        finally {
3059            FinderCacheUtil.clearCache("Users_Groups");
3060        }
3061    }
3062
3063    public void clearGroups(long pk) throws SystemException {
3064        try {
3065            clearGroups.clear(pk);
3066        }
3067        catch (Exception e) {
3068            throw processException(e);
3069        }
3070        finally {
3071            FinderCacheUtil.clearCache("Users_Groups");
3072        }
3073    }
3074
3075    public void removeGroup(long pk, long groupPK) throws SystemException {
3076        try {
3077            removeGroup.remove(pk, groupPK);
3078        }
3079        catch (Exception e) {
3080            throw processException(e);
3081        }
3082        finally {
3083            FinderCacheUtil.clearCache("Users_Groups");
3084        }
3085    }
3086
3087    public void removeGroup(long pk, com.liferay.portal.model.Group group)
3088        throws SystemException {
3089        try {
3090            removeGroup.remove(pk, group.getPrimaryKey());
3091        }
3092        catch (Exception e) {
3093            throw processException(e);
3094        }
3095        finally {
3096            FinderCacheUtil.clearCache("Users_Groups");
3097        }
3098    }
3099
3100    public void removeGroups(long pk, long[] groupPKs)
3101        throws SystemException {
3102        try {
3103            for (long groupPK : groupPKs) {
3104                removeGroup.remove(pk, groupPK);
3105            }
3106        }
3107        catch (Exception e) {
3108            throw processException(e);
3109        }
3110        finally {
3111            FinderCacheUtil.clearCache("Users_Groups");
3112        }
3113    }
3114
3115    public void removeGroups(long pk,
3116        List<com.liferay.portal.model.Group> groups) throws SystemException {
3117        try {
3118            for (com.liferay.portal.model.Group group : groups) {
3119                removeGroup.remove(pk, group.getPrimaryKey());
3120            }
3121        }
3122        catch (Exception e) {
3123            throw processException(e);
3124        }
3125        finally {
3126            FinderCacheUtil.clearCache("Users_Groups");
3127        }
3128    }
3129
3130    public void setGroups(long pk, long[] groupPKs) throws SystemException {
3131        try {
3132            clearGroups.clear(pk);
3133
3134            for (long groupPK : groupPKs) {
3135                addGroup.add(pk, groupPK);
3136            }
3137        }
3138        catch (Exception e) {
3139            throw processException(e);
3140        }
3141        finally {
3142            FinderCacheUtil.clearCache("Users_Groups");
3143        }
3144    }
3145
3146    public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
3147        throws SystemException {
3148        try {
3149            clearGroups.clear(pk);
3150
3151            for (com.liferay.portal.model.Group group : groups) {
3152                addGroup.add(pk, group.getPrimaryKey());
3153            }
3154        }
3155        catch (Exception e) {
3156            throw processException(e);
3157        }
3158        finally {
3159            FinderCacheUtil.clearCache("Users_Groups");
3160        }
3161    }
3162
3163    public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
3164        throws SystemException {
3165        return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3166    }
3167
3168    public List<com.liferay.portal.model.Organization> getOrganizations(
3169        long pk, int start, int end) throws SystemException {
3170        return getOrganizations(pk, start, end, null);
3171    }
3172
3173    public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3174            UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, "Users_Orgs",
3175            "getOrganizations",
3176            new String[] {
3177                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3178                "com.liferay.portal.kernel.util.OrderByComparator"
3179            });
3180
3181    public List<com.liferay.portal.model.Organization> getOrganizations(
3182        long pk, int start, int end, OrderByComparator obc)
3183        throws SystemException {
3184        Object[] finderArgs = new Object[] {
3185                new Long(pk), String.valueOf(start), String.valueOf(end),
3186                String.valueOf(obc)
3187            };
3188
3189        List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
3190                finderArgs, this);
3191
3192        if (list == null) {
3193            Session session = null;
3194
3195            try {
3196                session = openSession();
3197
3198                StringBuilder sb = new StringBuilder();
3199
3200                sb.append(_SQL_GETORGANIZATIONS);
3201
3202                if (obc != null) {
3203                    sb.append("ORDER BY ");
3204                    sb.append(obc.getOrderBy());
3205                }
3206
3207                else {
3208                    sb.append("ORDER BY ");
3209
3210                    sb.append("Organization_.name ASC");
3211                }
3212
3213                String sql = sb.toString();
3214
3215                SQLQuery q = session.createSQLQuery(sql);
3216
3217                q.addEntity("Organization_",
3218                    com.liferay.portal.model.impl.OrganizationImpl.class);
3219
3220                QueryPos qPos = QueryPos.getInstance(q);
3221
3222                qPos.add(pk);
3223
3224                list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
3225                        getDialect(), start, end);
3226            }
3227            catch (Exception e) {
3228                throw processException(e);
3229            }
3230            finally {
3231                if (list == null) {
3232                    list = new ArrayList<com.liferay.portal.model.Organization>();
3233                }
3234
3235                organizationPersistence.cacheResult(list);
3236
3237                FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
3238                    finderArgs, list);
3239
3240                closeSession(session);
3241            }
3242        }
3243
3244        return list;
3245    }
3246
3247    public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3248            UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, "Users_Orgs",
3249            "getOrganizationsSize", new String[] { Long.class.getName() });
3250
3251    public int getOrganizationsSize(long pk) throws SystemException {
3252        Object[] finderArgs = new Object[] { new Long(pk) };
3253
3254        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3255                finderArgs, this);
3256
3257        if (count == null) {
3258            Session session = null;
3259
3260            try {
3261                session = openSession();
3262
3263                SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
3264
3265                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3266
3267                QueryPos qPos = QueryPos.getInstance(q);
3268
3269                qPos.add(pk);
3270
3271                count = (Long)q.uniqueResult();
3272            }
3273            catch (Exception e) {
3274                throw processException(e);
3275            }
3276            finally {
3277                if (count == null) {
3278                    count = Long.valueOf(0);
3279                }
3280
3281                FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3282                    finderArgs, count);
3283
3284                closeSession(session);
3285            }
3286        }
3287
3288        return count.intValue();
3289    }
3290
3291    public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3292            UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, "Users_Orgs",
3293            "containsOrganization",
3294            new String[] { Long.class.getName(), Long.class.getName() });
3295
3296    public boolean containsOrganization(long pk, long organizationPK)
3297        throws SystemException {
3298        Object[] finderArgs = new Object[] {
3299                new Long(pk),
3300                
3301                new Long(organizationPK)
3302            };
3303
3304        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3305                finderArgs, this);
3306
3307        if (value == null) {
3308            try {
3309                value = Boolean.valueOf(containsOrganization.contains(pk,
3310                            organizationPK));
3311            }
3312            catch (Exception e) {
3313                throw processException(e);
3314            }
3315            finally {
3316                if (value == null) {
3317                    value = Boolean.FALSE;
3318                }
3319
3320                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3321                    finderArgs, value);
3322            }
3323        }
3324
3325        return value.booleanValue();
3326    }
3327
3328    public boolean containsOrganizations(long pk) throws SystemException {
3329        if (getOrganizationsSize(pk) > 0) {
3330            return true;
3331        }
3332        else {
3333            return false;
3334        }
3335    }
3336
3337    public void addOrganization(long pk, long organizationPK)
3338        throws SystemException {
3339        try {
3340            addOrganization.add(pk, organizationPK);
3341        }
3342        catch (Exception e) {
3343            throw processException(e);
3344        }
3345        finally {
3346            FinderCacheUtil.clearCache("Users_Orgs");
3347        }
3348    }
3349
3350    public void addOrganization(long pk,
3351        com.liferay.portal.model.Organization organization)
3352        throws SystemException {
3353        try {
3354            addOrganization.add(pk, organization.getPrimaryKey());
3355        }
3356        catch (Exception e) {
3357            throw processException(e);
3358        }
3359        finally {
3360            FinderCacheUtil.clearCache("Users_Orgs");
3361        }
3362    }
3363
3364    public void addOrganizations(long pk, long[] organizationPKs)
3365        throws SystemException {
3366        try {
3367            for (long organizationPK : organizationPKs) {
3368                addOrganization.add(pk, organizationPK);
3369            }
3370        }
3371        catch (Exception e) {
3372            throw processException(e);
3373        }
3374        finally {
3375            FinderCacheUtil.clearCache("Users_Orgs");
3376        }
3377    }
3378
3379    public void addOrganizations(long pk,
3380        List<com.liferay.portal.model.Organization> organizations)
3381        throws SystemException {
3382        try {
3383            for (com.liferay.portal.model.Organization organization : organizations) {
3384                addOrganization.add(pk, organization.getPrimaryKey());
3385            }
3386        }
3387        catch (Exception e) {
3388            throw processException(e);
3389        }
3390        finally {
3391            FinderCacheUtil.clearCache("Users_Orgs");
3392        }
3393    }
3394
3395    public void clearOrganizations(long pk) throws SystemException {
3396        try {
3397            clearOrganizations.clear(pk);
3398        }
3399        catch (Exception e) {
3400            throw processException(e);
3401        }
3402        finally {
3403            FinderCacheUtil.clearCache("Users_Orgs");
3404        }
3405    }
3406
3407    public void removeOrganization(long pk, long organizationPK)
3408        throws SystemException {
3409        try {
3410            removeOrganization.remove(pk, organizationPK);
3411        }
3412        catch (Exception e) {
3413            throw processException(e);
3414        }
3415        finally {
3416            FinderCacheUtil.clearCache("Users_Orgs");
3417        }
3418    }
3419
3420    public void removeOrganization(long pk,
3421        com.liferay.portal.model.Organization organization)
3422        throws SystemException {
3423        try {
3424            removeOrganization.remove(pk, organization.getPrimaryKey());
3425        }
3426        catch (Exception e) {
3427            throw processException(e);
3428        }
3429        finally {
3430            FinderCacheUtil.clearCache("Users_Orgs");
3431        }
3432    }
3433
3434    public void removeOrganizations(long pk, long[] organizationPKs)
3435        throws SystemException {
3436        try {
3437            for (long organizationPK : organizationPKs) {
3438                removeOrganization.remove(pk, organizationPK);
3439            }
3440        }
3441        catch (Exception e) {
3442            throw processException(e);
3443        }
3444        finally {
3445            FinderCacheUtil.clearCache("Users_Orgs");
3446        }
3447    }
3448
3449    public void removeOrganizations(long pk,
3450        List<com.liferay.portal.model.Organization> organizations)
3451        throws SystemException {
3452        try {
3453            for (com.liferay.portal.model.Organization organization : organizations) {
3454                removeOrganization.remove(pk, organization.getPrimaryKey());
3455            }
3456        }
3457        catch (Exception e) {
3458            throw processException(e);
3459        }
3460        finally {
3461            FinderCacheUtil.clearCache("Users_Orgs");
3462        }
3463    }
3464
3465    public void setOrganizations(long pk, long[] organizationPKs)
3466        throws SystemException {
3467        try {
3468            clearOrganizations.clear(pk);
3469
3470            for (long organizationPK : organizationPKs) {
3471                addOrganization.add(pk, organizationPK);
3472            }
3473        }
3474        catch (Exception e) {
3475            throw processException(e);
3476        }
3477        finally {
3478            FinderCacheUtil.clearCache("Users_Orgs");
3479        }
3480    }
3481
3482    public void setOrganizations(long pk,
3483        List<com.liferay.portal.model.Organization> organizations)
3484        throws SystemException {
3485        try {
3486            clearOrganizations.clear(pk);
3487
3488            for (com.liferay.portal.model.Organization organization : organizations) {
3489                addOrganization.add(pk, organization.getPrimaryKey());
3490            }
3491        }
3492        catch (Exception e) {
3493            throw processException(e);
3494        }
3495        finally {
3496            FinderCacheUtil.clearCache("Users_Orgs");
3497        }
3498    }
3499
3500    public List<com.liferay.portal.model.Permission> getPermissions(long pk)
3501        throws SystemException {
3502        return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3503    }
3504
3505    public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3506        int start, int end) throws SystemException {
3507        return getPermissions(pk, start, end, null);
3508    }
3509
3510    public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3511            UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
3512            "Users_Permissions", "getPermissions",
3513            new String[] {
3514                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3515                "com.liferay.portal.kernel.util.OrderByComparator"
3516            });
3517
3518    public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3519        int start, int end, OrderByComparator obc) throws SystemException {
3520        Object[] finderArgs = new Object[] {
3521                new Long(pk), String.valueOf(start), String.valueOf(end),
3522                String.valueOf(obc)
3523            };
3524
3525        List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
3526                finderArgs, this);
3527
3528        if (list == null) {
3529            Session session = null;
3530
3531            try {
3532                session = openSession();
3533
3534                StringBuilder sb = new StringBuilder();
3535
3536                sb.append(_SQL_GETPERMISSIONS);
3537
3538                if (obc != null) {
3539                    sb.append("ORDER BY ");
3540                    sb.append(obc.getOrderBy());
3541                }
3542
3543                String sql = sb.toString();
3544
3545                SQLQuery q = session.createSQLQuery(sql);
3546
3547                q.addEntity("Permission_",
3548                    com.liferay.portal.model.impl.PermissionImpl.class);
3549
3550                QueryPos qPos = QueryPos.getInstance(q);
3551
3552                qPos.add(pk);
3553
3554                list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
3555                        getDialect(), start, end);
3556            }
3557            catch (Exception e) {
3558                throw processException(e);
3559            }
3560            finally {
3561                if (list == null) {
3562                    list = new ArrayList<com.liferay.portal.model.Permission>();
3563                }
3564
3565                permissionPersistence.cacheResult(list);
3566
3567                FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
3568                    finderArgs, list);
3569
3570                closeSession(session);
3571            }
3572        }
3573
3574        return list;
3575    }
3576
3577    public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3578            UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
3579            "Users_Permissions", "getPermissionsSize",
3580            new String[] { Long.class.getName() });
3581
3582    public int getPermissionsSize(long pk) throws SystemException {
3583        Object[] finderArgs = new Object[] { new Long(pk) };
3584
3585        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3586                finderArgs, this);
3587
3588        if (count == null) {
3589            Session session = null;
3590
3591            try {
3592                session = openSession();
3593
3594                SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
3595
3596                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3597
3598                QueryPos qPos = QueryPos.getInstance(q);
3599
3600                qPos.add(pk);
3601
3602                count = (Long)q.uniqueResult();
3603            }
3604            catch (Exception e) {
3605                throw processException(e);
3606            }
3607            finally {
3608                if (count == null) {
3609                    count = Long.valueOf(0);
3610                }
3611
3612                FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3613                    finderArgs, count);
3614
3615                closeSession(session);
3616            }
3617        }
3618
3619        return count.intValue();
3620    }
3621
3622    public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3623            UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
3624            "Users_Permissions", "containsPermission",
3625            new String[] { Long.class.getName(), Long.class.getName() });
3626
3627    public boolean containsPermission(long pk, long permissionPK)
3628        throws SystemException {
3629        Object[] finderArgs = new Object[] { new Long(pk), new Long(permissionPK) };
3630
3631        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
3632                finderArgs, this);
3633
3634        if (value == null) {
3635            try {
3636                value = Boolean.valueOf(containsPermission.contains(pk,
3637                            permissionPK));
3638            }
3639            catch (Exception e) {
3640                throw processException(e);
3641            }
3642            finally {
3643                if (value == null) {
3644                    value = Boolean.FALSE;
3645                }
3646
3647                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
3648                    finderArgs, value);
3649            }
3650        }
3651
3652        return value.booleanValue();
3653    }
3654
3655    public boolean containsPermissions(long pk) throws SystemException {
3656        if (getPermissionsSize(pk) > 0) {
3657            return true;
3658        }
3659        else {
3660            return false;
3661        }
3662    }
3663
3664    public void addPermission(long pk, long permissionPK)
3665        throws SystemException {
3666        try {
3667            addPermission.add(pk, permissionPK);
3668        }
3669        catch (Exception e) {
3670            throw processException(e);
3671        }
3672        finally {
3673            FinderCacheUtil.clearCache("Users_Permissions");
3674        }
3675    }
3676
3677    public void addPermission(long pk,
3678        com.liferay.portal.model.Permission permission)
3679        throws SystemException {
3680        try {
3681            addPermission.add(pk, permission.getPrimaryKey());
3682        }
3683        catch (Exception e) {
3684            throw processException(e);
3685        }
3686        finally {
3687            FinderCacheUtil.clearCache("Users_Permissions");
3688        }
3689    }
3690
3691    public void addPermissions(long pk, long[] permissionPKs)
3692        throws SystemException {
3693        try {
3694            for (long permissionPK : permissionPKs) {
3695                addPermission.add(pk, permissionPK);
3696            }
3697        }
3698        catch (Exception e) {
3699            throw processException(e);
3700        }
3701        finally {
3702            FinderCacheUtil.clearCache("Users_Permissions");
3703        }
3704    }
3705
3706    public void addPermissions(long pk,
3707        List<com.liferay.portal.model.Permission> permissions)
3708        throws SystemException {
3709        try {
3710            for (com.liferay.portal.model.Permission permission : permissions) {
3711                addPermission.add(pk, permission.getPrimaryKey());
3712            }
3713        }
3714        catch (Exception e) {
3715            throw processException(e);
3716        }
3717        finally {
3718            FinderCacheUtil.clearCache("Users_Permissions");
3719        }
3720    }
3721
3722    public void clearPermissions(long pk) throws SystemException {
3723        try {
3724            clearPermissions.clear(pk);
3725        }
3726        catch (Exception e) {
3727            throw processException(e);
3728        }
3729        finally {
3730            FinderCacheUtil.clearCache("Users_Permissions");
3731        }
3732    }
3733
3734    public void removePermission(long pk, long permissionPK)
3735        throws SystemException {
3736        try {
3737            removePermission.remove(pk, permissionPK);
3738        }
3739        catch (Exception e) {
3740            throw processException(e);
3741        }
3742        finally {
3743            FinderCacheUtil.clearCache("Users_Permissions");
3744        }
3745    }
3746
3747    public void removePermission(long pk,
3748        com.liferay.portal.model.Permission permission)
3749        throws SystemException {
3750        try {
3751            removePermission.remove(pk, permission.getPrimaryKey());
3752        }
3753        catch (Exception e) {
3754            throw processException(e);
3755        }
3756        finally {
3757            FinderCacheUtil.clearCache("Users_Permissions");
3758        }
3759    }
3760
3761    public void removePermissions(long pk, long[] permissionPKs)
3762        throws SystemException {
3763        try {
3764            for (long permissionPK : permissionPKs) {
3765                removePermission.remove(pk, permissionPK);
3766            }
3767        }
3768        catch (Exception e) {
3769            throw processException(e);
3770        }
3771        finally {
3772            FinderCacheUtil.clearCache("Users_Permissions");
3773        }
3774    }
3775
3776    public void removePermissions(long pk,
3777        List<com.liferay.portal.model.Permission> permissions)
3778        throws SystemException {
3779        try {
3780            for (com.liferay.portal.model.Permission permission : permissions) {
3781                removePermission.remove(pk, permission.getPrimaryKey());
3782            }
3783        }
3784        catch (Exception e) {
3785            throw processException(e);
3786        }
3787        finally {
3788            FinderCacheUtil.clearCache("Users_Permissions");
3789        }
3790    }
3791
3792    public void setPermissions(long pk, long[] permissionPKs)
3793        throws SystemException {
3794        try {
3795            clearPermissions.clear(pk);
3796
3797            for (long permissionPK : permissionPKs) {
3798                addPermission.add(pk, permissionPK);
3799            }
3800        }
3801        catch (Exception e) {
3802            throw processException(e);
3803        }
3804        finally {
3805            FinderCacheUtil.clearCache("Users_Permissions");
3806        }
3807    }
3808
3809    public void setPermissions(long pk,
3810        List<com.liferay.portal.model.Permission> permissions)
3811        throws SystemException {
3812        try {
3813            clearPermissions.clear(pk);
3814
3815            for (com.liferay.portal.model.Permission permission : permissions) {
3816                addPermission.add(pk, permission.getPrimaryKey());
3817            }
3818        }
3819        catch (Exception e) {
3820            throw processException(e);
3821        }
3822        finally {
3823            FinderCacheUtil.clearCache("Users_Permissions");
3824        }
3825    }
3826
3827    public List<com.liferay.portal.model.Role> getRoles(long pk)
3828        throws SystemException {
3829        return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3830    }
3831
3832    public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
3833        int end) throws SystemException {
3834        return getRoles(pk, start, end, null);
3835    }
3836
3837    public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3838            UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, "Users_Roles",
3839            "getRoles",
3840            new String[] {
3841                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3842                "com.liferay.portal.kernel.util.OrderByComparator"
3843            });
3844
3845    public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
3846        int end, OrderByComparator obc) throws SystemException {
3847        Object[] finderArgs = new Object[] {
3848                new Long(pk), String.valueOf(start), String.valueOf(end),
3849                String.valueOf(obc)
3850            };
3851
3852        List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
3853                finderArgs, this);
3854
3855        if (list == null) {
3856            Session session = null;
3857
3858            try {
3859                session = openSession();
3860
3861                StringBuilder sb = new StringBuilder();
3862
3863                sb.append(_SQL_GETROLES);
3864
3865                if (obc != null) {
3866                    sb.append("ORDER BY ");
3867                    sb.append(obc.getOrderBy());
3868                }
3869
3870                else {
3871                    sb.append("ORDER BY ");
3872
3873                    sb.append("Role_.name ASC");
3874                }
3875
3876                String sql = sb.toString();
3877
3878                SQLQuery q = session.createSQLQuery(sql);
3879
3880                q.addEntity("Role_",
3881                    com.liferay.portal.model.impl.RoleImpl.class);
3882
3883                QueryPos qPos = QueryPos.getInstance(q);
3884
3885                qPos.add(pk);
3886
3887                list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
3888                        getDialect(), start, end);
3889            }
3890            catch (Exception e) {
3891                throw processException(e);
3892            }
3893            finally {
3894                if (list == null) {
3895                    list = new ArrayList<com.liferay.portal.model.Role>();
3896                }
3897
3898                rolePersistence.cacheResult(list);
3899
3900                FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
3901                    list);
3902
3903                closeSession(session);
3904            }
3905        }
3906
3907        return list;
3908    }
3909
3910    public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3911            UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, "Users_Roles",
3912            "getRolesSize", new String[] { Long.class.getName() });
3913
3914    public int getRolesSize(long pk) throws SystemException {
3915        Object[] finderArgs = new Object[] { new Long(pk) };
3916
3917        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
3918                finderArgs, this);
3919
3920        if (count == null) {
3921            Session session = null;
3922
3923            try {
3924                session = openSession();
3925
3926                SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
3927
3928                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3929
3930                QueryPos qPos = QueryPos.getInstance(q);
3931
3932                qPos.add(pk);
3933
3934                count = (Long)q.uniqueResult();
3935            }
3936            catch (Exception e) {
3937                throw processException(e);
3938            }
3939            finally {
3940                if (count == null) {
3941                    count = Long.valueOf(0);
3942                }
3943
3944                FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
3945                    finderArgs, count);
3946
3947                closeSession(session);
3948            }
3949        }
3950
3951        return count.intValue();
3952    }
3953
3954    public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3955            UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, "Users_Roles",
3956            "containsRole",
3957            new String[] { Long.class.getName(), Long.class.getName() });
3958
3959    public boolean containsRole(long pk, long rolePK) throws SystemException {
3960        Object[] finderArgs = new Object[] { new Long(pk), new Long(rolePK) };
3961
3962        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
3963                finderArgs, this);
3964
3965        if (value == null) {
3966            try {
3967                value = Boolean.valueOf(containsRole.contains(pk, rolePK));
3968            }
3969            catch (Exception e) {
3970                throw processException(e);
3971            }
3972            finally {
3973                if (value == null) {
3974                    value = Boolean.FALSE;
3975                }
3976
3977                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
3978                    finderArgs, value);
3979            }
3980        }
3981
3982        return value.booleanValue();
3983    }
3984
3985    public boolean containsRoles(long pk) throws SystemException {
3986        if (getRolesSize(pk) > 0) {
3987            return true;
3988        }
3989        else {
3990            return false;
3991        }
3992    }
3993
3994    public void addRole(long pk, long rolePK) throws SystemException {
3995        try {
3996            addRole.add(pk, rolePK);
3997        }
3998        catch (Exception e) {
3999            throw processException(e);
4000        }
4001        finally {
4002            FinderCacheUtil.clearCache("Users_Roles");
4003        }
4004    }
4005
4006    public void addRole(long pk, com.liferay.portal.model.Role role)
4007        throws SystemException {
4008        try {
4009            addRole.add(pk, role.getPrimaryKey());
4010        }
4011        catch (Exception e) {
4012            throw processException(e);
4013        }
4014        finally {
4015            FinderCacheUtil.clearCache("Users_Roles");
4016        }
4017    }
4018
4019    public void addRoles(long pk, long[] rolePKs) throws SystemException {
4020        try {
4021            for (long rolePK : rolePKs) {
4022                addRole.add(pk, rolePK);
4023            }
4024        }
4025        catch (Exception e) {
4026            throw processException(e);
4027        }
4028        finally {
4029            FinderCacheUtil.clearCache("Users_Roles");
4030        }
4031    }
4032
4033    public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
4034        throws SystemException {
4035        try {
4036            for (com.liferay.portal.model.Role role : roles) {
4037                addRole.add(pk, role.getPrimaryKey());
4038            }
4039        }
4040        catch (Exception e) {
4041            throw processException(e);
4042        }
4043        finally {
4044            FinderCacheUtil.clearCache("Users_Roles");
4045        }
4046    }
4047
4048    public void clearRoles(long pk) throws SystemException {
4049        try {
4050            clearRoles.clear(pk);
4051        }
4052        catch (Exception e) {
4053            throw processException(e);
4054        }
4055        finally {
4056            FinderCacheUtil.clearCache("Users_Roles");
4057        }
4058    }
4059
4060    public void removeRole(long pk, long rolePK) throws SystemException {
4061        try {
4062            removeRole.remove(pk, rolePK);
4063        }
4064        catch (Exception e) {
4065            throw processException(e);
4066        }
4067        finally {
4068            FinderCacheUtil.clearCache("Users_Roles");
4069        }
4070    }
4071
4072    public void removeRole(long pk, com.liferay.portal.model.Role role)
4073        throws SystemException {
4074        try {
4075            removeRole.remove(pk, role.getPrimaryKey());
4076        }
4077        catch (Exception e) {
4078            throw processException(e);
4079        }
4080        finally {
4081            FinderCacheUtil.clearCache("Users_Roles");
4082        }
4083    }
4084
4085    public void removeRoles(long pk, long[] rolePKs) throws SystemException {
4086        try {
4087            for (long rolePK : rolePKs) {
4088                removeRole.remove(pk, rolePK);
4089            }
4090        }
4091        catch (Exception e) {
4092            throw processException(e);
4093        }
4094        finally {
4095            FinderCacheUtil.clearCache("Users_Roles");
4096        }
4097    }
4098
4099    public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
4100        throws SystemException {
4101        try {
4102            for (com.liferay.portal.model.Role role : roles) {
4103                removeRole.remove(pk, role.getPrimaryKey());
4104            }
4105        }
4106        catch (Exception e) {
4107            throw processException(e);
4108        }
4109        finally {
4110            FinderCacheUtil.clearCache("Users_Roles");
4111        }
4112    }
4113
4114    public void setRoles(long pk, long[] rolePKs) throws SystemException {
4115        try {
4116            clearRoles.clear(pk);
4117
4118            for (long rolePK : rolePKs) {
4119                addRole.add(pk, rolePK);
4120            }
4121        }
4122        catch (Exception e) {
4123            throw processException(e);
4124        }
4125        finally {
4126            FinderCacheUtil.clearCache("Users_Roles");
4127        }
4128    }
4129
4130    public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
4131        throws SystemException {
4132        try {
4133            clearRoles.clear(pk);
4134
4135            for (com.liferay.portal.model.Role role : roles) {
4136                addRole.add(pk, role.getPrimaryKey());
4137            }
4138        }
4139        catch (Exception e) {
4140            throw processException(e);
4141        }
4142        finally {
4143            FinderCacheUtil.clearCache("Users_Roles");
4144        }
4145    }
4146
4147    public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
4148        throws SystemException {
4149        return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4150    }
4151
4152    public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4153        int start, int end) throws SystemException {
4154        return getUserGroups(pk, start, end, null);
4155    }
4156
4157    public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4158            UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4159            "Users_UserGroups", "getUserGroups",
4160            new String[] {
4161                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4162                "com.liferay.portal.kernel.util.OrderByComparator"
4163            });
4164
4165    public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4166        int start, int end, OrderByComparator obc) throws SystemException {
4167        Object[] finderArgs = new Object[] {
4168                new Long(pk), String.valueOf(start), String.valueOf(end),
4169                String.valueOf(obc)
4170            };
4171
4172        List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
4173                finderArgs, this);
4174
4175        if (list == null) {
4176            Session session = null;
4177
4178            try {
4179                session = openSession();
4180
4181                StringBuilder sb = new StringBuilder();
4182
4183                sb.append(_SQL_GETUSERGROUPS);
4184
4185                if (obc != null) {
4186                    sb.append("ORDER BY ");
4187                    sb.append(obc.getOrderBy());
4188                }
4189
4190                else {
4191                    sb.append("ORDER BY ");
4192
4193                    sb.append("UserGroup.name ASC");
4194                }
4195
4196                String sql = sb.toString();
4197
4198                SQLQuery q = session.createSQLQuery(sql);
4199
4200                q.addEntity("UserGroup",
4201                    com.liferay.portal.model.impl.UserGroupImpl.class);
4202
4203                QueryPos qPos = QueryPos.getInstance(q);
4204
4205                qPos.add(pk);
4206
4207                list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
4208                        getDialect(), start, end);
4209            }
4210            catch (Exception e) {
4211                throw processException(e);
4212            }
4213            finally {
4214                if (list == null) {
4215                    list = new ArrayList<com.liferay.portal.model.UserGroup>();
4216                }
4217
4218                userGroupPersistence.cacheResult(list);
4219
4220                FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
4221                    finderArgs, list);
4222
4223                closeSession(session);
4224            }
4225        }
4226
4227        return list;
4228    }
4229
4230    public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4231            UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4232            "Users_UserGroups", "getUserGroupsSize",
4233            new String[] { Long.class.getName() });
4234
4235    public int getUserGroupsSize(long pk) throws SystemException {
4236        Object[] finderArgs = new Object[] { new Long(pk) };
4237
4238        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4239                finderArgs, this);
4240
4241        if (count == null) {
4242            Session session = null;
4243
4244            try {
4245                session = openSession();
4246
4247                SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
4248
4249                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
4250
4251                QueryPos qPos = QueryPos.getInstance(q);
4252
4253                qPos.add(pk);
4254
4255                count = (Long)q.uniqueResult();
4256            }
4257            catch (Exception e) {
4258                throw processException(e);
4259            }
4260            finally {
4261                if (count == null) {
4262                    count = Long.valueOf(0);
4263                }
4264
4265                FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4266                    finderArgs, count);
4267
4268                closeSession(session);
4269            }
4270        }
4271
4272        return count.intValue();
4273    }
4274
4275    public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4276            UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4277            "Users_UserGroups", "containsUserGroup",
4278            new String[] { Long.class.getName(), Long.class.getName() });
4279
4280    public boolean containsUserGroup(long pk, long userGroupPK)
4281        throws SystemException {
4282        Object[] finderArgs = new Object[] { new Long(pk), new Long(userGroupPK) };
4283
4284        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
4285                finderArgs, this);
4286
4287        if (value == null) {
4288            try {
4289                value = Boolean.valueOf(containsUserGroup.contains(pk,
4290                            userGroupPK));
4291            }
4292            catch (Exception e) {
4293                throw processException(e);
4294            }
4295            finally {
4296                if (value == null) {
4297                    value = Boolean.FALSE;
4298                }
4299
4300                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
4301                    finderArgs, value);
4302            }
4303        }
4304
4305        return value.booleanValue();
4306    }
4307
4308    public boolean containsUserGroups(long pk) throws SystemException {
4309        if (getUserGroupsSize(pk) > 0) {
4310            return true;
4311        }
4312        else {
4313            return false;
4314        }
4315    }
4316
4317    public void addUserGroup(long pk, long userGroupPK)
4318        throws SystemException {
4319        try {
4320            addUserGroup.add(pk, userGroupPK);
4321        }
4322        catch (Exception e) {
4323            throw processException(e);
4324        }
4325        finally {
4326            FinderCacheUtil.clearCache("Users_UserGroups");
4327        }
4328    }
4329
4330    public void addUserGroup(long pk,
4331        com.liferay.portal.model.UserGroup userGroup) throws SystemException {
4332        try {
4333            addUserGroup.add(pk, userGroup.getPrimaryKey());
4334        }
4335        catch (Exception e) {
4336            throw processException(e);
4337        }
4338        finally {
4339            FinderCacheUtil.clearCache("Users_UserGroups");
4340        }
4341    }
4342
4343    public void addUserGroups(long pk, long[] userGroupPKs)
4344        throws SystemException {
4345        try {
4346            for (long userGroupPK : userGroupPKs) {
4347                addUserGroup.add(pk, userGroupPK);
4348            }
4349        }
4350        catch (Exception e) {
4351            throw processException(e);
4352        }
4353        finally {
4354            FinderCacheUtil.clearCache("Users_UserGroups");
4355        }
4356    }
4357
4358    public void addUserGroups(long pk,
4359        List<com.liferay.portal.model.UserGroup> userGroups)
4360        throws SystemException {
4361        try {
4362            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4363                addUserGroup.add(pk, userGroup.getPrimaryKey());
4364            }
4365        }
4366        catch (Exception e) {
4367            throw processException(e);
4368        }
4369        finally {
4370            FinderCacheUtil.clearCache("Users_UserGroups");
4371        }
4372    }
4373
4374    public void clearUserGroups(long pk) throws SystemException {
4375        try {
4376            clearUserGroups.clear(pk);
4377        }
4378        catch (Exception e) {
4379            throw processException(e);
4380        }
4381        finally {
4382            FinderCacheUtil.clearCache("Users_UserGroups");
4383        }
4384    }
4385
4386    public void removeUserGroup(long pk, long userGroupPK)
4387        throws SystemException {
4388        try {
4389            removeUserGroup.remove(pk, userGroupPK);
4390        }
4391        catch (Exception e) {
4392            throw processException(e);
4393        }
4394        finally {
4395            FinderCacheUtil.clearCache("Users_UserGroups");
4396        }
4397    }
4398
4399    public void removeUserGroup(long pk,
4400        com.liferay.portal.model.UserGroup userGroup) throws SystemException {
4401        try {
4402            removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4403        }
4404        catch (Exception e) {
4405            throw processException(e);
4406        }
4407        finally {
4408            FinderCacheUtil.clearCache("Users_UserGroups");
4409        }
4410    }
4411
4412    public void removeUserGroups(long pk, long[] userGroupPKs)
4413        throws SystemException {
4414        try {
4415            for (long userGroupPK : userGroupPKs) {
4416                removeUserGroup.remove(pk, userGroupPK);
4417            }
4418        }
4419        catch (Exception e) {
4420            throw processException(e);
4421        }
4422        finally {
4423            FinderCacheUtil.clearCache("Users_UserGroups");
4424        }
4425    }
4426
4427    public void removeUserGroups(long pk,
4428        List<com.liferay.portal.model.UserGroup> userGroups)
4429        throws SystemException {
4430        try {
4431            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4432                removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4433            }
4434        }
4435        catch (Exception e) {
4436            throw processException(e);
4437        }
4438        finally {
4439            FinderCacheUtil.clearCache("Users_UserGroups");
4440        }
4441    }
4442
4443    public void setUserGroups(long pk, long[] userGroupPKs)
4444        throws SystemException {
4445        try {
4446            clearUserGroups.clear(pk);
4447
4448            for (long userGroupPK : userGroupPKs) {
4449                addUserGroup.add(pk, userGroupPK);
4450            }
4451        }
4452        catch (Exception e) {
4453            throw processException(e);
4454        }
4455        finally {
4456            FinderCacheUtil.clearCache("Users_UserGroups");
4457        }
4458    }
4459
4460    public void setUserGroups(long pk,
4461        List<com.liferay.portal.model.UserGroup> userGroups)
4462        throws SystemException {
4463        try {
4464            clearUserGroups.clear(pk);
4465
4466            for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4467                addUserGroup.add(pk, userGroup.getPrimaryKey());
4468            }
4469        }
4470        catch (Exception e) {
4471            throw processException(e);
4472        }
4473        finally {
4474            FinderCacheUtil.clearCache("Users_UserGroups");
4475        }
4476    }
4477
4478    public void afterPropertiesSet() {
4479        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4480                    com.liferay.portal.util.PropsUtil.get(
4481                        "value.object.listener.com.liferay.portal.model.User")));
4482
4483        if (listenerClassNames.length > 0) {
4484            try {
4485                List<ModelListener<User>> listenersList = new ArrayList<ModelListener<User>>();
4486
4487                for (String listenerClassName : listenerClassNames) {
4488                    listenersList.add((ModelListener<User>)Class.forName(
4489                            listenerClassName).newInstance());
4490                }
4491
4492                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4493            }
4494            catch (Exception e) {
4495                _log.error(e);
4496            }
4497        }
4498
4499        containsGroup = new ContainsGroup(this);
4500
4501        addGroup = new AddGroup(this);
4502        clearGroups = new ClearGroups(this);
4503        removeGroup = new RemoveGroup(this);
4504
4505        containsOrganization = new ContainsOrganization(this);
4506
4507        addOrganization = new AddOrganization(this);
4508        clearOrganizations = new ClearOrganizations(this);
4509        removeOrganization = new RemoveOrganization(this);
4510
4511        containsPermission = new ContainsPermission(this);
4512
4513        addPermission = new AddPermission(this);
4514        clearPermissions = new ClearPermissions(this);
4515        removePermission = new RemovePermission(this);
4516
4517        containsRole = new ContainsRole(this);
4518
4519        addRole = new AddRole(this);
4520        clearRoles = new ClearRoles(this);
4521        removeRole = new RemoveRole(this);
4522
4523        containsUserGroup = new ContainsUserGroup(this);
4524
4525        addUserGroup = new AddUserGroup(this);
4526        clearUserGroups = new ClearUserGroups(this);
4527        removeUserGroup = new RemoveUserGroup(this);
4528    }
4529
4530    @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
4531    protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
4532    @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
4533    protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
4534    @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
4535    protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
4536    @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
4537    protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
4538    @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
4539    protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
4540    @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
4541    protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
4542    @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
4543    protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
4544    @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
4545    protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
4546    @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
4547    protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
4548    @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
4549    protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
4550    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
4551    protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
4552    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
4553    protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
4554    @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
4555    protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
4556    @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
4557    protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
4558    @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
4559    protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
4560    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
4561    protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
4562    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
4563    protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
4564    @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
4565    protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
4566    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
4567    protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
4568    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
4569    protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4570    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
4571    protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
4572    @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
4573    protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
4574    @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
4575    protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
4576    @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
4577    protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
4578    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
4579    protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
4580    @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
4581    protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
4582    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
4583    protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
4584    @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
4585    protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
4586    @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
4587    protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
4588    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
4589    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
4590    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
4591    protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
4592    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
4593    protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
4594    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
4595    protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
4596    @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
4597    protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
4598    @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
4599    protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
4600    @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
4601    protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
4602    @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
4603    protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
4604    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
4605    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
4606    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
4607    protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
4608    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
4609    protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
4610    @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
4611    protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
4612    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
4613    protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
4614    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
4615    protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
4616    @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
4617    protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
4618    @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
4619    protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
4620    @BeanReference(name = "com.liferay.portlet.announcements.service.persistence.AnnouncementsDeliveryPersistence.impl")
4621    protected com.liferay.portlet.announcements.service.persistence.AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
4622    @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence.impl")
4623    protected com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence blogsStatsUserPersistence;
4624    @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
4625    protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
4626    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence.impl")
4627    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence dlFileRankPersistence;
4628    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBBanPersistence.impl")
4629    protected com.liferay.portlet.messageboards.service.persistence.MBBanPersistence mbBanPersistence;
4630    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence.impl")
4631    protected com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence mbMessageFlagPersistence;
4632    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence.impl")
4633    protected com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence mbStatsUserPersistence;
4634    @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence.impl")
4635    protected com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence shoppingCartPersistence;
4636    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
4637    protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
4638    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialRequestPersistence.impl")
4639    protected com.liferay.portlet.social.service.persistence.SocialRequestPersistence socialRequestPersistence;
4640    protected ContainsGroup containsGroup;
4641    protected AddGroup addGroup;
4642    protected ClearGroups clearGroups;
4643    protected RemoveGroup removeGroup;
4644    protected ContainsOrganization containsOrganization;
4645    protected AddOrganization addOrganization;
4646    protected ClearOrganizations clearOrganizations;
4647    protected RemoveOrganization removeOrganization;
4648    protected ContainsPermission containsPermission;
4649    protected AddPermission addPermission;
4650    protected ClearPermissions clearPermissions;
4651    protected RemovePermission removePermission;
4652    protected ContainsRole containsRole;
4653    protected AddRole addRole;
4654    protected ClearRoles clearRoles;
4655    protected RemoveRole removeRole;
4656    protected ContainsUserGroup containsUserGroup;
4657    protected AddUserGroup addUserGroup;
4658    protected ClearUserGroups clearUserGroups;
4659    protected RemoveUserGroup removeUserGroup;
4660
4661    protected class ContainsGroup {
4662        protected ContainsGroup(UserPersistenceImpl persistenceImpl) {
4663            super();
4664
4665            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4666                    _SQL_CONTAINSGROUP,
4667                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4668        }
4669
4670        protected boolean contains(long userId, long groupId) {
4671            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4672                        new Long(userId), new Long(groupId)
4673                    });
4674
4675            if (results.size() > 0) {
4676                Integer count = results.get(0);
4677
4678                if (count.intValue() > 0) {
4679                    return true;
4680                }
4681            }
4682
4683            return false;
4684        }
4685
4686        private MappingSqlQuery _mappingSqlQuery;
4687    }
4688
4689    protected class AddGroup {
4690        protected AddGroup(UserPersistenceImpl persistenceImpl) {
4691            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4692                    "INSERT INTO Users_Groups (userId, groupId) VALUES (?, ?)",
4693                    new int[] { Types.BIGINT, Types.BIGINT });
4694            _persistenceImpl = persistenceImpl;
4695        }
4696
4697        protected void add(long userId, long groupId) {
4698            if (!_persistenceImpl.containsGroup.contains(userId, groupId)) {
4699                _sqlUpdate.update(new Object[] {
4700                        new Long(userId), new Long(groupId)
4701                    });
4702            }
4703        }
4704
4705        private SqlUpdate _sqlUpdate;
4706        private UserPersistenceImpl _persistenceImpl;
4707    }
4708
4709    protected class ClearGroups {
4710        protected ClearGroups(UserPersistenceImpl persistenceImpl) {
4711            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4712                    "DELETE FROM Users_Groups WHERE userId = ?",
4713                    new int[] { Types.BIGINT });
4714        }
4715
4716        protected void clear(long userId) {
4717            _sqlUpdate.update(new Object[] { new Long(userId) });
4718        }
4719
4720        private SqlUpdate _sqlUpdate;
4721    }
4722
4723    protected class RemoveGroup {
4724        protected RemoveGroup(UserPersistenceImpl persistenceImpl) {
4725            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4726                    "DELETE FROM Users_Groups WHERE userId = ? AND groupId = ?",
4727                    new int[] { Types.BIGINT, Types.BIGINT });
4728        }
4729
4730        protected void remove(long userId, long groupId) {
4731            _sqlUpdate.update(new Object[] { new Long(userId), new Long(groupId) });
4732        }
4733
4734        private SqlUpdate _sqlUpdate;
4735    }
4736
4737    protected class ContainsOrganization {
4738        protected ContainsOrganization(UserPersistenceImpl persistenceImpl) {
4739            super();
4740
4741            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4742                    _SQL_CONTAINSORGANIZATION,
4743                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4744        }
4745
4746        protected boolean contains(long userId, long organizationId) {
4747            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4748                        new Long(userId), new Long(organizationId)
4749                    });
4750
4751            if (results.size() > 0) {
4752                Integer count = results.get(0);
4753
4754                if (count.intValue() > 0) {
4755                    return true;
4756                }
4757            }
4758
4759            return false;
4760        }
4761
4762        private MappingSqlQuery _mappingSqlQuery;
4763    }
4764
4765    protected class AddOrganization {
4766        protected AddOrganization(UserPersistenceImpl persistenceImpl) {
4767            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4768                    "INSERT INTO Users_Orgs (userId, organizationId) VALUES (?, ?)",
4769                    new int[] { Types.BIGINT, Types.BIGINT });
4770            _persistenceImpl = persistenceImpl;
4771        }
4772
4773        protected void add(long userId, long organizationId) {
4774            if (!_persistenceImpl.containsOrganization.contains(userId,
4775                        organizationId)) {
4776                _sqlUpdate.update(new Object[] {
4777                        new Long(userId), new Long(organizationId)
4778                    });
4779            }
4780        }
4781
4782        private SqlUpdate _sqlUpdate;
4783        private UserPersistenceImpl _persistenceImpl;
4784    }
4785
4786    protected class ClearOrganizations {
4787        protected ClearOrganizations(UserPersistenceImpl persistenceImpl) {
4788            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4789                    "DELETE FROM Users_Orgs WHERE userId = ?",
4790                    new int[] { Types.BIGINT });
4791        }
4792
4793        protected void clear(long userId) {
4794            _sqlUpdate.update(new Object[] { new Long(userId) });
4795        }
4796
4797        private SqlUpdate _sqlUpdate;
4798    }
4799
4800    protected class RemoveOrganization {
4801        protected RemoveOrganization(UserPersistenceImpl persistenceImpl) {
4802            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4803                    "DELETE FROM Users_Orgs WHERE userId = ? AND organizationId = ?",
4804                    new int[] { Types.BIGINT, Types.BIGINT });
4805        }
4806
4807        protected void remove(long userId, long organizationId) {
4808            _sqlUpdate.update(new Object[] {
4809                    new Long(userId), new Long(organizationId)
4810                });
4811        }
4812
4813        private SqlUpdate _sqlUpdate;
4814    }
4815
4816    protected class ContainsPermission {
4817        protected ContainsPermission(UserPersistenceImpl persistenceImpl) {
4818            super();
4819
4820            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4821                    _SQL_CONTAINSPERMISSION,
4822                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4823        }
4824
4825        protected boolean contains(long userId, long permissionId) {
4826            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4827                        new Long(userId), new Long(permissionId)
4828                    });
4829
4830            if (results.size() > 0) {
4831                Integer count = results.get(0);
4832
4833                if (count.intValue() > 0) {
4834                    return true;
4835                }
4836            }
4837
4838            return false;
4839        }
4840
4841        private MappingSqlQuery _mappingSqlQuery;
4842    }
4843
4844    protected class AddPermission {
4845        protected AddPermission(UserPersistenceImpl persistenceImpl) {
4846            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4847                    "INSERT INTO Users_Permissions (userId, permissionId) VALUES (?, ?)",
4848                    new int[] { Types.BIGINT, Types.BIGINT });
4849            _persistenceImpl = persistenceImpl;
4850        }
4851
4852        protected void add(long userId, long permissionId) {
4853            if (!_persistenceImpl.containsPermission.contains(userId,
4854                        permissionId)) {
4855                _sqlUpdate.update(new Object[] {
4856                        new Long(userId), new Long(permissionId)
4857                    });
4858            }
4859        }
4860
4861        private SqlUpdate _sqlUpdate;
4862        private UserPersistenceImpl _persistenceImpl;
4863    }
4864
4865    protected class ClearPermissions {
4866        protected ClearPermissions(UserPersistenceImpl persistenceImpl) {
4867            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4868                    "DELETE FROM Users_Permissions WHERE userId = ?",
4869                    new int[] { Types.BIGINT });
4870        }
4871
4872        protected void clear(long userId) {
4873            _sqlUpdate.update(new Object[] { new Long(userId) });
4874        }
4875
4876        private SqlUpdate _sqlUpdate;
4877    }
4878
4879    protected class RemovePermission {
4880        protected RemovePermission(UserPersistenceImpl persistenceImpl) {
4881            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4882                    "DELETE FROM Users_Permissions WHERE userId = ? AND permissionId = ?",
4883                    new int[] { Types.BIGINT, Types.BIGINT });
4884        }
4885
4886        protected void remove(long userId, long permissionId) {
4887            _sqlUpdate.update(new Object[] {
4888                    new Long(userId), new Long(permissionId)
4889                });
4890        }
4891
4892        private SqlUpdate _sqlUpdate;
4893    }
4894
4895    protected class ContainsRole {
4896        protected ContainsRole(UserPersistenceImpl persistenceImpl) {
4897            super();
4898
4899            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4900                    _SQL_CONTAINSROLE,
4901                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4902        }
4903
4904        protected boolean contains(long userId, long roleId) {
4905            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4906                        new Long(userId), new Long(roleId)
4907                    });
4908
4909            if (results.size() > 0) {
4910                Integer count = results.get(0);
4911
4912                if (count.intValue() > 0) {
4913                    return true;
4914                }
4915            }
4916
4917            return false;
4918        }
4919
4920        private MappingSqlQuery _mappingSqlQuery;
4921    }
4922
4923    protected class AddRole {
4924        protected AddRole(UserPersistenceImpl persistenceImpl) {
4925            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4926                    "INSERT INTO Users_Roles (userId, roleId) VALUES (?, ?)",
4927                    new int[] { Types.BIGINT, Types.BIGINT });
4928            _persistenceImpl = persistenceImpl;
4929        }
4930
4931        protected void add(long userId, long roleId) {
4932            if (!_persistenceImpl.containsRole.contains(userId, roleId)) {
4933                _sqlUpdate.update(new Object[] {
4934                        new Long(userId), new Long(roleId)
4935                    });
4936            }
4937        }
4938
4939        private SqlUpdate _sqlUpdate;
4940        private UserPersistenceImpl _persistenceImpl;
4941    }
4942
4943    protected class ClearRoles {
4944        protected ClearRoles(UserPersistenceImpl persistenceImpl) {
4945            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4946                    "DELETE FROM Users_Roles WHERE userId = ?",
4947                    new int[] { Types.BIGINT });
4948        }
4949
4950        protected void clear(long userId) {
4951            _sqlUpdate.update(new Object[] { new Long(userId) });
4952        }
4953
4954        private SqlUpdate _sqlUpdate;
4955    }
4956
4957    protected class RemoveRole {
4958        protected RemoveRole(UserPersistenceImpl persistenceImpl) {
4959            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4960                    "DELETE FROM Users_Roles WHERE userId = ? AND roleId = ?",
4961                    new int[] { Types.BIGINT, Types.BIGINT });
4962        }
4963
4964        protected void remove(long userId, long roleId) {
4965            _sqlUpdate.update(new Object[] { new Long(userId), new Long(roleId) });
4966        }
4967
4968        private SqlUpdate _sqlUpdate;
4969    }
4970
4971    protected class ContainsUserGroup {
4972        protected ContainsUserGroup(UserPersistenceImpl persistenceImpl) {
4973            super();
4974
4975            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4976                    _SQL_CONTAINSUSERGROUP,
4977                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4978        }
4979
4980        protected boolean contains(long userId, long userGroupId) {
4981            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4982                        new Long(userId), new Long(userGroupId)
4983                    });
4984
4985            if (results.size() > 0) {
4986                Integer count = results.get(0);
4987
4988                if (count.intValue() > 0) {
4989                    return true;
4990                }
4991            }
4992
4993            return false;
4994        }
4995
4996        private MappingSqlQuery _mappingSqlQuery;
4997    }
4998
4999    protected class AddUserGroup {
5000        protected AddUserGroup(UserPersistenceImpl persistenceImpl) {
5001            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5002                    "INSERT INTO Users_UserGroups (userId, userGroupId) VALUES (?, ?)",
5003                    new int[] { Types.BIGINT, Types.BIGINT });
5004            _persistenceImpl = persistenceImpl;
5005        }
5006
5007        protected void add(long userId, long userGroupId) {
5008            if (!_persistenceImpl.containsUserGroup.contains(userId, userGroupId)) {
5009                _sqlUpdate.update(new Object[] {
5010                        new Long(userId), new Long(userGroupId)
5011                    });
5012            }
5013        }
5014
5015        private SqlUpdate _sqlUpdate;
5016        private UserPersistenceImpl _persistenceImpl;
5017    }
5018
5019    protected class ClearUserGroups {
5020        protected ClearUserGroups(UserPersistenceImpl persistenceImpl) {
5021            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5022                    "DELETE FROM Users_UserGroups WHERE userId = ?",
5023                    new int[] { Types.BIGINT });
5024        }
5025
5026        protected void clear(long userId) {
5027            _sqlUpdate.update(new Object[] { new Long(userId) });
5028        }
5029
5030        private SqlUpdate _sqlUpdate;
5031    }
5032
5033    protected class RemoveUserGroup {
5034        protected RemoveUserGroup(UserPersistenceImpl persistenceImpl) {
5035            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5036                    "DELETE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?",
5037                    new int[] { Types.BIGINT, Types.BIGINT });
5038        }
5039
5040        protected void remove(long userId, long userGroupId) {
5041            _sqlUpdate.update(new Object[] {
5042                    new Long(userId), new Long(userGroupId)
5043                });
5044        }
5045
5046        private SqlUpdate _sqlUpdate;
5047    }
5048
5049    private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Users_Groups.userId = ?)";
5050    private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ?";
5051    private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ? AND groupId = ?";
5052    private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Organization_.organizationId) WHERE (Users_Orgs.userId = ?)";
5053    private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ?";
5054    private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ? AND organizationId = ?";
5055    private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Users_Permissions ON (Users_Permissions.permissionId = Permission_.permissionId) WHERE (Users_Permissions.userId = ?)";
5056    private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ?";
5057    private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ? AND permissionId = ?";
5058    private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Users_Roles ON (Users_Roles.roleId = Role_.roleId) WHERE (Users_Roles.userId = ?)";
5059    private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ?";
5060    private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ? AND roleId = ?";
5061    private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Users_UserGroups.userId = ?)";
5062    private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ?";
5063    private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?";
5064    private static Log _log = LogFactoryUtil.getLog(UserPersistenceImpl.class);
5065}