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