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