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