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