Source Code Cross Referenced for UserPersistenceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portal » service » persistence » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » com.liferay.portal.service.persistence 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
0003:         *
0004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
0005:         * of this software and associated documentation files (the "Software"), to deal
0006:         * in the Software without restriction, including without limitation the rights
0007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0008:         * copies of the Software, and to permit persons to whom the Software is
0009:         * furnished to do so, subject to the following conditions:
0010:         *
0011:         * The above copyright notice and this permission notice shall be included in
0012:         * all copies or substantial portions of the Software.
0013:         *
0014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0020:         * SOFTWARE.
0021:         */package com.liferay.portal.service.persistence;
0022:
0023:        import com.liferay.portal.NoSuchUserException;
0024:        import com.liferay.portal.SystemException;
0025:        import com.liferay.portal.kernel.dao.DynamicQuery;
0026:        import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
0027:        import com.liferay.portal.kernel.util.GetterUtil;
0028:        import com.liferay.portal.kernel.util.OrderByComparator;
0029:        import com.liferay.portal.kernel.util.StringMaker;
0030:        import com.liferay.portal.kernel.util.StringPool;
0031:        import com.liferay.portal.kernel.util.Validator;
0032:        import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
0033:        import com.liferay.portal.model.ModelListener;
0034:        import com.liferay.portal.model.User;
0035:        import com.liferay.portal.model.impl.UserImpl;
0036:        import com.liferay.portal.model.impl.UserModelImpl;
0037:        import com.liferay.portal.spring.hibernate.FinderCache;
0038:        import com.liferay.portal.spring.hibernate.HibernateUtil;
0039:        import com.liferay.portal.util.PropsUtil;
0040:
0041:        import com.liferay.util.dao.hibernate.QueryPos;
0042:        import com.liferay.util.dao.hibernate.QueryUtil;
0043:
0044:        import org.apache.commons.logging.Log;
0045:        import org.apache.commons.logging.LogFactory;
0046:
0047:        import org.hibernate.Hibernate;
0048:        import org.hibernate.Query;
0049:        import org.hibernate.SQLQuery;
0050:        import org.hibernate.Session;
0051:
0052:        import org.springframework.dao.DataAccessException;
0053:
0054:        import org.springframework.jdbc.core.SqlParameter;
0055:        import org.springframework.jdbc.object.MappingSqlQuery;
0056:        import org.springframework.jdbc.object.SqlUpdate;
0057:
0058:        import java.sql.ResultSet;
0059:        import java.sql.SQLException;
0060:        import java.sql.Types;
0061:
0062:        import java.util.Collections;
0063:        import java.util.Iterator;
0064:        import java.util.List;
0065:
0066:        /**
0067:         * <a href="UserPersistenceImpl.java.html"><b><i>View Source</i></b></a>
0068:         *
0069:         * @author Brian Wing Shun Chan
0070:         *
0071:         */
0072:        public class UserPersistenceImpl extends BasePersistence implements 
0073:                UserPersistence {
0074:            public User create(long userId) {
0075:                User user = new UserImpl();
0076:
0077:                user.setNew(true);
0078:                user.setPrimaryKey(userId);
0079:
0080:                String uuid = PortalUUIDUtil.generate();
0081:
0082:                user.setUuid(uuid);
0083:
0084:                return user;
0085:            }
0086:
0087:            public User remove(long userId) throws NoSuchUserException,
0088:                    SystemException {
0089:                Session session = null;
0090:
0091:                try {
0092:                    session = openSession();
0093:
0094:                    User user = (User) session.get(UserImpl.class, new Long(
0095:                            userId));
0096:
0097:                    if (user == null) {
0098:                        if (_log.isWarnEnabled()) {
0099:                            _log.warn("No User exists with the primary key "
0100:                                    + userId);
0101:                        }
0102:
0103:                        throw new NoSuchUserException(
0104:                                "No User exists with the primary key " + userId);
0105:                    }
0106:
0107:                    return remove(user);
0108:                } catch (NoSuchUserException nsee) {
0109:                    throw nsee;
0110:                } catch (Exception e) {
0111:                    throw HibernateUtil.processException(e);
0112:                } finally {
0113:                    closeSession(session);
0114:                }
0115:            }
0116:
0117:            public User remove(User user) throws SystemException {
0118:                ModelListener listener = _getListener();
0119:
0120:                if (listener != null) {
0121:                    listener.onBeforeRemove(user);
0122:                }
0123:
0124:                user = removeImpl(user);
0125:
0126:                if (listener != null) {
0127:                    listener.onAfterRemove(user);
0128:                }
0129:
0130:                return user;
0131:            }
0132:
0133:            protected User removeImpl(User user) throws SystemException {
0134:                try {
0135:                    clearGroups.clear(user.getPrimaryKey());
0136:                } catch (Exception e) {
0137:                    throw HibernateUtil.processException(e);
0138:                } finally {
0139:                    FinderCache.clearCache("Users_Groups");
0140:                }
0141:
0142:                try {
0143:                    clearOrganizations.clear(user.getPrimaryKey());
0144:                } catch (Exception e) {
0145:                    throw HibernateUtil.processException(e);
0146:                } finally {
0147:                    FinderCache.clearCache("Users_Orgs");
0148:                }
0149:
0150:                try {
0151:                    clearPermissions.clear(user.getPrimaryKey());
0152:                } catch (Exception e) {
0153:                    throw HibernateUtil.processException(e);
0154:                } finally {
0155:                    FinderCache.clearCache("Users_Permissions");
0156:                }
0157:
0158:                try {
0159:                    clearRoles.clear(user.getPrimaryKey());
0160:                } catch (Exception e) {
0161:                    throw HibernateUtil.processException(e);
0162:                } finally {
0163:                    FinderCache.clearCache("Users_Roles");
0164:                }
0165:
0166:                try {
0167:                    clearUserGroups.clear(user.getPrimaryKey());
0168:                } catch (Exception e) {
0169:                    throw HibernateUtil.processException(e);
0170:                } finally {
0171:                    FinderCache.clearCache("Users_UserGroups");
0172:                }
0173:
0174:                Session session = null;
0175:
0176:                try {
0177:                    session = openSession();
0178:
0179:                    session.delete(user);
0180:
0181:                    session.flush();
0182:
0183:                    return user;
0184:                } catch (Exception e) {
0185:                    throw HibernateUtil.processException(e);
0186:                } finally {
0187:                    closeSession(session);
0188:
0189:                    FinderCache.clearCache(User.class.getName());
0190:                }
0191:            }
0192:
0193:            public User update(User user) throws SystemException {
0194:                return update(user, false);
0195:            }
0196:
0197:            public User update(User user, boolean merge) throws SystemException {
0198:                ModelListener listener = _getListener();
0199:
0200:                boolean isNew = user.isNew();
0201:
0202:                if (listener != null) {
0203:                    if (isNew) {
0204:                        listener.onBeforeCreate(user);
0205:                    } else {
0206:                        listener.onBeforeUpdate(user);
0207:                    }
0208:                }
0209:
0210:                user = updateImpl(user, merge);
0211:
0212:                if (listener != null) {
0213:                    if (isNew) {
0214:                        listener.onAfterCreate(user);
0215:                    } else {
0216:                        listener.onAfterUpdate(user);
0217:                    }
0218:                }
0219:
0220:                return user;
0221:            }
0222:
0223:            public User updateImpl(com.liferay.portal.model.User user,
0224:                    boolean merge) throws SystemException {
0225:                FinderCache.clearCache("Users_Groups");
0226:                FinderCache.clearCache("Users_Orgs");
0227:                FinderCache.clearCache("Users_Permissions");
0228:                FinderCache.clearCache("Users_Roles");
0229:                FinderCache.clearCache("Users_UserGroups");
0230:
0231:                if (Validator.isNull(user.getUuid())) {
0232:                    String uuid = PortalUUIDUtil.generate();
0233:
0234:                    user.setUuid(uuid);
0235:                }
0236:
0237:                Session session = null;
0238:
0239:                try {
0240:                    session = openSession();
0241:
0242:                    if (merge) {
0243:                        session.merge(user);
0244:                    } else {
0245:                        if (user.isNew()) {
0246:                            session.save(user);
0247:                        }
0248:                    }
0249:
0250:                    session.flush();
0251:
0252:                    user.setNew(false);
0253:
0254:                    return user;
0255:                } catch (Exception e) {
0256:                    throw HibernateUtil.processException(e);
0257:                } finally {
0258:                    closeSession(session);
0259:
0260:                    FinderCache.clearCache(User.class.getName());
0261:                }
0262:            }
0263:
0264:            public User findByPrimaryKey(long userId)
0265:                    throws NoSuchUserException, SystemException {
0266:                User user = fetchByPrimaryKey(userId);
0267:
0268:                if (user == null) {
0269:                    if (_log.isWarnEnabled()) {
0270:                        _log.warn("No User exists with the primary key "
0271:                                + userId);
0272:                    }
0273:
0274:                    throw new NoSuchUserException(
0275:                            "No User exists with the primary key " + userId);
0276:                }
0277:
0278:                return user;
0279:            }
0280:
0281:            public User fetchByPrimaryKey(long userId) throws SystemException {
0282:                Session session = null;
0283:
0284:                try {
0285:                    session = openSession();
0286:
0287:                    return (User) session.get(UserImpl.class, new Long(userId));
0288:                } catch (Exception e) {
0289:                    throw HibernateUtil.processException(e);
0290:                } finally {
0291:                    closeSession(session);
0292:                }
0293:            }
0294:
0295:            public List findByUuid(String uuid) throws SystemException {
0296:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
0297:                String finderClassName = User.class.getName();
0298:                String finderMethodName = "findByUuid";
0299:                String[] finderParams = new String[] { String.class.getName() };
0300:                Object[] finderArgs = new Object[] { uuid };
0301:
0302:                Object result = null;
0303:
0304:                if (finderClassNameCacheEnabled) {
0305:                    result = FinderCache.getResult(finderClassName,
0306:                            finderMethodName, finderParams, finderArgs,
0307:                            getSessionFactory());
0308:                }
0309:
0310:                if (result == null) {
0311:                    Session session = null;
0312:
0313:                    try {
0314:                        session = openSession();
0315:
0316:                        StringMaker query = new StringMaker();
0317:
0318:                        query
0319:                                .append("FROM com.liferay.portal.model.User WHERE ");
0320:
0321:                        if (uuid == null) {
0322:                            query.append("uuid_ IS NULL");
0323:                        } else {
0324:                            query.append("uuid_ = ?");
0325:                        }
0326:
0327:                        query.append(" ");
0328:
0329:                        Query q = session.createQuery(query.toString());
0330:
0331:                        int queryPos = 0;
0332:
0333:                        if (uuid != null) {
0334:                            q.setString(queryPos++, uuid);
0335:                        }
0336:
0337:                        List list = q.list();
0338:
0339:                        FinderCache.putResult(finderClassNameCacheEnabled,
0340:                                finderClassName, finderMethodName,
0341:                                finderParams, finderArgs, list);
0342:
0343:                        return list;
0344:                    } catch (Exception e) {
0345:                        throw HibernateUtil.processException(e);
0346:                    } finally {
0347:                        closeSession(session);
0348:                    }
0349:                } else {
0350:                    return (List) result;
0351:                }
0352:            }
0353:
0354:            public List findByUuid(String uuid, int begin, int end)
0355:                    throws SystemException {
0356:                return findByUuid(uuid, begin, end, null);
0357:            }
0358:
0359:            public List findByUuid(String uuid, int begin, int end,
0360:                    OrderByComparator obc) throws SystemException {
0361:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
0362:                String finderClassName = User.class.getName();
0363:                String finderMethodName = "findByUuid";
0364:                String[] finderParams = new String[] { String.class.getName(),
0365:
0366:                "java.lang.Integer", "java.lang.Integer",
0367:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0368:                Object[] finderArgs = new Object[] { uuid,
0369:
0370:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0371:
0372:                Object result = null;
0373:
0374:                if (finderClassNameCacheEnabled) {
0375:                    result = FinderCache.getResult(finderClassName,
0376:                            finderMethodName, finderParams, finderArgs,
0377:                            getSessionFactory());
0378:                }
0379:
0380:                if (result == null) {
0381:                    Session session = null;
0382:
0383:                    try {
0384:                        session = openSession();
0385:
0386:                        StringMaker query = new StringMaker();
0387:
0388:                        query
0389:                                .append("FROM com.liferay.portal.model.User WHERE ");
0390:
0391:                        if (uuid == null) {
0392:                            query.append("uuid_ IS NULL");
0393:                        } else {
0394:                            query.append("uuid_ = ?");
0395:                        }
0396:
0397:                        query.append(" ");
0398:
0399:                        if (obc != null) {
0400:                            query.append("ORDER BY ");
0401:                            query.append(obc.getOrderBy());
0402:                        }
0403:
0404:                        Query q = session.createQuery(query.toString());
0405:
0406:                        int queryPos = 0;
0407:
0408:                        if (uuid != null) {
0409:                            q.setString(queryPos++, uuid);
0410:                        }
0411:
0412:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0413:
0414:                        FinderCache.putResult(finderClassNameCacheEnabled,
0415:                                finderClassName, finderMethodName,
0416:                                finderParams, finderArgs, list);
0417:
0418:                        return list;
0419:                    } catch (Exception e) {
0420:                        throw HibernateUtil.processException(e);
0421:                    } finally {
0422:                        closeSession(session);
0423:                    }
0424:                } else {
0425:                    return (List) result;
0426:                }
0427:            }
0428:
0429:            public User findByUuid_First(String uuid, OrderByComparator obc)
0430:                    throws NoSuchUserException, SystemException {
0431:                List list = findByUuid(uuid, 0, 1, obc);
0432:
0433:                if (list.size() == 0) {
0434:                    StringMaker msg = new StringMaker();
0435:
0436:                    msg.append("No User exists with the key {");
0437:
0438:                    msg.append("uuid=" + uuid);
0439:
0440:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0441:
0442:                    throw new NoSuchUserException(msg.toString());
0443:                } else {
0444:                    return (User) list.get(0);
0445:                }
0446:            }
0447:
0448:            public User findByUuid_Last(String uuid, OrderByComparator obc)
0449:                    throws NoSuchUserException, SystemException {
0450:                int count = countByUuid(uuid);
0451:
0452:                List list = findByUuid(uuid, count - 1, count, obc);
0453:
0454:                if (list.size() == 0) {
0455:                    StringMaker msg = new StringMaker();
0456:
0457:                    msg.append("No User exists with the key {");
0458:
0459:                    msg.append("uuid=" + uuid);
0460:
0461:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0462:
0463:                    throw new NoSuchUserException(msg.toString());
0464:                } else {
0465:                    return (User) list.get(0);
0466:                }
0467:            }
0468:
0469:            public User[] findByUuid_PrevAndNext(long userId, String uuid,
0470:                    OrderByComparator obc) throws NoSuchUserException,
0471:                    SystemException {
0472:                User user = findByPrimaryKey(userId);
0473:
0474:                int count = countByUuid(uuid);
0475:
0476:                Session session = null;
0477:
0478:                try {
0479:                    session = openSession();
0480:
0481:                    StringMaker query = new StringMaker();
0482:
0483:                    query.append("FROM com.liferay.portal.model.User WHERE ");
0484:
0485:                    if (uuid == null) {
0486:                        query.append("uuid_ IS NULL");
0487:                    } else {
0488:                        query.append("uuid_ = ?");
0489:                    }
0490:
0491:                    query.append(" ");
0492:
0493:                    if (obc != null) {
0494:                        query.append("ORDER BY ");
0495:                        query.append(obc.getOrderBy());
0496:                    }
0497:
0498:                    Query q = session.createQuery(query.toString());
0499:
0500:                    int queryPos = 0;
0501:
0502:                    if (uuid != null) {
0503:                        q.setString(queryPos++, uuid);
0504:                    }
0505:
0506:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0507:                            user);
0508:
0509:                    User[] array = new UserImpl[3];
0510:
0511:                    array[0] = (User) objArray[0];
0512:                    array[1] = (User) objArray[1];
0513:                    array[2] = (User) objArray[2];
0514:
0515:                    return array;
0516:                } catch (Exception e) {
0517:                    throw HibernateUtil.processException(e);
0518:                } finally {
0519:                    closeSession(session);
0520:                }
0521:            }
0522:
0523:            public List findByCompanyId(long companyId) throws SystemException {
0524:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
0525:                String finderClassName = User.class.getName();
0526:                String finderMethodName = "findByCompanyId";
0527:                String[] finderParams = new String[] { Long.class.getName() };
0528:                Object[] finderArgs = new Object[] { new Long(companyId) };
0529:
0530:                Object result = null;
0531:
0532:                if (finderClassNameCacheEnabled) {
0533:                    result = FinderCache.getResult(finderClassName,
0534:                            finderMethodName, finderParams, finderArgs,
0535:                            getSessionFactory());
0536:                }
0537:
0538:                if (result == null) {
0539:                    Session session = null;
0540:
0541:                    try {
0542:                        session = openSession();
0543:
0544:                        StringMaker query = new StringMaker();
0545:
0546:                        query
0547:                                .append("FROM com.liferay.portal.model.User WHERE ");
0548:
0549:                        query.append("companyId = ?");
0550:
0551:                        query.append(" ");
0552:
0553:                        Query q = session.createQuery(query.toString());
0554:
0555:                        int queryPos = 0;
0556:
0557:                        q.setLong(queryPos++, companyId);
0558:
0559:                        List list = q.list();
0560:
0561:                        FinderCache.putResult(finderClassNameCacheEnabled,
0562:                                finderClassName, finderMethodName,
0563:                                finderParams, finderArgs, list);
0564:
0565:                        return list;
0566:                    } catch (Exception e) {
0567:                        throw HibernateUtil.processException(e);
0568:                    } finally {
0569:                        closeSession(session);
0570:                    }
0571:                } else {
0572:                    return (List) result;
0573:                }
0574:            }
0575:
0576:            public List findByCompanyId(long companyId, int begin, int end)
0577:                    throws SystemException {
0578:                return findByCompanyId(companyId, begin, end, null);
0579:            }
0580:
0581:            public List findByCompanyId(long companyId, int begin, int end,
0582:                    OrderByComparator obc) throws SystemException {
0583:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
0584:                String finderClassName = User.class.getName();
0585:                String finderMethodName = "findByCompanyId";
0586:                String[] finderParams = new String[] { Long.class.getName(),
0587:
0588:                "java.lang.Integer", "java.lang.Integer",
0589:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0590:                Object[] finderArgs = new Object[] { new Long(companyId),
0591:
0592:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0593:
0594:                Object result = null;
0595:
0596:                if (finderClassNameCacheEnabled) {
0597:                    result = FinderCache.getResult(finderClassName,
0598:                            finderMethodName, finderParams, finderArgs,
0599:                            getSessionFactory());
0600:                }
0601:
0602:                if (result == null) {
0603:                    Session session = null;
0604:
0605:                    try {
0606:                        session = openSession();
0607:
0608:                        StringMaker query = new StringMaker();
0609:
0610:                        query
0611:                                .append("FROM com.liferay.portal.model.User WHERE ");
0612:
0613:                        query.append("companyId = ?");
0614:
0615:                        query.append(" ");
0616:
0617:                        if (obc != null) {
0618:                            query.append("ORDER BY ");
0619:                            query.append(obc.getOrderBy());
0620:                        }
0621:
0622:                        Query q = session.createQuery(query.toString());
0623:
0624:                        int queryPos = 0;
0625:
0626:                        q.setLong(queryPos++, companyId);
0627:
0628:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0629:
0630:                        FinderCache.putResult(finderClassNameCacheEnabled,
0631:                                finderClassName, finderMethodName,
0632:                                finderParams, finderArgs, list);
0633:
0634:                        return list;
0635:                    } catch (Exception e) {
0636:                        throw HibernateUtil.processException(e);
0637:                    } finally {
0638:                        closeSession(session);
0639:                    }
0640:                } else {
0641:                    return (List) result;
0642:                }
0643:            }
0644:
0645:            public User findByCompanyId_First(long companyId,
0646:                    OrderByComparator obc) throws NoSuchUserException,
0647:                    SystemException {
0648:                List list = findByCompanyId(companyId, 0, 1, obc);
0649:
0650:                if (list.size() == 0) {
0651:                    StringMaker msg = new StringMaker();
0652:
0653:                    msg.append("No User exists with the key {");
0654:
0655:                    msg.append("companyId=" + companyId);
0656:
0657:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0658:
0659:                    throw new NoSuchUserException(msg.toString());
0660:                } else {
0661:                    return (User) list.get(0);
0662:                }
0663:            }
0664:
0665:            public User findByCompanyId_Last(long companyId,
0666:                    OrderByComparator obc) throws NoSuchUserException,
0667:                    SystemException {
0668:                int count = countByCompanyId(companyId);
0669:
0670:                List list = findByCompanyId(companyId, count - 1, count, obc);
0671:
0672:                if (list.size() == 0) {
0673:                    StringMaker msg = new StringMaker();
0674:
0675:                    msg.append("No User exists with the key {");
0676:
0677:                    msg.append("companyId=" + companyId);
0678:
0679:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0680:
0681:                    throw new NoSuchUserException(msg.toString());
0682:                } else {
0683:                    return (User) list.get(0);
0684:                }
0685:            }
0686:
0687:            public User[] findByCompanyId_PrevAndNext(long userId,
0688:                    long companyId, OrderByComparator obc)
0689:                    throws NoSuchUserException, SystemException {
0690:                User user = findByPrimaryKey(userId);
0691:
0692:                int count = countByCompanyId(companyId);
0693:
0694:                Session session = null;
0695:
0696:                try {
0697:                    session = openSession();
0698:
0699:                    StringMaker query = new StringMaker();
0700:
0701:                    query.append("FROM com.liferay.portal.model.User WHERE ");
0702:
0703:                    query.append("companyId = ?");
0704:
0705:                    query.append(" ");
0706:
0707:                    if (obc != null) {
0708:                        query.append("ORDER BY ");
0709:                        query.append(obc.getOrderBy());
0710:                    }
0711:
0712:                    Query q = session.createQuery(query.toString());
0713:
0714:                    int queryPos = 0;
0715:
0716:                    q.setLong(queryPos++, companyId);
0717:
0718:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0719:                            user);
0720:
0721:                    User[] array = new UserImpl[3];
0722:
0723:                    array[0] = (User) objArray[0];
0724:                    array[1] = (User) objArray[1];
0725:                    array[2] = (User) objArray[2];
0726:
0727:                    return array;
0728:                } catch (Exception e) {
0729:                    throw HibernateUtil.processException(e);
0730:                } finally {
0731:                    closeSession(session);
0732:                }
0733:            }
0734:
0735:            public User findByContactId(long contactId)
0736:                    throws NoSuchUserException, SystemException {
0737:                User user = fetchByContactId(contactId);
0738:
0739:                if (user == null) {
0740:                    StringMaker msg = new StringMaker();
0741:
0742:                    msg.append("No User exists with the key {");
0743:
0744:                    msg.append("contactId=" + contactId);
0745:
0746:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0747:
0748:                    if (_log.isWarnEnabled()) {
0749:                        _log.warn(msg.toString());
0750:                    }
0751:
0752:                    throw new NoSuchUserException(msg.toString());
0753:                }
0754:
0755:                return user;
0756:            }
0757:
0758:            public User fetchByContactId(long contactId) throws SystemException {
0759:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
0760:                String finderClassName = User.class.getName();
0761:                String finderMethodName = "fetchByContactId";
0762:                String[] finderParams = new String[] { Long.class.getName() };
0763:                Object[] finderArgs = new Object[] { new Long(contactId) };
0764:
0765:                Object result = null;
0766:
0767:                if (finderClassNameCacheEnabled) {
0768:                    result = FinderCache.getResult(finderClassName,
0769:                            finderMethodName, finderParams, finderArgs,
0770:                            getSessionFactory());
0771:                }
0772:
0773:                if (result == null) {
0774:                    Session session = null;
0775:
0776:                    try {
0777:                        session = openSession();
0778:
0779:                        StringMaker query = new StringMaker();
0780:
0781:                        query
0782:                                .append("FROM com.liferay.portal.model.User WHERE ");
0783:
0784:                        query.append("contactId = ?");
0785:
0786:                        query.append(" ");
0787:
0788:                        Query q = session.createQuery(query.toString());
0789:
0790:                        int queryPos = 0;
0791:
0792:                        q.setLong(queryPos++, contactId);
0793:
0794:                        List list = q.list();
0795:
0796:                        FinderCache.putResult(finderClassNameCacheEnabled,
0797:                                finderClassName, finderMethodName,
0798:                                finderParams, finderArgs, list);
0799:
0800:                        if (list.size() == 0) {
0801:                            return null;
0802:                        } else {
0803:                            return (User) list.get(0);
0804:                        }
0805:                    } catch (Exception e) {
0806:                        throw HibernateUtil.processException(e);
0807:                    } finally {
0808:                        closeSession(session);
0809:                    }
0810:                } else {
0811:                    List list = (List) result;
0812:
0813:                    if (list.size() == 0) {
0814:                        return null;
0815:                    } else {
0816:                        return (User) list.get(0);
0817:                    }
0818:                }
0819:            }
0820:
0821:            public User findByPortraitId(long portraitId)
0822:                    throws NoSuchUserException, SystemException {
0823:                User user = fetchByPortraitId(portraitId);
0824:
0825:                if (user == null) {
0826:                    StringMaker msg = new StringMaker();
0827:
0828:                    msg.append("No User exists with the key {");
0829:
0830:                    msg.append("portraitId=" + portraitId);
0831:
0832:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0833:
0834:                    if (_log.isWarnEnabled()) {
0835:                        _log.warn(msg.toString());
0836:                    }
0837:
0838:                    throw new NoSuchUserException(msg.toString());
0839:                }
0840:
0841:                return user;
0842:            }
0843:
0844:            public User fetchByPortraitId(long portraitId)
0845:                    throws SystemException {
0846:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
0847:                String finderClassName = User.class.getName();
0848:                String finderMethodName = "fetchByPortraitId";
0849:                String[] finderParams = new String[] { Long.class.getName() };
0850:                Object[] finderArgs = new Object[] { new Long(portraitId) };
0851:
0852:                Object result = null;
0853:
0854:                if (finderClassNameCacheEnabled) {
0855:                    result = FinderCache.getResult(finderClassName,
0856:                            finderMethodName, finderParams, finderArgs,
0857:                            getSessionFactory());
0858:                }
0859:
0860:                if (result == null) {
0861:                    Session session = null;
0862:
0863:                    try {
0864:                        session = openSession();
0865:
0866:                        StringMaker query = new StringMaker();
0867:
0868:                        query
0869:                                .append("FROM com.liferay.portal.model.User WHERE ");
0870:
0871:                        query.append("portraitId = ?");
0872:
0873:                        query.append(" ");
0874:
0875:                        Query q = session.createQuery(query.toString());
0876:
0877:                        int queryPos = 0;
0878:
0879:                        q.setLong(queryPos++, portraitId);
0880:
0881:                        List list = q.list();
0882:
0883:                        FinderCache.putResult(finderClassNameCacheEnabled,
0884:                                finderClassName, finderMethodName,
0885:                                finderParams, finderArgs, list);
0886:
0887:                        if (list.size() == 0) {
0888:                            return null;
0889:                        } else {
0890:                            return (User) list.get(0);
0891:                        }
0892:                    } catch (Exception e) {
0893:                        throw HibernateUtil.processException(e);
0894:                    } finally {
0895:                        closeSession(session);
0896:                    }
0897:                } else {
0898:                    List list = (List) result;
0899:
0900:                    if (list.size() == 0) {
0901:                        return null;
0902:                    } else {
0903:                        return (User) list.get(0);
0904:                    }
0905:                }
0906:            }
0907:
0908:            public User findByC_U(long companyId, long userId)
0909:                    throws NoSuchUserException, SystemException {
0910:                User user = fetchByC_U(companyId, userId);
0911:
0912:                if (user == null) {
0913:                    StringMaker msg = new StringMaker();
0914:
0915:                    msg.append("No User exists with the key {");
0916:
0917:                    msg.append("companyId=" + companyId);
0918:
0919:                    msg.append(", ");
0920:                    msg.append("userId=" + userId);
0921:
0922:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0923:
0924:                    if (_log.isWarnEnabled()) {
0925:                        _log.warn(msg.toString());
0926:                    }
0927:
0928:                    throw new NoSuchUserException(msg.toString());
0929:                }
0930:
0931:                return user;
0932:            }
0933:
0934:            public User fetchByC_U(long companyId, long userId)
0935:                    throws SystemException {
0936:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
0937:                String finderClassName = User.class.getName();
0938:                String finderMethodName = "fetchByC_U";
0939:                String[] finderParams = new String[] { Long.class.getName(),
0940:                        Long.class.getName() };
0941:                Object[] finderArgs = new Object[] { new Long(companyId),
0942:                        new Long(userId) };
0943:
0944:                Object result = null;
0945:
0946:                if (finderClassNameCacheEnabled) {
0947:                    result = FinderCache.getResult(finderClassName,
0948:                            finderMethodName, finderParams, finderArgs,
0949:                            getSessionFactory());
0950:                }
0951:
0952:                if (result == null) {
0953:                    Session session = null;
0954:
0955:                    try {
0956:                        session = openSession();
0957:
0958:                        StringMaker query = new StringMaker();
0959:
0960:                        query
0961:                                .append("FROM com.liferay.portal.model.User WHERE ");
0962:
0963:                        query.append("companyId = ?");
0964:
0965:                        query.append(" AND ");
0966:
0967:                        query.append("userId = ?");
0968:
0969:                        query.append(" ");
0970:
0971:                        Query q = session.createQuery(query.toString());
0972:
0973:                        int queryPos = 0;
0974:
0975:                        q.setLong(queryPos++, companyId);
0976:
0977:                        q.setLong(queryPos++, userId);
0978:
0979:                        List list = q.list();
0980:
0981:                        FinderCache.putResult(finderClassNameCacheEnabled,
0982:                                finderClassName, finderMethodName,
0983:                                finderParams, finderArgs, list);
0984:
0985:                        if (list.size() == 0) {
0986:                            return null;
0987:                        } else {
0988:                            return (User) list.get(0);
0989:                        }
0990:                    } catch (Exception e) {
0991:                        throw HibernateUtil.processException(e);
0992:                    } finally {
0993:                        closeSession(session);
0994:                    }
0995:                } else {
0996:                    List list = (List) result;
0997:
0998:                    if (list.size() == 0) {
0999:                        return null;
1000:                    } else {
1001:                        return (User) list.get(0);
1002:                    }
1003:                }
1004:            }
1005:
1006:            public User findByC_DU(long companyId, boolean defaultUser)
1007:                    throws NoSuchUserException, SystemException {
1008:                User user = fetchByC_DU(companyId, defaultUser);
1009:
1010:                if (user == null) {
1011:                    StringMaker msg = new StringMaker();
1012:
1013:                    msg.append("No User exists with the key {");
1014:
1015:                    msg.append("companyId=" + companyId);
1016:
1017:                    msg.append(", ");
1018:                    msg.append("defaultUser=" + defaultUser);
1019:
1020:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1021:
1022:                    if (_log.isWarnEnabled()) {
1023:                        _log.warn(msg.toString());
1024:                    }
1025:
1026:                    throw new NoSuchUserException(msg.toString());
1027:                }
1028:
1029:                return user;
1030:            }
1031:
1032:            public User fetchByC_DU(long companyId, boolean defaultUser)
1033:                    throws SystemException {
1034:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1035:                String finderClassName = User.class.getName();
1036:                String finderMethodName = "fetchByC_DU";
1037:                String[] finderParams = new String[] { Long.class.getName(),
1038:                        Boolean.class.getName() };
1039:                Object[] finderArgs = new Object[] { new Long(companyId),
1040:                        Boolean.valueOf(defaultUser) };
1041:
1042:                Object result = null;
1043:
1044:                if (finderClassNameCacheEnabled) {
1045:                    result = FinderCache.getResult(finderClassName,
1046:                            finderMethodName, finderParams, finderArgs,
1047:                            getSessionFactory());
1048:                }
1049:
1050:                if (result == null) {
1051:                    Session session = null;
1052:
1053:                    try {
1054:                        session = openSession();
1055:
1056:                        StringMaker query = new StringMaker();
1057:
1058:                        query
1059:                                .append("FROM com.liferay.portal.model.User WHERE ");
1060:
1061:                        query.append("companyId = ?");
1062:
1063:                        query.append(" AND ");
1064:
1065:                        query.append("defaultUser = ?");
1066:
1067:                        query.append(" ");
1068:
1069:                        Query q = session.createQuery(query.toString());
1070:
1071:                        int queryPos = 0;
1072:
1073:                        q.setLong(queryPos++, companyId);
1074:
1075:                        q.setBoolean(queryPos++, defaultUser);
1076:
1077:                        List list = q.list();
1078:
1079:                        FinderCache.putResult(finderClassNameCacheEnabled,
1080:                                finderClassName, finderMethodName,
1081:                                finderParams, finderArgs, list);
1082:
1083:                        if (list.size() == 0) {
1084:                            return null;
1085:                        } else {
1086:                            return (User) list.get(0);
1087:                        }
1088:                    } catch (Exception e) {
1089:                        throw HibernateUtil.processException(e);
1090:                    } finally {
1091:                        closeSession(session);
1092:                    }
1093:                } else {
1094:                    List list = (List) result;
1095:
1096:                    if (list.size() == 0) {
1097:                        return null;
1098:                    } else {
1099:                        return (User) list.get(0);
1100:                    }
1101:                }
1102:            }
1103:
1104:            public List findByC_P(long companyId, String password)
1105:                    throws SystemException {
1106:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1107:                String finderClassName = User.class.getName();
1108:                String finderMethodName = "findByC_P";
1109:                String[] finderParams = new String[] { Long.class.getName(),
1110:                        String.class.getName() };
1111:                Object[] finderArgs = new Object[] { new Long(companyId),
1112:                        password };
1113:
1114:                Object result = null;
1115:
1116:                if (finderClassNameCacheEnabled) {
1117:                    result = FinderCache.getResult(finderClassName,
1118:                            finderMethodName, finderParams, finderArgs,
1119:                            getSessionFactory());
1120:                }
1121:
1122:                if (result == null) {
1123:                    Session session = null;
1124:
1125:                    try {
1126:                        session = openSession();
1127:
1128:                        StringMaker query = new StringMaker();
1129:
1130:                        query
1131:                                .append("FROM com.liferay.portal.model.User WHERE ");
1132:
1133:                        query.append("companyId = ?");
1134:
1135:                        query.append(" AND ");
1136:
1137:                        if (password == null) {
1138:                            query.append("password_ IS NULL");
1139:                        } else {
1140:                            query.append("password_ = ?");
1141:                        }
1142:
1143:                        query.append(" ");
1144:
1145:                        Query q = session.createQuery(query.toString());
1146:
1147:                        int queryPos = 0;
1148:
1149:                        q.setLong(queryPos++, companyId);
1150:
1151:                        if (password != null) {
1152:                            q.setString(queryPos++, password);
1153:                        }
1154:
1155:                        List list = q.list();
1156:
1157:                        FinderCache.putResult(finderClassNameCacheEnabled,
1158:                                finderClassName, finderMethodName,
1159:                                finderParams, finderArgs, list);
1160:
1161:                        return list;
1162:                    } catch (Exception e) {
1163:                        throw HibernateUtil.processException(e);
1164:                    } finally {
1165:                        closeSession(session);
1166:                    }
1167:                } else {
1168:                    return (List) result;
1169:                }
1170:            }
1171:
1172:            public List findByC_P(long companyId, String password, int begin,
1173:                    int end) throws SystemException {
1174:                return findByC_P(companyId, password, begin, end, null);
1175:            }
1176:
1177:            public List findByC_P(long companyId, String password, int begin,
1178:                    int end, OrderByComparator obc) throws SystemException {
1179:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1180:                String finderClassName = User.class.getName();
1181:                String finderMethodName = "findByC_P";
1182:                String[] finderParams = new String[] { Long.class.getName(),
1183:                        String.class.getName(),
1184:
1185:                        "java.lang.Integer", "java.lang.Integer",
1186:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1187:                Object[] finderArgs = new Object[] { new Long(companyId),
1188:
1189:                password,
1190:
1191:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
1192:
1193:                Object result = null;
1194:
1195:                if (finderClassNameCacheEnabled) {
1196:                    result = FinderCache.getResult(finderClassName,
1197:                            finderMethodName, finderParams, finderArgs,
1198:                            getSessionFactory());
1199:                }
1200:
1201:                if (result == null) {
1202:                    Session session = null;
1203:
1204:                    try {
1205:                        session = openSession();
1206:
1207:                        StringMaker query = new StringMaker();
1208:
1209:                        query
1210:                                .append("FROM com.liferay.portal.model.User WHERE ");
1211:
1212:                        query.append("companyId = ?");
1213:
1214:                        query.append(" AND ");
1215:
1216:                        if (password == null) {
1217:                            query.append("password_ IS NULL");
1218:                        } else {
1219:                            query.append("password_ = ?");
1220:                        }
1221:
1222:                        query.append(" ");
1223:
1224:                        if (obc != null) {
1225:                            query.append("ORDER BY ");
1226:                            query.append(obc.getOrderBy());
1227:                        }
1228:
1229:                        Query q = session.createQuery(query.toString());
1230:
1231:                        int queryPos = 0;
1232:
1233:                        q.setLong(queryPos++, companyId);
1234:
1235:                        if (password != null) {
1236:                            q.setString(queryPos++, password);
1237:                        }
1238:
1239:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1240:
1241:                        FinderCache.putResult(finderClassNameCacheEnabled,
1242:                                finderClassName, finderMethodName,
1243:                                finderParams, finderArgs, list);
1244:
1245:                        return list;
1246:                    } catch (Exception e) {
1247:                        throw HibernateUtil.processException(e);
1248:                    } finally {
1249:                        closeSession(session);
1250:                    }
1251:                } else {
1252:                    return (List) result;
1253:                }
1254:            }
1255:
1256:            public User findByC_P_First(long companyId, String password,
1257:                    OrderByComparator obc) throws NoSuchUserException,
1258:                    SystemException {
1259:                List list = findByC_P(companyId, password, 0, 1, obc);
1260:
1261:                if (list.size() == 0) {
1262:                    StringMaker msg = new StringMaker();
1263:
1264:                    msg.append("No User exists with the key {");
1265:
1266:                    msg.append("companyId=" + companyId);
1267:
1268:                    msg.append(", ");
1269:                    msg.append("password=" + password);
1270:
1271:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1272:
1273:                    throw new NoSuchUserException(msg.toString());
1274:                } else {
1275:                    return (User) list.get(0);
1276:                }
1277:            }
1278:
1279:            public User findByC_P_Last(long companyId, String password,
1280:                    OrderByComparator obc) throws NoSuchUserException,
1281:                    SystemException {
1282:                int count = countByC_P(companyId, password);
1283:
1284:                List list = findByC_P(companyId, password, count - 1, count,
1285:                        obc);
1286:
1287:                if (list.size() == 0) {
1288:                    StringMaker msg = new StringMaker();
1289:
1290:                    msg.append("No User exists with the key {");
1291:
1292:                    msg.append("companyId=" + companyId);
1293:
1294:                    msg.append(", ");
1295:                    msg.append("password=" + password);
1296:
1297:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1298:
1299:                    throw new NoSuchUserException(msg.toString());
1300:                } else {
1301:                    return (User) list.get(0);
1302:                }
1303:            }
1304:
1305:            public User[] findByC_P_PrevAndNext(long userId, long companyId,
1306:                    String password, OrderByComparator obc)
1307:                    throws NoSuchUserException, SystemException {
1308:                User user = findByPrimaryKey(userId);
1309:
1310:                int count = countByC_P(companyId, password);
1311:
1312:                Session session = null;
1313:
1314:                try {
1315:                    session = openSession();
1316:
1317:                    StringMaker query = new StringMaker();
1318:
1319:                    query.append("FROM com.liferay.portal.model.User WHERE ");
1320:
1321:                    query.append("companyId = ?");
1322:
1323:                    query.append(" AND ");
1324:
1325:                    if (password == null) {
1326:                        query.append("password_ IS NULL");
1327:                    } else {
1328:                        query.append("password_ = ?");
1329:                    }
1330:
1331:                    query.append(" ");
1332:
1333:                    if (obc != null) {
1334:                        query.append("ORDER BY ");
1335:                        query.append(obc.getOrderBy());
1336:                    }
1337:
1338:                    Query q = session.createQuery(query.toString());
1339:
1340:                    int queryPos = 0;
1341:
1342:                    q.setLong(queryPos++, companyId);
1343:
1344:                    if (password != null) {
1345:                        q.setString(queryPos++, password);
1346:                    }
1347:
1348:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1349:                            user);
1350:
1351:                    User[] array = new UserImpl[3];
1352:
1353:                    array[0] = (User) objArray[0];
1354:                    array[1] = (User) objArray[1];
1355:                    array[2] = (User) objArray[2];
1356:
1357:                    return array;
1358:                } catch (Exception e) {
1359:                    throw HibernateUtil.processException(e);
1360:                } finally {
1361:                    closeSession(session);
1362:                }
1363:            }
1364:
1365:            public User findByC_SN(long companyId, String screenName)
1366:                    throws NoSuchUserException, SystemException {
1367:                User user = fetchByC_SN(companyId, screenName);
1368:
1369:                if (user == null) {
1370:                    StringMaker msg = new StringMaker();
1371:
1372:                    msg.append("No User exists with the key {");
1373:
1374:                    msg.append("companyId=" + companyId);
1375:
1376:                    msg.append(", ");
1377:                    msg.append("screenName=" + screenName);
1378:
1379:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1380:
1381:                    if (_log.isWarnEnabled()) {
1382:                        _log.warn(msg.toString());
1383:                    }
1384:
1385:                    throw new NoSuchUserException(msg.toString());
1386:                }
1387:
1388:                return user;
1389:            }
1390:
1391:            public User fetchByC_SN(long companyId, String screenName)
1392:                    throws SystemException {
1393:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1394:                String finderClassName = User.class.getName();
1395:                String finderMethodName = "fetchByC_SN";
1396:                String[] finderParams = new String[] { Long.class.getName(),
1397:                        String.class.getName() };
1398:                Object[] finderArgs = new Object[] { new Long(companyId),
1399:                        screenName };
1400:
1401:                Object result = null;
1402:
1403:                if (finderClassNameCacheEnabled) {
1404:                    result = FinderCache.getResult(finderClassName,
1405:                            finderMethodName, finderParams, finderArgs,
1406:                            getSessionFactory());
1407:                }
1408:
1409:                if (result == null) {
1410:                    Session session = null;
1411:
1412:                    try {
1413:                        session = openSession();
1414:
1415:                        StringMaker query = new StringMaker();
1416:
1417:                        query
1418:                                .append("FROM com.liferay.portal.model.User WHERE ");
1419:
1420:                        query.append("companyId = ?");
1421:
1422:                        query.append(" AND ");
1423:
1424:                        if (screenName == null) {
1425:                            query.append("screenName IS NULL");
1426:                        } else {
1427:                            query.append("screenName = ?");
1428:                        }
1429:
1430:                        query.append(" ");
1431:
1432:                        Query q = session.createQuery(query.toString());
1433:
1434:                        int queryPos = 0;
1435:
1436:                        q.setLong(queryPos++, companyId);
1437:
1438:                        if (screenName != null) {
1439:                            q.setString(queryPos++, screenName);
1440:                        }
1441:
1442:                        List list = q.list();
1443:
1444:                        FinderCache.putResult(finderClassNameCacheEnabled,
1445:                                finderClassName, finderMethodName,
1446:                                finderParams, finderArgs, list);
1447:
1448:                        if (list.size() == 0) {
1449:                            return null;
1450:                        } else {
1451:                            return (User) list.get(0);
1452:                        }
1453:                    } catch (Exception e) {
1454:                        throw HibernateUtil.processException(e);
1455:                    } finally {
1456:                        closeSession(session);
1457:                    }
1458:                } else {
1459:                    List list = (List) result;
1460:
1461:                    if (list.size() == 0) {
1462:                        return null;
1463:                    } else {
1464:                        return (User) list.get(0);
1465:                    }
1466:                }
1467:            }
1468:
1469:            public User findByC_EA(long companyId, String emailAddress)
1470:                    throws NoSuchUserException, SystemException {
1471:                User user = fetchByC_EA(companyId, emailAddress);
1472:
1473:                if (user == null) {
1474:                    StringMaker msg = new StringMaker();
1475:
1476:                    msg.append("No User exists with the key {");
1477:
1478:                    msg.append("companyId=" + companyId);
1479:
1480:                    msg.append(", ");
1481:                    msg.append("emailAddress=" + emailAddress);
1482:
1483:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1484:
1485:                    if (_log.isWarnEnabled()) {
1486:                        _log.warn(msg.toString());
1487:                    }
1488:
1489:                    throw new NoSuchUserException(msg.toString());
1490:                }
1491:
1492:                return user;
1493:            }
1494:
1495:            public User fetchByC_EA(long companyId, String emailAddress)
1496:                    throws SystemException {
1497:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1498:                String finderClassName = User.class.getName();
1499:                String finderMethodName = "fetchByC_EA";
1500:                String[] finderParams = new String[] { Long.class.getName(),
1501:                        String.class.getName() };
1502:                Object[] finderArgs = new Object[] { new Long(companyId),
1503:                        emailAddress };
1504:
1505:                Object result = null;
1506:
1507:                if (finderClassNameCacheEnabled) {
1508:                    result = FinderCache.getResult(finderClassName,
1509:                            finderMethodName, finderParams, finderArgs,
1510:                            getSessionFactory());
1511:                }
1512:
1513:                if (result == null) {
1514:                    Session session = null;
1515:
1516:                    try {
1517:                        session = openSession();
1518:
1519:                        StringMaker query = new StringMaker();
1520:
1521:                        query
1522:                                .append("FROM com.liferay.portal.model.User WHERE ");
1523:
1524:                        query.append("companyId = ?");
1525:
1526:                        query.append(" AND ");
1527:
1528:                        if (emailAddress == null) {
1529:                            query.append("emailAddress IS NULL");
1530:                        } else {
1531:                            query.append("emailAddress = ?");
1532:                        }
1533:
1534:                        query.append(" ");
1535:
1536:                        Query q = session.createQuery(query.toString());
1537:
1538:                        int queryPos = 0;
1539:
1540:                        q.setLong(queryPos++, companyId);
1541:
1542:                        if (emailAddress != null) {
1543:                            q.setString(queryPos++, emailAddress);
1544:                        }
1545:
1546:                        List list = q.list();
1547:
1548:                        FinderCache.putResult(finderClassNameCacheEnabled,
1549:                                finderClassName, finderMethodName,
1550:                                finderParams, finderArgs, list);
1551:
1552:                        if (list.size() == 0) {
1553:                            return null;
1554:                        } else {
1555:                            return (User) list.get(0);
1556:                        }
1557:                    } catch (Exception e) {
1558:                        throw HibernateUtil.processException(e);
1559:                    } finally {
1560:                        closeSession(session);
1561:                    }
1562:                } else {
1563:                    List list = (List) result;
1564:
1565:                    if (list.size() == 0) {
1566:                        return null;
1567:                    } else {
1568:                        return (User) list.get(0);
1569:                    }
1570:                }
1571:            }
1572:
1573:            public List findWithDynamicQuery(
1574:                    DynamicQueryInitializer queryInitializer)
1575:                    throws SystemException {
1576:                Session session = null;
1577:
1578:                try {
1579:                    session = openSession();
1580:
1581:                    DynamicQuery query = queryInitializer.initialize(session);
1582:
1583:                    return query.list();
1584:                } catch (Exception e) {
1585:                    throw HibernateUtil.processException(e);
1586:                } finally {
1587:                    closeSession(session);
1588:                }
1589:            }
1590:
1591:            public List findWithDynamicQuery(
1592:                    DynamicQueryInitializer queryInitializer, int begin, int end)
1593:                    throws SystemException {
1594:                Session session = null;
1595:
1596:                try {
1597:                    session = openSession();
1598:
1599:                    DynamicQuery query = queryInitializer.initialize(session);
1600:
1601:                    query.setLimit(begin, end);
1602:
1603:                    return query.list();
1604:                } catch (Exception e) {
1605:                    throw HibernateUtil.processException(e);
1606:                } finally {
1607:                    closeSession(session);
1608:                }
1609:            }
1610:
1611:            public List findAll() throws SystemException {
1612:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1613:            }
1614:
1615:            public List findAll(int begin, int end) throws SystemException {
1616:                return findAll(begin, end, null);
1617:            }
1618:
1619:            public List findAll(int begin, int end, OrderByComparator obc)
1620:                    throws SystemException {
1621:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1622:                String finderClassName = User.class.getName();
1623:                String finderMethodName = "findAll";
1624:                String[] finderParams = new String[] { "java.lang.Integer",
1625:                        "java.lang.Integer",
1626:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1627:                Object[] finderArgs = new Object[] { String.valueOf(begin),
1628:                        String.valueOf(end), String.valueOf(obc) };
1629:
1630:                Object result = null;
1631:
1632:                if (finderClassNameCacheEnabled) {
1633:                    result = FinderCache.getResult(finderClassName,
1634:                            finderMethodName, finderParams, finderArgs,
1635:                            getSessionFactory());
1636:                }
1637:
1638:                if (result == null) {
1639:                    Session session = null;
1640:
1641:                    try {
1642:                        session = openSession();
1643:
1644:                        StringMaker query = new StringMaker();
1645:
1646:                        query.append("FROM com.liferay.portal.model.User ");
1647:
1648:                        if (obc != null) {
1649:                            query.append("ORDER BY ");
1650:                            query.append(obc.getOrderBy());
1651:                        }
1652:
1653:                        Query q = session.createQuery(query.toString());
1654:
1655:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1656:
1657:                        if (obc == null) {
1658:                            Collections.sort(list);
1659:                        }
1660:
1661:                        FinderCache.putResult(finderClassNameCacheEnabled,
1662:                                finderClassName, finderMethodName,
1663:                                finderParams, finderArgs, list);
1664:
1665:                        return list;
1666:                    } catch (Exception e) {
1667:                        throw HibernateUtil.processException(e);
1668:                    } finally {
1669:                        closeSession(session);
1670:                    }
1671:                } else {
1672:                    return (List) result;
1673:                }
1674:            }
1675:
1676:            public void removeByUuid(String uuid) throws SystemException {
1677:                Iterator itr = findByUuid(uuid).iterator();
1678:
1679:                while (itr.hasNext()) {
1680:                    User user = (User) itr.next();
1681:
1682:                    remove(user);
1683:                }
1684:            }
1685:
1686:            public void removeByCompanyId(long companyId)
1687:                    throws SystemException {
1688:                Iterator itr = findByCompanyId(companyId).iterator();
1689:
1690:                while (itr.hasNext()) {
1691:                    User user = (User) itr.next();
1692:
1693:                    remove(user);
1694:                }
1695:            }
1696:
1697:            public void removeByContactId(long contactId)
1698:                    throws NoSuchUserException, SystemException {
1699:                User user = findByContactId(contactId);
1700:
1701:                remove(user);
1702:            }
1703:
1704:            public void removeByPortraitId(long portraitId)
1705:                    throws NoSuchUserException, SystemException {
1706:                User user = findByPortraitId(portraitId);
1707:
1708:                remove(user);
1709:            }
1710:
1711:            public void removeByC_U(long companyId, long userId)
1712:                    throws NoSuchUserException, SystemException {
1713:                User user = findByC_U(companyId, userId);
1714:
1715:                remove(user);
1716:            }
1717:
1718:            public void removeByC_DU(long companyId, boolean defaultUser)
1719:                    throws NoSuchUserException, SystemException {
1720:                User user = findByC_DU(companyId, defaultUser);
1721:
1722:                remove(user);
1723:            }
1724:
1725:            public void removeByC_P(long companyId, String password)
1726:                    throws SystemException {
1727:                Iterator itr = findByC_P(companyId, password).iterator();
1728:
1729:                while (itr.hasNext()) {
1730:                    User user = (User) itr.next();
1731:
1732:                    remove(user);
1733:                }
1734:            }
1735:
1736:            public void removeByC_SN(long companyId, String screenName)
1737:                    throws NoSuchUserException, SystemException {
1738:                User user = findByC_SN(companyId, screenName);
1739:
1740:                remove(user);
1741:            }
1742:
1743:            public void removeByC_EA(long companyId, String emailAddress)
1744:                    throws NoSuchUserException, SystemException {
1745:                User user = findByC_EA(companyId, emailAddress);
1746:
1747:                remove(user);
1748:            }
1749:
1750:            public void removeAll() throws SystemException {
1751:                Iterator itr = findAll().iterator();
1752:
1753:                while (itr.hasNext()) {
1754:                    remove((User) itr.next());
1755:                }
1756:            }
1757:
1758:            public int countByUuid(String uuid) throws SystemException {
1759:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1760:                String finderClassName = User.class.getName();
1761:                String finderMethodName = "countByUuid";
1762:                String[] finderParams = new String[] { String.class.getName() };
1763:                Object[] finderArgs = new Object[] { uuid };
1764:
1765:                Object result = null;
1766:
1767:                if (finderClassNameCacheEnabled) {
1768:                    result = FinderCache.getResult(finderClassName,
1769:                            finderMethodName, finderParams, finderArgs,
1770:                            getSessionFactory());
1771:                }
1772:
1773:                if (result == null) {
1774:                    Session session = null;
1775:
1776:                    try {
1777:                        session = openSession();
1778:
1779:                        StringMaker query = new StringMaker();
1780:
1781:                        query.append("SELECT COUNT(*) ");
1782:                        query
1783:                                .append("FROM com.liferay.portal.model.User WHERE ");
1784:
1785:                        if (uuid == null) {
1786:                            query.append("uuid_ IS NULL");
1787:                        } else {
1788:                            query.append("uuid_ = ?");
1789:                        }
1790:
1791:                        query.append(" ");
1792:
1793:                        Query q = session.createQuery(query.toString());
1794:
1795:                        int queryPos = 0;
1796:
1797:                        if (uuid != null) {
1798:                            q.setString(queryPos++, uuid);
1799:                        }
1800:
1801:                        Long count = null;
1802:
1803:                        Iterator itr = q.list().iterator();
1804:
1805:                        if (itr.hasNext()) {
1806:                            count = (Long) itr.next();
1807:                        }
1808:
1809:                        if (count == null) {
1810:                            count = new Long(0);
1811:                        }
1812:
1813:                        FinderCache.putResult(finderClassNameCacheEnabled,
1814:                                finderClassName, finderMethodName,
1815:                                finderParams, finderArgs, count);
1816:
1817:                        return count.intValue();
1818:                    } catch (Exception e) {
1819:                        throw HibernateUtil.processException(e);
1820:                    } finally {
1821:                        closeSession(session);
1822:                    }
1823:                } else {
1824:                    return ((Long) result).intValue();
1825:                }
1826:            }
1827:
1828:            public int countByCompanyId(long companyId) throws SystemException {
1829:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1830:                String finderClassName = User.class.getName();
1831:                String finderMethodName = "countByCompanyId";
1832:                String[] finderParams = new String[] { Long.class.getName() };
1833:                Object[] finderArgs = new Object[] { new Long(companyId) };
1834:
1835:                Object result = null;
1836:
1837:                if (finderClassNameCacheEnabled) {
1838:                    result = FinderCache.getResult(finderClassName,
1839:                            finderMethodName, finderParams, finderArgs,
1840:                            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
1853:                                .append("FROM com.liferay.portal.model.User WHERE ");
1854:
1855:                        query.append("companyId = ?");
1856:
1857:                        query.append(" ");
1858:
1859:                        Query q = session.createQuery(query.toString());
1860:
1861:                        int queryPos = 0;
1862:
1863:                        q.setLong(queryPos++, companyId);
1864:
1865:                        Long count = null;
1866:
1867:                        Iterator itr = q.list().iterator();
1868:
1869:                        if (itr.hasNext()) {
1870:                            count = (Long) itr.next();
1871:                        }
1872:
1873:                        if (count == null) {
1874:                            count = new Long(0);
1875:                        }
1876:
1877:                        FinderCache.putResult(finderClassNameCacheEnabled,
1878:                                finderClassName, finderMethodName,
1879:                                finderParams, finderArgs, count);
1880:
1881:                        return count.intValue();
1882:                    } catch (Exception e) {
1883:                        throw HibernateUtil.processException(e);
1884:                    } finally {
1885:                        closeSession(session);
1886:                    }
1887:                } else {
1888:                    return ((Long) result).intValue();
1889:                }
1890:            }
1891:
1892:            public int countByContactId(long contactId) throws SystemException {
1893:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1894:                String finderClassName = User.class.getName();
1895:                String finderMethodName = "countByContactId";
1896:                String[] finderParams = new String[] { Long.class.getName() };
1897:                Object[] finderArgs = new Object[] { new Long(contactId) };
1898:
1899:                Object result = null;
1900:
1901:                if (finderClassNameCacheEnabled) {
1902:                    result = FinderCache.getResult(finderClassName,
1903:                            finderMethodName, finderParams, finderArgs,
1904:                            getSessionFactory());
1905:                }
1906:
1907:                if (result == null) {
1908:                    Session session = null;
1909:
1910:                    try {
1911:                        session = openSession();
1912:
1913:                        StringMaker query = new StringMaker();
1914:
1915:                        query.append("SELECT COUNT(*) ");
1916:                        query
1917:                                .append("FROM com.liferay.portal.model.User WHERE ");
1918:
1919:                        query.append("contactId = ?");
1920:
1921:                        query.append(" ");
1922:
1923:                        Query q = session.createQuery(query.toString());
1924:
1925:                        int queryPos = 0;
1926:
1927:                        q.setLong(queryPos++, contactId);
1928:
1929:                        Long count = null;
1930:
1931:                        Iterator itr = q.list().iterator();
1932:
1933:                        if (itr.hasNext()) {
1934:                            count = (Long) itr.next();
1935:                        }
1936:
1937:                        if (count == null) {
1938:                            count = new Long(0);
1939:                        }
1940:
1941:                        FinderCache.putResult(finderClassNameCacheEnabled,
1942:                                finderClassName, finderMethodName,
1943:                                finderParams, finderArgs, count);
1944:
1945:                        return count.intValue();
1946:                    } catch (Exception e) {
1947:                        throw HibernateUtil.processException(e);
1948:                    } finally {
1949:                        closeSession(session);
1950:                    }
1951:                } else {
1952:                    return ((Long) result).intValue();
1953:                }
1954:            }
1955:
1956:            public int countByPortraitId(long portraitId)
1957:                    throws SystemException {
1958:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
1959:                String finderClassName = User.class.getName();
1960:                String finderMethodName = "countByPortraitId";
1961:                String[] finderParams = new String[] { Long.class.getName() };
1962:                Object[] finderArgs = new Object[] { new Long(portraitId) };
1963:
1964:                Object result = null;
1965:
1966:                if (finderClassNameCacheEnabled) {
1967:                    result = FinderCache.getResult(finderClassName,
1968:                            finderMethodName, finderParams, finderArgs,
1969:                            getSessionFactory());
1970:                }
1971:
1972:                if (result == null) {
1973:                    Session session = null;
1974:
1975:                    try {
1976:                        session = openSession();
1977:
1978:                        StringMaker query = new StringMaker();
1979:
1980:                        query.append("SELECT COUNT(*) ");
1981:                        query
1982:                                .append("FROM com.liferay.portal.model.User WHERE ");
1983:
1984:                        query.append("portraitId = ?");
1985:
1986:                        query.append(" ");
1987:
1988:                        Query q = session.createQuery(query.toString());
1989:
1990:                        int queryPos = 0;
1991:
1992:                        q.setLong(queryPos++, portraitId);
1993:
1994:                        Long count = null;
1995:
1996:                        Iterator itr = q.list().iterator();
1997:
1998:                        if (itr.hasNext()) {
1999:                            count = (Long) itr.next();
2000:                        }
2001:
2002:                        if (count == null) {
2003:                            count = new Long(0);
2004:                        }
2005:
2006:                        FinderCache.putResult(finderClassNameCacheEnabled,
2007:                                finderClassName, finderMethodName,
2008:                                finderParams, finderArgs, count);
2009:
2010:                        return count.intValue();
2011:                    } catch (Exception e) {
2012:                        throw HibernateUtil.processException(e);
2013:                    } finally {
2014:                        closeSession(session);
2015:                    }
2016:                } else {
2017:                    return ((Long) result).intValue();
2018:                }
2019:            }
2020:
2021:            public int countByC_U(long companyId, long userId)
2022:                    throws SystemException {
2023:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
2024:                String finderClassName = User.class.getName();
2025:                String finderMethodName = "countByC_U";
2026:                String[] finderParams = new String[] { Long.class.getName(),
2027:                        Long.class.getName() };
2028:                Object[] finderArgs = new Object[] { new Long(companyId),
2029:                        new Long(userId) };
2030:
2031:                Object result = null;
2032:
2033:                if (finderClassNameCacheEnabled) {
2034:                    result = FinderCache.getResult(finderClassName,
2035:                            finderMethodName, finderParams, finderArgs,
2036:                            getSessionFactory());
2037:                }
2038:
2039:                if (result == null) {
2040:                    Session session = null;
2041:
2042:                    try {
2043:                        session = openSession();
2044:
2045:                        StringMaker query = new StringMaker();
2046:
2047:                        query.append("SELECT COUNT(*) ");
2048:                        query
2049:                                .append("FROM com.liferay.portal.model.User WHERE ");
2050:
2051:                        query.append("companyId = ?");
2052:
2053:                        query.append(" AND ");
2054:
2055:                        query.append("userId = ?");
2056:
2057:                        query.append(" ");
2058:
2059:                        Query q = session.createQuery(query.toString());
2060:
2061:                        int queryPos = 0;
2062:
2063:                        q.setLong(queryPos++, companyId);
2064:
2065:                        q.setLong(queryPos++, userId);
2066:
2067:                        Long count = null;
2068:
2069:                        Iterator itr = q.list().iterator();
2070:
2071:                        if (itr.hasNext()) {
2072:                            count = (Long) itr.next();
2073:                        }
2074:
2075:                        if (count == null) {
2076:                            count = new Long(0);
2077:                        }
2078:
2079:                        FinderCache.putResult(finderClassNameCacheEnabled,
2080:                                finderClassName, finderMethodName,
2081:                                finderParams, finderArgs, count);
2082:
2083:                        return count.intValue();
2084:                    } catch (Exception e) {
2085:                        throw HibernateUtil.processException(e);
2086:                    } finally {
2087:                        closeSession(session);
2088:                    }
2089:                } else {
2090:                    return ((Long) result).intValue();
2091:                }
2092:            }
2093:
2094:            public int countByC_DU(long companyId, boolean defaultUser)
2095:                    throws SystemException {
2096:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
2097:                String finderClassName = User.class.getName();
2098:                String finderMethodName = "countByC_DU";
2099:                String[] finderParams = new String[] { Long.class.getName(),
2100:                        Boolean.class.getName() };
2101:                Object[] finderArgs = new Object[] { new Long(companyId),
2102:                        Boolean.valueOf(defaultUser) };
2103:
2104:                Object result = null;
2105:
2106:                if (finderClassNameCacheEnabled) {
2107:                    result = FinderCache.getResult(finderClassName,
2108:                            finderMethodName, finderParams, finderArgs,
2109:                            getSessionFactory());
2110:                }
2111:
2112:                if (result == null) {
2113:                    Session session = null;
2114:
2115:                    try {
2116:                        session = openSession();
2117:
2118:                        StringMaker query = new StringMaker();
2119:
2120:                        query.append("SELECT COUNT(*) ");
2121:                        query
2122:                                .append("FROM com.liferay.portal.model.User WHERE ");
2123:
2124:                        query.append("companyId = ?");
2125:
2126:                        query.append(" AND ");
2127:
2128:                        query.append("defaultUser = ?");
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.setBoolean(queryPos++, defaultUser);
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,
2154:                                finderParams, finderArgs, count);
2155:
2156:                        return count.intValue();
2157:                    } catch (Exception e) {
2158:                        throw HibernateUtil.processException(e);
2159:                    } finally {
2160:                        closeSession(session);
2161:                    }
2162:                } else {
2163:                    return ((Long) result).intValue();
2164:                }
2165:            }
2166:
2167:            public int countByC_P(long companyId, String password)
2168:                    throws SystemException {
2169:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
2170:                String finderClassName = User.class.getName();
2171:                String finderMethodName = "countByC_P";
2172:                String[] finderParams = new String[] { Long.class.getName(),
2173:                        String.class.getName() };
2174:                Object[] finderArgs = new Object[] { new Long(companyId),
2175:                        password };
2176:
2177:                Object result = null;
2178:
2179:                if (finderClassNameCacheEnabled) {
2180:                    result = FinderCache.getResult(finderClassName,
2181:                            finderMethodName, finderParams, finderArgs,
2182:                            getSessionFactory());
2183:                }
2184:
2185:                if (result == null) {
2186:                    Session session = null;
2187:
2188:                    try {
2189:                        session = openSession();
2190:
2191:                        StringMaker query = new StringMaker();
2192:
2193:                        query.append("SELECT COUNT(*) ");
2194:                        query
2195:                                .append("FROM com.liferay.portal.model.User WHERE ");
2196:
2197:                        query.append("companyId = ?");
2198:
2199:                        query.append(" AND ");
2200:
2201:                        if (password == null) {
2202:                            query.append("password_ IS NULL");
2203:                        } else {
2204:                            query.append("password_ = ?");
2205:                        }
2206:
2207:                        query.append(" ");
2208:
2209:                        Query q = session.createQuery(query.toString());
2210:
2211:                        int queryPos = 0;
2212:
2213:                        q.setLong(queryPos++, companyId);
2214:
2215:                        if (password != null) {
2216:                            q.setString(queryPos++, password);
2217:                        }
2218:
2219:                        Long count = null;
2220:
2221:                        Iterator itr = q.list().iterator();
2222:
2223:                        if (itr.hasNext()) {
2224:                            count = (Long) itr.next();
2225:                        }
2226:
2227:                        if (count == null) {
2228:                            count = new Long(0);
2229:                        }
2230:
2231:                        FinderCache.putResult(finderClassNameCacheEnabled,
2232:                                finderClassName, finderMethodName,
2233:                                finderParams, finderArgs, count);
2234:
2235:                        return count.intValue();
2236:                    } catch (Exception e) {
2237:                        throw HibernateUtil.processException(e);
2238:                    } finally {
2239:                        closeSession(session);
2240:                    }
2241:                } else {
2242:                    return ((Long) result).intValue();
2243:                }
2244:            }
2245:
2246:            public int countByC_SN(long companyId, String screenName)
2247:                    throws SystemException {
2248:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
2249:                String finderClassName = User.class.getName();
2250:                String finderMethodName = "countByC_SN";
2251:                String[] finderParams = new String[] { Long.class.getName(),
2252:                        String.class.getName() };
2253:                Object[] finderArgs = new Object[] { new Long(companyId),
2254:                        screenName };
2255:
2256:                Object result = null;
2257:
2258:                if (finderClassNameCacheEnabled) {
2259:                    result = FinderCache.getResult(finderClassName,
2260:                            finderMethodName, finderParams, finderArgs,
2261:                            getSessionFactory());
2262:                }
2263:
2264:                if (result == null) {
2265:                    Session session = null;
2266:
2267:                    try {
2268:                        session = openSession();
2269:
2270:                        StringMaker query = new StringMaker();
2271:
2272:                        query.append("SELECT COUNT(*) ");
2273:                        query
2274:                                .append("FROM com.liferay.portal.model.User WHERE ");
2275:
2276:                        query.append("companyId = ?");
2277:
2278:                        query.append(" AND ");
2279:
2280:                        if (screenName == null) {
2281:                            query.append("screenName IS NULL");
2282:                        } else {
2283:                            query.append("screenName = ?");
2284:                        }
2285:
2286:                        query.append(" ");
2287:
2288:                        Query q = session.createQuery(query.toString());
2289:
2290:                        int queryPos = 0;
2291:
2292:                        q.setLong(queryPos++, companyId);
2293:
2294:                        if (screenName != null) {
2295:                            q.setString(queryPos++, screenName);
2296:                        }
2297:
2298:                        Long count = null;
2299:
2300:                        Iterator itr = q.list().iterator();
2301:
2302:                        if (itr.hasNext()) {
2303:                            count = (Long) itr.next();
2304:                        }
2305:
2306:                        if (count == null) {
2307:                            count = new Long(0);
2308:                        }
2309:
2310:                        FinderCache.putResult(finderClassNameCacheEnabled,
2311:                                finderClassName, finderMethodName,
2312:                                finderParams, finderArgs, count);
2313:
2314:                        return count.intValue();
2315:                    } catch (Exception e) {
2316:                        throw HibernateUtil.processException(e);
2317:                    } finally {
2318:                        closeSession(session);
2319:                    }
2320:                } else {
2321:                    return ((Long) result).intValue();
2322:                }
2323:            }
2324:
2325:            public int countByC_EA(long companyId, String emailAddress)
2326:                    throws SystemException {
2327:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
2328:                String finderClassName = User.class.getName();
2329:                String finderMethodName = "countByC_EA";
2330:                String[] finderParams = new String[] { Long.class.getName(),
2331:                        String.class.getName() };
2332:                Object[] finderArgs = new Object[] { new Long(companyId),
2333:                        emailAddress };
2334:
2335:                Object result = null;
2336:
2337:                if (finderClassNameCacheEnabled) {
2338:                    result = FinderCache.getResult(finderClassName,
2339:                            finderMethodName, finderParams, finderArgs,
2340:                            getSessionFactory());
2341:                }
2342:
2343:                if (result == null) {
2344:                    Session session = null;
2345:
2346:                    try {
2347:                        session = openSession();
2348:
2349:                        StringMaker query = new StringMaker();
2350:
2351:                        query.append("SELECT COUNT(*) ");
2352:                        query
2353:                                .append("FROM com.liferay.portal.model.User WHERE ");
2354:
2355:                        query.append("companyId = ?");
2356:
2357:                        query.append(" AND ");
2358:
2359:                        if (emailAddress == null) {
2360:                            query.append("emailAddress IS NULL");
2361:                        } else {
2362:                            query.append("emailAddress = ?");
2363:                        }
2364:
2365:                        query.append(" ");
2366:
2367:                        Query q = session.createQuery(query.toString());
2368:
2369:                        int queryPos = 0;
2370:
2371:                        q.setLong(queryPos++, companyId);
2372:
2373:                        if (emailAddress != null) {
2374:                            q.setString(queryPos++, emailAddress);
2375:                        }
2376:
2377:                        Long count = null;
2378:
2379:                        Iterator itr = q.list().iterator();
2380:
2381:                        if (itr.hasNext()) {
2382:                            count = (Long) itr.next();
2383:                        }
2384:
2385:                        if (count == null) {
2386:                            count = new Long(0);
2387:                        }
2388:
2389:                        FinderCache.putResult(finderClassNameCacheEnabled,
2390:                                finderClassName, finderMethodName,
2391:                                finderParams, finderArgs, count);
2392:
2393:                        return count.intValue();
2394:                    } catch (Exception e) {
2395:                        throw HibernateUtil.processException(e);
2396:                    } finally {
2397:                        closeSession(session);
2398:                    }
2399:                } else {
2400:                    return ((Long) result).intValue();
2401:                }
2402:            }
2403:
2404:            public int countAll() throws SystemException {
2405:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED;
2406:                String finderClassName = User.class.getName();
2407:                String finderMethodName = "countAll";
2408:                String[] finderParams = new String[] {};
2409:                Object[] finderArgs = new Object[] {};
2410:
2411:                Object result = null;
2412:
2413:                if (finderClassNameCacheEnabled) {
2414:                    result = FinderCache.getResult(finderClassName,
2415:                            finderMethodName, finderParams, finderArgs,
2416:                            getSessionFactory());
2417:                }
2418:
2419:                if (result == null) {
2420:                    Session session = null;
2421:
2422:                    try {
2423:                        session = openSession();
2424:
2425:                        Query q = session
2426:                                .createQuery("SELECT COUNT(*) FROM com.liferay.portal.model.User");
2427:
2428:                        Long count = null;
2429:
2430:                        Iterator itr = q.list().iterator();
2431:
2432:                        if (itr.hasNext()) {
2433:                            count = (Long) itr.next();
2434:                        }
2435:
2436:                        if (count == null) {
2437:                            count = new Long(0);
2438:                        }
2439:
2440:                        FinderCache.putResult(finderClassNameCacheEnabled,
2441:                                finderClassName, finderMethodName,
2442:                                finderParams, finderArgs, count);
2443:
2444:                        return count.intValue();
2445:                    } catch (Exception e) {
2446:                        throw HibernateUtil.processException(e);
2447:                    } finally {
2448:                        closeSession(session);
2449:                    }
2450:                } else {
2451:                    return ((Long) result).intValue();
2452:                }
2453:            }
2454:
2455:            public List getGroups(long pk) throws NoSuchUserException,
2456:                    SystemException {
2457:                return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2458:            }
2459:
2460:            public List getGroups(long pk, int begin, int end)
2461:                    throws NoSuchUserException, SystemException {
2462:                return getGroups(pk, begin, end, null);
2463:            }
2464:
2465:            public List getGroups(long pk, int begin, int end,
2466:                    OrderByComparator obc) throws NoSuchUserException,
2467:                    SystemException {
2468:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_GROUPS;
2469:                String finderClassName = "Users_Groups";
2470:                String finderMethodName = "getGroups";
2471:                String[] finderParams = new String[] { Long.class.getName(),
2472:                        "java.lang.Integer", "java.lang.Integer",
2473:                        "com.liferay.portal.kernel.util.OrderByComparator" };
2474:                Object[] finderArgs = new Object[] { new Long(pk),
2475:                        String.valueOf(begin), String.valueOf(end),
2476:                        String.valueOf(obc) };
2477:
2478:                Object result = null;
2479:
2480:                if (finderClassNameCacheEnabled) {
2481:                    result = FinderCache.getResult(finderClassName,
2482:                            finderMethodName, finderParams, finderArgs,
2483:                            getSessionFactory());
2484:                }
2485:
2486:                if (result == null) {
2487:                    Session session = null;
2488:
2489:                    try {
2490:                        session = HibernateUtil.openSession();
2491:
2492:                        StringMaker sm = new StringMaker();
2493:
2494:                        sm.append(_SQL_GETGROUPS);
2495:
2496:                        if (obc != null) {
2497:                            sm.append("ORDER BY ");
2498:                            sm.append(obc.getOrderBy());
2499:                        }
2500:
2501:                        else {
2502:                            sm.append("ORDER BY ");
2503:
2504:                            sm.append("Group_.name ASC");
2505:                        }
2506:
2507:                        String sql = sm.toString();
2508:
2509:                        SQLQuery q = session.createSQLQuery(sql);
2510:
2511:                        q.addEntity("Group_",
2512:                                com.liferay.portal.model.impl.GroupImpl.class);
2513:
2514:                        QueryPos qPos = QueryPos.getInstance(q);
2515:
2516:                        qPos.add(pk);
2517:
2518:                        List list = QueryUtil.list(q, getDialect(), begin, end);
2519:
2520:                        FinderCache.putResult(finderClassNameCacheEnabled,
2521:                                finderClassName, finderMethodName,
2522:                                finderParams, finderArgs, list);
2523:
2524:                        return list;
2525:                    } catch (Exception e) {
2526:                        throw new SystemException(e);
2527:                    } finally {
2528:                        closeSession(session);
2529:                    }
2530:                } else {
2531:                    return (List) result;
2532:                }
2533:            }
2534:
2535:            public int getGroupsSize(long pk) throws SystemException {
2536:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_GROUPS;
2537:                String finderClassName = "Users_Groups";
2538:                String finderMethodName = "getGroupsSize";
2539:                String[] finderParams = new String[] { Long.class.getName() };
2540:                Object[] finderArgs = new Object[] { new Long(pk) };
2541:
2542:                Object result = null;
2543:
2544:                if (finderClassNameCacheEnabled) {
2545:                    result = FinderCache.getResult(finderClassName,
2546:                            finderMethodName, finderParams, finderArgs,
2547:                            getSessionFactory());
2548:                }
2549:
2550:                if (result == null) {
2551:                    Session session = null;
2552:
2553:                    try {
2554:                        session = openSession();
2555:
2556:                        SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
2557:
2558:                        q.addScalar(HibernateUtil.getCountColumnName(),
2559:                                Hibernate.LONG);
2560:
2561:                        QueryPos qPos = QueryPos.getInstance(q);
2562:
2563:                        qPos.add(pk);
2564:
2565:                        Long count = null;
2566:
2567:                        Iterator itr = q.list().iterator();
2568:
2569:                        if (itr.hasNext()) {
2570:                            count = (Long) itr.next();
2571:                        }
2572:
2573:                        if (count == null) {
2574:                            count = new Long(0);
2575:                        }
2576:
2577:                        FinderCache.putResult(finderClassNameCacheEnabled,
2578:                                finderClassName, finderMethodName,
2579:                                finderParams, finderArgs, count);
2580:
2581:                        return count.intValue();
2582:                    } catch (Exception e) {
2583:                        throw HibernateUtil.processException(e);
2584:                    } finally {
2585:                        closeSession(session);
2586:                    }
2587:                } else {
2588:                    return ((Long) result).intValue();
2589:                }
2590:            }
2591:
2592:            public boolean containsGroup(long pk, long groupPK)
2593:                    throws SystemException {
2594:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_GROUPS;
2595:                String finderClassName = "Users_Groups";
2596:                String finderMethodName = "containsGroups";
2597:                String[] finderParams = new String[] { Long.class.getName(),
2598:
2599:                Long.class.getName() };
2600:                Object[] finderArgs = new Object[] { new Long(pk),
2601:                        new Long(groupPK) };
2602:
2603:                Object result = null;
2604:
2605:                if (finderClassNameCacheEnabled) {
2606:                    result = FinderCache.getResult(finderClassName,
2607:                            finderMethodName, finderParams, finderArgs,
2608:                            getSessionFactory());
2609:                }
2610:
2611:                if (result == null) {
2612:                    try {
2613:                        Boolean value = Boolean.valueOf(containsGroup.contains(
2614:                                pk, groupPK));
2615:
2616:                        FinderCache.putResult(finderClassNameCacheEnabled,
2617:                                finderClassName, finderMethodName,
2618:                                finderParams, finderArgs, value);
2619:
2620:                        return value.booleanValue();
2621:                    } catch (DataAccessException dae) {
2622:                        throw new SystemException(dae);
2623:                    }
2624:                } else {
2625:                    return ((Boolean) result).booleanValue();
2626:                }
2627:            }
2628:
2629:            public boolean containsGroups(long pk) throws SystemException {
2630:                if (getGroupsSize(pk) > 0) {
2631:                    return true;
2632:                } else {
2633:                    return false;
2634:                }
2635:            }
2636:
2637:            public void addGroup(long pk, long groupPK)
2638:                    throws NoSuchUserException,
2639:                    com.liferay.portal.NoSuchGroupException, SystemException {
2640:                try {
2641:                    addGroup.add(pk, groupPK);
2642:                } catch (DataAccessException dae) {
2643:                    throw new SystemException(dae);
2644:                } finally {
2645:                    FinderCache.clearCache("Users_Groups");
2646:                }
2647:            }
2648:
2649:            public void addGroup(long pk, com.liferay.portal.model.Group group)
2650:                    throws NoSuchUserException,
2651:                    com.liferay.portal.NoSuchGroupException, SystemException {
2652:                try {
2653:                    addGroup.add(pk, group.getPrimaryKey());
2654:                } catch (DataAccessException dae) {
2655:                    throw new SystemException(dae);
2656:                } finally {
2657:                    FinderCache.clearCache("Users_Groups");
2658:                }
2659:            }
2660:
2661:            public void addGroups(long pk, long[] groupPKs)
2662:                    throws NoSuchUserException,
2663:                    com.liferay.portal.NoSuchGroupException, SystemException {
2664:                try {
2665:                    for (int i = 0; i < groupPKs.length; i++) {
2666:                        addGroup.add(pk, groupPKs[i]);
2667:                    }
2668:                } catch (DataAccessException dae) {
2669:                    throw new SystemException(dae);
2670:                } finally {
2671:                    FinderCache.clearCache("Users_Groups");
2672:                }
2673:            }
2674:
2675:            public void addGroups(long pk, List groups)
2676:                    throws NoSuchUserException,
2677:                    com.liferay.portal.NoSuchGroupException, SystemException {
2678:                try {
2679:                    for (int i = 0; i < groups.size(); i++) {
2680:                        com.liferay.portal.model.Group group = (com.liferay.portal.model.Group) groups
2681:                                .get(i);
2682:
2683:                        addGroup.add(pk, group.getPrimaryKey());
2684:                    }
2685:                } catch (DataAccessException dae) {
2686:                    throw new SystemException(dae);
2687:                } finally {
2688:                    FinderCache.clearCache("Users_Groups");
2689:                }
2690:            }
2691:
2692:            public void clearGroups(long pk) throws NoSuchUserException,
2693:                    SystemException {
2694:                try {
2695:                    clearGroups.clear(pk);
2696:                } catch (DataAccessException dae) {
2697:                    throw new SystemException(dae);
2698:                } finally {
2699:                    FinderCache.clearCache("Users_Groups");
2700:                }
2701:            }
2702:
2703:            public void removeGroup(long pk, long groupPK)
2704:                    throws NoSuchUserException,
2705:                    com.liferay.portal.NoSuchGroupException, SystemException {
2706:                try {
2707:                    removeGroup.remove(pk, groupPK);
2708:                } catch (DataAccessException dae) {
2709:                    throw new SystemException(dae);
2710:                } finally {
2711:                    FinderCache.clearCache("Users_Groups");
2712:                }
2713:            }
2714:
2715:            public void removeGroup(long pk,
2716:                    com.liferay.portal.model.Group group)
2717:                    throws NoSuchUserException,
2718:                    com.liferay.portal.NoSuchGroupException, SystemException {
2719:                try {
2720:                    removeGroup.remove(pk, group.getPrimaryKey());
2721:                } catch (DataAccessException dae) {
2722:                    throw new SystemException(dae);
2723:                } finally {
2724:                    FinderCache.clearCache("Users_Groups");
2725:                }
2726:            }
2727:
2728:            public void removeGroups(long pk, long[] groupPKs)
2729:                    throws NoSuchUserException,
2730:                    com.liferay.portal.NoSuchGroupException, SystemException {
2731:                try {
2732:                    for (int i = 0; i < groupPKs.length; i++) {
2733:                        removeGroup.remove(pk, groupPKs[i]);
2734:                    }
2735:                } catch (DataAccessException dae) {
2736:                    throw new SystemException(dae);
2737:                } finally {
2738:                    FinderCache.clearCache("Users_Groups");
2739:                }
2740:            }
2741:
2742:            public void removeGroups(long pk, List groups)
2743:                    throws NoSuchUserException,
2744:                    com.liferay.portal.NoSuchGroupException, SystemException {
2745:                try {
2746:                    for (int i = 0; i < groups.size(); i++) {
2747:                        com.liferay.portal.model.Group group = (com.liferay.portal.model.Group) groups
2748:                                .get(i);
2749:
2750:                        removeGroup.remove(pk, group.getPrimaryKey());
2751:                    }
2752:                } catch (DataAccessException dae) {
2753:                    throw new SystemException(dae);
2754:                } finally {
2755:                    FinderCache.clearCache("Users_Groups");
2756:                }
2757:            }
2758:
2759:            public void setGroups(long pk, long[] groupPKs)
2760:                    throws NoSuchUserException,
2761:                    com.liferay.portal.NoSuchGroupException, SystemException {
2762:                try {
2763:                    clearGroups.clear(pk);
2764:
2765:                    for (int i = 0; i < groupPKs.length; i++) {
2766:                        addGroup.add(pk, groupPKs[i]);
2767:                    }
2768:                } catch (DataAccessException dae) {
2769:                    throw new SystemException(dae);
2770:                } finally {
2771:                    FinderCache.clearCache("Users_Groups");
2772:                }
2773:            }
2774:
2775:            public void setGroups(long pk, List groups)
2776:                    throws NoSuchUserException,
2777:                    com.liferay.portal.NoSuchGroupException, SystemException {
2778:                try {
2779:                    clearGroups.clear(pk);
2780:
2781:                    for (int i = 0; i < groups.size(); i++) {
2782:                        com.liferay.portal.model.Group group = (com.liferay.portal.model.Group) groups
2783:                                .get(i);
2784:
2785:                        addGroup.add(pk, group.getPrimaryKey());
2786:                    }
2787:                } catch (DataAccessException dae) {
2788:                    throw new SystemException(dae);
2789:                } finally {
2790:                    FinderCache.clearCache("Users_Groups");
2791:                }
2792:            }
2793:
2794:            public List getOrganizations(long pk) throws NoSuchUserException,
2795:                    SystemException {
2796:                return getOrganizations(pk, QueryUtil.ALL_POS,
2797:                        QueryUtil.ALL_POS);
2798:            }
2799:
2800:            public List getOrganizations(long pk, int begin, int end)
2801:                    throws NoSuchUserException, SystemException {
2802:                return getOrganizations(pk, begin, end, null);
2803:            }
2804:
2805:            public List getOrganizations(long pk, int begin, int end,
2806:                    OrderByComparator obc) throws NoSuchUserException,
2807:                    SystemException {
2808:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_ORGS;
2809:                String finderClassName = "Users_Orgs";
2810:                String finderMethodName = "getOrganizations";
2811:                String[] finderParams = new String[] { Long.class.getName(),
2812:                        "java.lang.Integer", "java.lang.Integer",
2813:                        "com.liferay.portal.kernel.util.OrderByComparator" };
2814:                Object[] finderArgs = new Object[] { new Long(pk),
2815:                        String.valueOf(begin), String.valueOf(end),
2816:                        String.valueOf(obc) };
2817:
2818:                Object result = null;
2819:
2820:                if (finderClassNameCacheEnabled) {
2821:                    result = FinderCache.getResult(finderClassName,
2822:                            finderMethodName, finderParams, finderArgs,
2823:                            getSessionFactory());
2824:                }
2825:
2826:                if (result == null) {
2827:                    Session session = null;
2828:
2829:                    try {
2830:                        session = HibernateUtil.openSession();
2831:
2832:                        StringMaker sm = new StringMaker();
2833:
2834:                        sm.append(_SQL_GETORGANIZATIONS);
2835:
2836:                        if (obc != null) {
2837:                            sm.append("ORDER BY ");
2838:                            sm.append(obc.getOrderBy());
2839:                        }
2840:
2841:                        else {
2842:                            sm.append("ORDER BY ");
2843:
2844:                            sm.append("Organization_.name ASC");
2845:                        }
2846:
2847:                        String sql = sm.toString();
2848:
2849:                        SQLQuery q = session.createSQLQuery(sql);
2850:
2851:                        q
2852:                                .addEntity(
2853:                                        "Organization_",
2854:                                        com.liferay.portal.model.impl.OrganizationImpl.class);
2855:
2856:                        QueryPos qPos = QueryPos.getInstance(q);
2857:
2858:                        qPos.add(pk);
2859:
2860:                        List list = QueryUtil.list(q, getDialect(), begin, end);
2861:
2862:                        FinderCache.putResult(finderClassNameCacheEnabled,
2863:                                finderClassName, finderMethodName,
2864:                                finderParams, finderArgs, list);
2865:
2866:                        return list;
2867:                    } catch (Exception e) {
2868:                        throw new SystemException(e);
2869:                    } finally {
2870:                        closeSession(session);
2871:                    }
2872:                } else {
2873:                    return (List) result;
2874:                }
2875:            }
2876:
2877:            public int getOrganizationsSize(long pk) throws SystemException {
2878:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_ORGS;
2879:                String finderClassName = "Users_Orgs";
2880:                String finderMethodName = "getOrganizationsSize";
2881:                String[] finderParams = new String[] { Long.class.getName() };
2882:                Object[] finderArgs = new Object[] { new Long(pk) };
2883:
2884:                Object result = null;
2885:
2886:                if (finderClassNameCacheEnabled) {
2887:                    result = FinderCache.getResult(finderClassName,
2888:                            finderMethodName, finderParams, finderArgs,
2889:                            getSessionFactory());
2890:                }
2891:
2892:                if (result == null) {
2893:                    Session session = null;
2894:
2895:                    try {
2896:                        session = openSession();
2897:
2898:                        SQLQuery q = session
2899:                                .createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
2900:
2901:                        q.addScalar(HibernateUtil.getCountColumnName(),
2902:                                Hibernate.LONG);
2903:
2904:                        QueryPos qPos = QueryPos.getInstance(q);
2905:
2906:                        qPos.add(pk);
2907:
2908:                        Long count = null;
2909:
2910:                        Iterator itr = q.list().iterator();
2911:
2912:                        if (itr.hasNext()) {
2913:                            count = (Long) itr.next();
2914:                        }
2915:
2916:                        if (count == null) {
2917:                            count = new Long(0);
2918:                        }
2919:
2920:                        FinderCache.putResult(finderClassNameCacheEnabled,
2921:                                finderClassName, finderMethodName,
2922:                                finderParams, finderArgs, count);
2923:
2924:                        return count.intValue();
2925:                    } catch (Exception e) {
2926:                        throw HibernateUtil.processException(e);
2927:                    } finally {
2928:                        closeSession(session);
2929:                    }
2930:                } else {
2931:                    return ((Long) result).intValue();
2932:                }
2933:            }
2934:
2935:            public boolean containsOrganization(long pk, long organizationPK)
2936:                    throws SystemException {
2937:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_ORGS;
2938:                String finderClassName = "Users_Orgs";
2939:                String finderMethodName = "containsOrganizations";
2940:                String[] finderParams = new String[] { Long.class.getName(),
2941:
2942:                Long.class.getName() };
2943:                Object[] finderArgs = new Object[] { new Long(pk),
2944:
2945:                new Long(organizationPK) };
2946:
2947:                Object result = null;
2948:
2949:                if (finderClassNameCacheEnabled) {
2950:                    result = FinderCache.getResult(finderClassName,
2951:                            finderMethodName, finderParams, finderArgs,
2952:                            getSessionFactory());
2953:                }
2954:
2955:                if (result == null) {
2956:                    try {
2957:                        Boolean value = Boolean.valueOf(containsOrganization
2958:                                .contains(pk, organizationPK));
2959:
2960:                        FinderCache.putResult(finderClassNameCacheEnabled,
2961:                                finderClassName, finderMethodName,
2962:                                finderParams, finderArgs, value);
2963:
2964:                        return value.booleanValue();
2965:                    } catch (DataAccessException dae) {
2966:                        throw new SystemException(dae);
2967:                    }
2968:                } else {
2969:                    return ((Boolean) result).booleanValue();
2970:                }
2971:            }
2972:
2973:            public boolean containsOrganizations(long pk)
2974:                    throws SystemException {
2975:                if (getOrganizationsSize(pk) > 0) {
2976:                    return true;
2977:                } else {
2978:                    return false;
2979:                }
2980:            }
2981:
2982:            public void addOrganization(long pk, long organizationPK)
2983:                    throws NoSuchUserException,
2984:                    com.liferay.portal.NoSuchOrganizationException,
2985:                    SystemException {
2986:                try {
2987:                    addOrganization.add(pk, organizationPK);
2988:                } catch (DataAccessException dae) {
2989:                    throw new SystemException(dae);
2990:                } finally {
2991:                    FinderCache.clearCache("Users_Orgs");
2992:                }
2993:            }
2994:
2995:            public void addOrganization(long pk,
2996:                    com.liferay.portal.model.Organization organization)
2997:                    throws NoSuchUserException,
2998:                    com.liferay.portal.NoSuchOrganizationException,
2999:                    SystemException {
3000:                try {
3001:                    addOrganization.add(pk, organization.getPrimaryKey());
3002:                } catch (DataAccessException dae) {
3003:                    throw new SystemException(dae);
3004:                } finally {
3005:                    FinderCache.clearCache("Users_Orgs");
3006:                }
3007:            }
3008:
3009:            public void addOrganizations(long pk, long[] organizationPKs)
3010:                    throws NoSuchUserException,
3011:                    com.liferay.portal.NoSuchOrganizationException,
3012:                    SystemException {
3013:                try {
3014:                    for (int i = 0; i < organizationPKs.length; i++) {
3015:                        addOrganization.add(pk, organizationPKs[i]);
3016:                    }
3017:                } catch (DataAccessException dae) {
3018:                    throw new SystemException(dae);
3019:                } finally {
3020:                    FinderCache.clearCache("Users_Orgs");
3021:                }
3022:            }
3023:
3024:            public void addOrganizations(long pk, List organizations)
3025:                    throws NoSuchUserException,
3026:                    com.liferay.portal.NoSuchOrganizationException,
3027:                    SystemException {
3028:                try {
3029:                    for (int i = 0; i < organizations.size(); i++) {
3030:                        com.liferay.portal.model.Organization organization = (com.liferay.portal.model.Organization) organizations
3031:                                .get(i);
3032:
3033:                        addOrganization.add(pk, organization.getPrimaryKey());
3034:                    }
3035:                } catch (DataAccessException dae) {
3036:                    throw new SystemException(dae);
3037:                } finally {
3038:                    FinderCache.clearCache("Users_Orgs");
3039:                }
3040:            }
3041:
3042:            public void clearOrganizations(long pk) throws NoSuchUserException,
3043:                    SystemException {
3044:                try {
3045:                    clearOrganizations.clear(pk);
3046:                } catch (DataAccessException dae) {
3047:                    throw new SystemException(dae);
3048:                } finally {
3049:                    FinderCache.clearCache("Users_Orgs");
3050:                }
3051:            }
3052:
3053:            public void removeOrganization(long pk, long organizationPK)
3054:                    throws NoSuchUserException,
3055:                    com.liferay.portal.NoSuchOrganizationException,
3056:                    SystemException {
3057:                try {
3058:                    removeOrganization.remove(pk, organizationPK);
3059:                } catch (DataAccessException dae) {
3060:                    throw new SystemException(dae);
3061:                } finally {
3062:                    FinderCache.clearCache("Users_Orgs");
3063:                }
3064:            }
3065:
3066:            public void removeOrganization(long pk,
3067:                    com.liferay.portal.model.Organization organization)
3068:                    throws NoSuchUserException,
3069:                    com.liferay.portal.NoSuchOrganizationException,
3070:                    SystemException {
3071:                try {
3072:                    removeOrganization.remove(pk, organization.getPrimaryKey());
3073:                } catch (DataAccessException dae) {
3074:                    throw new SystemException(dae);
3075:                } finally {
3076:                    FinderCache.clearCache("Users_Orgs");
3077:                }
3078:            }
3079:
3080:            public void removeOrganizations(long pk, long[] organizationPKs)
3081:                    throws NoSuchUserException,
3082:                    com.liferay.portal.NoSuchOrganizationException,
3083:                    SystemException {
3084:                try {
3085:                    for (int i = 0; i < organizationPKs.length; i++) {
3086:                        removeOrganization.remove(pk, organizationPKs[i]);
3087:                    }
3088:                } catch (DataAccessException dae) {
3089:                    throw new SystemException(dae);
3090:                } finally {
3091:                    FinderCache.clearCache("Users_Orgs");
3092:                }
3093:            }
3094:
3095:            public void removeOrganizations(long pk, List organizations)
3096:                    throws NoSuchUserException,
3097:                    com.liferay.portal.NoSuchOrganizationException,
3098:                    SystemException {
3099:                try {
3100:                    for (int i = 0; i < organizations.size(); i++) {
3101:                        com.liferay.portal.model.Organization organization = (com.liferay.portal.model.Organization) organizations
3102:                                .get(i);
3103:
3104:                        removeOrganization.remove(pk, organization
3105:                                .getPrimaryKey());
3106:                    }
3107:                } catch (DataAccessException dae) {
3108:                    throw new SystemException(dae);
3109:                } finally {
3110:                    FinderCache.clearCache("Users_Orgs");
3111:                }
3112:            }
3113:
3114:            public void setOrganizations(long pk, long[] organizationPKs)
3115:                    throws NoSuchUserException,
3116:                    com.liferay.portal.NoSuchOrganizationException,
3117:                    SystemException {
3118:                try {
3119:                    clearOrganizations.clear(pk);
3120:
3121:                    for (int i = 0; i < organizationPKs.length; i++) {
3122:                        addOrganization.add(pk, organizationPKs[i]);
3123:                    }
3124:                } catch (DataAccessException dae) {
3125:                    throw new SystemException(dae);
3126:                } finally {
3127:                    FinderCache.clearCache("Users_Orgs");
3128:                }
3129:            }
3130:
3131:            public void setOrganizations(long pk, List organizations)
3132:                    throws NoSuchUserException,
3133:                    com.liferay.portal.NoSuchOrganizationException,
3134:                    SystemException {
3135:                try {
3136:                    clearOrganizations.clear(pk);
3137:
3138:                    for (int i = 0; i < organizations.size(); i++) {
3139:                        com.liferay.portal.model.Organization organization = (com.liferay.portal.model.Organization) organizations
3140:                                .get(i);
3141:
3142:                        addOrganization.add(pk, organization.getPrimaryKey());
3143:                    }
3144:                } catch (DataAccessException dae) {
3145:                    throw new SystemException(dae);
3146:                } finally {
3147:                    FinderCache.clearCache("Users_Orgs");
3148:                }
3149:            }
3150:
3151:            public List getPermissions(long pk) throws NoSuchUserException,
3152:                    SystemException {
3153:                return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3154:            }
3155:
3156:            public List getPermissions(long pk, int begin, int end)
3157:                    throws NoSuchUserException, SystemException {
3158:                return getPermissions(pk, begin, end, null);
3159:            }
3160:
3161:            public List getPermissions(long pk, int begin, int end,
3162:                    OrderByComparator obc) throws NoSuchUserException,
3163:                    SystemException {
3164:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_PERMISSIONS;
3165:                String finderClassName = "Users_Permissions";
3166:                String finderMethodName = "getPermissions";
3167:                String[] finderParams = new String[] { Long.class.getName(),
3168:                        "java.lang.Integer", "java.lang.Integer",
3169:                        "com.liferay.portal.kernel.util.OrderByComparator" };
3170:                Object[] finderArgs = new Object[] { new Long(pk),
3171:                        String.valueOf(begin), String.valueOf(end),
3172:                        String.valueOf(obc) };
3173:
3174:                Object result = null;
3175:
3176:                if (finderClassNameCacheEnabled) {
3177:                    result = FinderCache.getResult(finderClassName,
3178:                            finderMethodName, finderParams, finderArgs,
3179:                            getSessionFactory());
3180:                }
3181:
3182:                if (result == null) {
3183:                    Session session = null;
3184:
3185:                    try {
3186:                        session = HibernateUtil.openSession();
3187:
3188:                        StringMaker sm = new StringMaker();
3189:
3190:                        sm.append(_SQL_GETPERMISSIONS);
3191:
3192:                        if (obc != null) {
3193:                            sm.append("ORDER BY ");
3194:                            sm.append(obc.getOrderBy());
3195:                        }
3196:
3197:                        String sql = sm.toString();
3198:
3199:                        SQLQuery q = session.createSQLQuery(sql);
3200:
3201:                        q
3202:                                .addEntity(
3203:                                        "Permission_",
3204:                                        com.liferay.portal.model.impl.PermissionImpl.class);
3205:
3206:                        QueryPos qPos = QueryPos.getInstance(q);
3207:
3208:                        qPos.add(pk);
3209:
3210:                        List list = QueryUtil.list(q, getDialect(), begin, end);
3211:
3212:                        FinderCache.putResult(finderClassNameCacheEnabled,
3213:                                finderClassName, finderMethodName,
3214:                                finderParams, finderArgs, list);
3215:
3216:                        return list;
3217:                    } catch (Exception e) {
3218:                        throw new SystemException(e);
3219:                    } finally {
3220:                        closeSession(session);
3221:                    }
3222:                } else {
3223:                    return (List) result;
3224:                }
3225:            }
3226:
3227:            public int getPermissionsSize(long pk) throws SystemException {
3228:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_PERMISSIONS;
3229:                String finderClassName = "Users_Permissions";
3230:                String finderMethodName = "getPermissionsSize";
3231:                String[] finderParams = new String[] { Long.class.getName() };
3232:                Object[] finderArgs = new Object[] { new Long(pk) };
3233:
3234:                Object result = null;
3235:
3236:                if (finderClassNameCacheEnabled) {
3237:                    result = FinderCache.getResult(finderClassName,
3238:                            finderMethodName, finderParams, finderArgs,
3239:                            getSessionFactory());
3240:                }
3241:
3242:                if (result == null) {
3243:                    Session session = null;
3244:
3245:                    try {
3246:                        session = openSession();
3247:
3248:                        SQLQuery q = session
3249:                                .createSQLQuery(_SQL_GETPERMISSIONSSIZE);
3250:
3251:                        q.addScalar(HibernateUtil.getCountColumnName(),
3252:                                Hibernate.LONG);
3253:
3254:                        QueryPos qPos = QueryPos.getInstance(q);
3255:
3256:                        qPos.add(pk);
3257:
3258:                        Long count = null;
3259:
3260:                        Iterator itr = q.list().iterator();
3261:
3262:                        if (itr.hasNext()) {
3263:                            count = (Long) itr.next();
3264:                        }
3265:
3266:                        if (count == null) {
3267:                            count = new Long(0);
3268:                        }
3269:
3270:                        FinderCache.putResult(finderClassNameCacheEnabled,
3271:                                finderClassName, finderMethodName,
3272:                                finderParams, finderArgs, count);
3273:
3274:                        return count.intValue();
3275:                    } catch (Exception e) {
3276:                        throw HibernateUtil.processException(e);
3277:                    } finally {
3278:                        closeSession(session);
3279:                    }
3280:                } else {
3281:                    return ((Long) result).intValue();
3282:                }
3283:            }
3284:
3285:            public boolean containsPermission(long pk, long permissionPK)
3286:                    throws SystemException {
3287:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_PERMISSIONS;
3288:                String finderClassName = "Users_Permissions";
3289:                String finderMethodName = "containsPermissions";
3290:                String[] finderParams = new String[] { Long.class.getName(),
3291:
3292:                Long.class.getName() };
3293:                Object[] finderArgs = new Object[] { new Long(pk),
3294:                        new Long(permissionPK) };
3295:
3296:                Object result = null;
3297:
3298:                if (finderClassNameCacheEnabled) {
3299:                    result = FinderCache.getResult(finderClassName,
3300:                            finderMethodName, finderParams, finderArgs,
3301:                            getSessionFactory());
3302:                }
3303:
3304:                if (result == null) {
3305:                    try {
3306:                        Boolean value = Boolean.valueOf(containsPermission
3307:                                .contains(pk, permissionPK));
3308:
3309:                        FinderCache.putResult(finderClassNameCacheEnabled,
3310:                                finderClassName, finderMethodName,
3311:                                finderParams, finderArgs, value);
3312:
3313:                        return value.booleanValue();
3314:                    } catch (DataAccessException dae) {
3315:                        throw new SystemException(dae);
3316:                    }
3317:                } else {
3318:                    return ((Boolean) result).booleanValue();
3319:                }
3320:            }
3321:
3322:            public boolean containsPermissions(long pk) throws SystemException {
3323:                if (getPermissionsSize(pk) > 0) {
3324:                    return true;
3325:                } else {
3326:                    return false;
3327:                }
3328:            }
3329:
3330:            public void addPermission(long pk, long permissionPK)
3331:                    throws NoSuchUserException,
3332:                    com.liferay.portal.NoSuchPermissionException,
3333:                    SystemException {
3334:                try {
3335:                    addPermission.add(pk, permissionPK);
3336:                } catch (DataAccessException dae) {
3337:                    throw new SystemException(dae);
3338:                } finally {
3339:                    FinderCache.clearCache("Users_Permissions");
3340:                }
3341:            }
3342:
3343:            public void addPermission(long pk,
3344:                    com.liferay.portal.model.Permission permission)
3345:                    throws NoSuchUserException,
3346:                    com.liferay.portal.NoSuchPermissionException,
3347:                    SystemException {
3348:                try {
3349:                    addPermission.add(pk, permission.getPrimaryKey());
3350:                } catch (DataAccessException dae) {
3351:                    throw new SystemException(dae);
3352:                } finally {
3353:                    FinderCache.clearCache("Users_Permissions");
3354:                }
3355:            }
3356:
3357:            public void addPermissions(long pk, long[] permissionPKs)
3358:                    throws NoSuchUserException,
3359:                    com.liferay.portal.NoSuchPermissionException,
3360:                    SystemException {
3361:                try {
3362:                    for (int i = 0; i < permissionPKs.length; i++) {
3363:                        addPermission.add(pk, permissionPKs[i]);
3364:                    }
3365:                } catch (DataAccessException dae) {
3366:                    throw new SystemException(dae);
3367:                } finally {
3368:                    FinderCache.clearCache("Users_Permissions");
3369:                }
3370:            }
3371:
3372:            public void addPermissions(long pk, List permissions)
3373:                    throws NoSuchUserException,
3374:                    com.liferay.portal.NoSuchPermissionException,
3375:                    SystemException {
3376:                try {
3377:                    for (int i = 0; i < permissions.size(); i++) {
3378:                        com.liferay.portal.model.Permission permission = (com.liferay.portal.model.Permission) permissions
3379:                                .get(i);
3380:
3381:                        addPermission.add(pk, permission.getPrimaryKey());
3382:                    }
3383:                } catch (DataAccessException dae) {
3384:                    throw new SystemException(dae);
3385:                } finally {
3386:                    FinderCache.clearCache("Users_Permissions");
3387:                }
3388:            }
3389:
3390:            public void clearPermissions(long pk) throws NoSuchUserException,
3391:                    SystemException {
3392:                try {
3393:                    clearPermissions.clear(pk);
3394:                } catch (DataAccessException dae) {
3395:                    throw new SystemException(dae);
3396:                } finally {
3397:                    FinderCache.clearCache("Users_Permissions");
3398:                }
3399:            }
3400:
3401:            public void removePermission(long pk, long permissionPK)
3402:                    throws NoSuchUserException,
3403:                    com.liferay.portal.NoSuchPermissionException,
3404:                    SystemException {
3405:                try {
3406:                    removePermission.remove(pk, permissionPK);
3407:                } catch (DataAccessException dae) {
3408:                    throw new SystemException(dae);
3409:                } finally {
3410:                    FinderCache.clearCache("Users_Permissions");
3411:                }
3412:            }
3413:
3414:            public void removePermission(long pk,
3415:                    com.liferay.portal.model.Permission permission)
3416:                    throws NoSuchUserException,
3417:                    com.liferay.portal.NoSuchPermissionException,
3418:                    SystemException {
3419:                try {
3420:                    removePermission.remove(pk, permission.getPrimaryKey());
3421:                } catch (DataAccessException dae) {
3422:                    throw new SystemException(dae);
3423:                } finally {
3424:                    FinderCache.clearCache("Users_Permissions");
3425:                }
3426:            }
3427:
3428:            public void removePermissions(long pk, long[] permissionPKs)
3429:                    throws NoSuchUserException,
3430:                    com.liferay.portal.NoSuchPermissionException,
3431:                    SystemException {
3432:                try {
3433:                    for (int i = 0; i < permissionPKs.length; i++) {
3434:                        removePermission.remove(pk, permissionPKs[i]);
3435:                    }
3436:                } catch (DataAccessException dae) {
3437:                    throw new SystemException(dae);
3438:                } finally {
3439:                    FinderCache.clearCache("Users_Permissions");
3440:                }
3441:            }
3442:
3443:            public void removePermissions(long pk, List permissions)
3444:                    throws NoSuchUserException,
3445:                    com.liferay.portal.NoSuchPermissionException,
3446:                    SystemException {
3447:                try {
3448:                    for (int i = 0; i < permissions.size(); i++) {
3449:                        com.liferay.portal.model.Permission permission = (com.liferay.portal.model.Permission) permissions
3450:                                .get(i);
3451:
3452:                        removePermission.remove(pk, permission.getPrimaryKey());
3453:                    }
3454:                } catch (DataAccessException dae) {
3455:                    throw new SystemException(dae);
3456:                } finally {
3457:                    FinderCache.clearCache("Users_Permissions");
3458:                }
3459:            }
3460:
3461:            public void setPermissions(long pk, long[] permissionPKs)
3462:                    throws NoSuchUserException,
3463:                    com.liferay.portal.NoSuchPermissionException,
3464:                    SystemException {
3465:                try {
3466:                    clearPermissions.clear(pk);
3467:
3468:                    for (int i = 0; i < permissionPKs.length; i++) {
3469:                        addPermission.add(pk, permissionPKs[i]);
3470:                    }
3471:                } catch (DataAccessException dae) {
3472:                    throw new SystemException(dae);
3473:                } finally {
3474:                    FinderCache.clearCache("Users_Permissions");
3475:                }
3476:            }
3477:
3478:            public void setPermissions(long pk, List permissions)
3479:                    throws NoSuchUserException,
3480:                    com.liferay.portal.NoSuchPermissionException,
3481:                    SystemException {
3482:                try {
3483:                    clearPermissions.clear(pk);
3484:
3485:                    for (int i = 0; i < permissions.size(); i++) {
3486:                        com.liferay.portal.model.Permission permission = (com.liferay.portal.model.Permission) permissions
3487:                                .get(i);
3488:
3489:                        addPermission.add(pk, permission.getPrimaryKey());
3490:                    }
3491:                } catch (DataAccessException dae) {
3492:                    throw new SystemException(dae);
3493:                } finally {
3494:                    FinderCache.clearCache("Users_Permissions");
3495:                }
3496:            }
3497:
3498:            public List getRoles(long pk) throws NoSuchUserException,
3499:                    SystemException {
3500:                return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3501:            }
3502:
3503:            public List getRoles(long pk, int begin, int end)
3504:                    throws NoSuchUserException, SystemException {
3505:                return getRoles(pk, begin, end, null);
3506:            }
3507:
3508:            public List getRoles(long pk, int begin, int end,
3509:                    OrderByComparator obc) throws NoSuchUserException,
3510:                    SystemException {
3511:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_ROLES;
3512:                String finderClassName = "Users_Roles";
3513:                String finderMethodName = "getRoles";
3514:                String[] finderParams = new String[] { Long.class.getName(),
3515:                        "java.lang.Integer", "java.lang.Integer",
3516:                        "com.liferay.portal.kernel.util.OrderByComparator" };
3517:                Object[] finderArgs = new Object[] { new Long(pk),
3518:                        String.valueOf(begin), String.valueOf(end),
3519:                        String.valueOf(obc) };
3520:
3521:                Object result = null;
3522:
3523:                if (finderClassNameCacheEnabled) {
3524:                    result = FinderCache.getResult(finderClassName,
3525:                            finderMethodName, finderParams, finderArgs,
3526:                            getSessionFactory());
3527:                }
3528:
3529:                if (result == null) {
3530:                    Session session = null;
3531:
3532:                    try {
3533:                        session = HibernateUtil.openSession();
3534:
3535:                        StringMaker sm = new StringMaker();
3536:
3537:                        sm.append(_SQL_GETROLES);
3538:
3539:                        if (obc != null) {
3540:                            sm.append("ORDER BY ");
3541:                            sm.append(obc.getOrderBy());
3542:                        }
3543:
3544:                        else {
3545:                            sm.append("ORDER BY ");
3546:
3547:                            sm.append("Role_.name ASC");
3548:                        }
3549:
3550:                        String sql = sm.toString();
3551:
3552:                        SQLQuery q = session.createSQLQuery(sql);
3553:
3554:                        q.addEntity("Role_",
3555:                                com.liferay.portal.model.impl.RoleImpl.class);
3556:
3557:                        QueryPos qPos = QueryPos.getInstance(q);
3558:
3559:                        qPos.add(pk);
3560:
3561:                        List list = QueryUtil.list(q, getDialect(), begin, end);
3562:
3563:                        FinderCache.putResult(finderClassNameCacheEnabled,
3564:                                finderClassName, finderMethodName,
3565:                                finderParams, finderArgs, list);
3566:
3567:                        return list;
3568:                    } catch (Exception e) {
3569:                        throw new SystemException(e);
3570:                    } finally {
3571:                        closeSession(session);
3572:                    }
3573:                } else {
3574:                    return (List) result;
3575:                }
3576:            }
3577:
3578:            public int getRolesSize(long pk) throws SystemException {
3579:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_ROLES;
3580:                String finderClassName = "Users_Roles";
3581:                String finderMethodName = "getRolesSize";
3582:                String[] finderParams = new String[] { Long.class.getName() };
3583:                Object[] finderArgs = new Object[] { new Long(pk) };
3584:
3585:                Object result = null;
3586:
3587:                if (finderClassNameCacheEnabled) {
3588:                    result = FinderCache.getResult(finderClassName,
3589:                            finderMethodName, finderParams, finderArgs,
3590:                            getSessionFactory());
3591:                }
3592:
3593:                if (result == null) {
3594:                    Session session = null;
3595:
3596:                    try {
3597:                        session = openSession();
3598:
3599:                        SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
3600:
3601:                        q.addScalar(HibernateUtil.getCountColumnName(),
3602:                                Hibernate.LONG);
3603:
3604:                        QueryPos qPos = QueryPos.getInstance(q);
3605:
3606:                        qPos.add(pk);
3607:
3608:                        Long count = null;
3609:
3610:                        Iterator itr = q.list().iterator();
3611:
3612:                        if (itr.hasNext()) {
3613:                            count = (Long) itr.next();
3614:                        }
3615:
3616:                        if (count == null) {
3617:                            count = new Long(0);
3618:                        }
3619:
3620:                        FinderCache.putResult(finderClassNameCacheEnabled,
3621:                                finderClassName, finderMethodName,
3622:                                finderParams, finderArgs, count);
3623:
3624:                        return count.intValue();
3625:                    } catch (Exception e) {
3626:                        throw HibernateUtil.processException(e);
3627:                    } finally {
3628:                        closeSession(session);
3629:                    }
3630:                } else {
3631:                    return ((Long) result).intValue();
3632:                }
3633:            }
3634:
3635:            public boolean containsRole(long pk, long rolePK)
3636:                    throws SystemException {
3637:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_ROLES;
3638:                String finderClassName = "Users_Roles";
3639:                String finderMethodName = "containsRoles";
3640:                String[] finderParams = new String[] { Long.class.getName(),
3641:
3642:                Long.class.getName() };
3643:                Object[] finderArgs = new Object[] { new Long(pk),
3644:                        new Long(rolePK) };
3645:
3646:                Object result = null;
3647:
3648:                if (finderClassNameCacheEnabled) {
3649:                    result = FinderCache.getResult(finderClassName,
3650:                            finderMethodName, finderParams, finderArgs,
3651:                            getSessionFactory());
3652:                }
3653:
3654:                if (result == null) {
3655:                    try {
3656:                        Boolean value = Boolean.valueOf(containsRole.contains(
3657:                                pk, rolePK));
3658:
3659:                        FinderCache.putResult(finderClassNameCacheEnabled,
3660:                                finderClassName, finderMethodName,
3661:                                finderParams, finderArgs, value);
3662:
3663:                        return value.booleanValue();
3664:                    } catch (DataAccessException dae) {
3665:                        throw new SystemException(dae);
3666:                    }
3667:                } else {
3668:                    return ((Boolean) result).booleanValue();
3669:                }
3670:            }
3671:
3672:            public boolean containsRoles(long pk) throws SystemException {
3673:                if (getRolesSize(pk) > 0) {
3674:                    return true;
3675:                } else {
3676:                    return false;
3677:                }
3678:            }
3679:
3680:            public void addRole(long pk, long rolePK)
3681:                    throws NoSuchUserException,
3682:                    com.liferay.portal.NoSuchRoleException, SystemException {
3683:                try {
3684:                    addRole.add(pk, rolePK);
3685:                } catch (DataAccessException dae) {
3686:                    throw new SystemException(dae);
3687:                } finally {
3688:                    FinderCache.clearCache("Users_Roles");
3689:                }
3690:            }
3691:
3692:            public void addRole(long pk, com.liferay.portal.model.Role role)
3693:                    throws NoSuchUserException,
3694:                    com.liferay.portal.NoSuchRoleException, SystemException {
3695:                try {
3696:                    addRole.add(pk, role.getPrimaryKey());
3697:                } catch (DataAccessException dae) {
3698:                    throw new SystemException(dae);
3699:                } finally {
3700:                    FinderCache.clearCache("Users_Roles");
3701:                }
3702:            }
3703:
3704:            public void addRoles(long pk, long[] rolePKs)
3705:                    throws NoSuchUserException,
3706:                    com.liferay.portal.NoSuchRoleException, SystemException {
3707:                try {
3708:                    for (int i = 0; i < rolePKs.length; i++) {
3709:                        addRole.add(pk, rolePKs[i]);
3710:                    }
3711:                } catch (DataAccessException dae) {
3712:                    throw new SystemException(dae);
3713:                } finally {
3714:                    FinderCache.clearCache("Users_Roles");
3715:                }
3716:            }
3717:
3718:            public void addRoles(long pk, List roles)
3719:                    throws NoSuchUserException,
3720:                    com.liferay.portal.NoSuchRoleException, SystemException {
3721:                try {
3722:                    for (int i = 0; i < roles.size(); i++) {
3723:                        com.liferay.portal.model.Role role = (com.liferay.portal.model.Role) roles
3724:                                .get(i);
3725:
3726:                        addRole.add(pk, role.getPrimaryKey());
3727:                    }
3728:                } catch (DataAccessException dae) {
3729:                    throw new SystemException(dae);
3730:                } finally {
3731:                    FinderCache.clearCache("Users_Roles");
3732:                }
3733:            }
3734:
3735:            public void clearRoles(long pk) throws NoSuchUserException,
3736:                    SystemException {
3737:                try {
3738:                    clearRoles.clear(pk);
3739:                } catch (DataAccessException dae) {
3740:                    throw new SystemException(dae);
3741:                } finally {
3742:                    FinderCache.clearCache("Users_Roles");
3743:                }
3744:            }
3745:
3746:            public void removeRole(long pk, long rolePK)
3747:                    throws NoSuchUserException,
3748:                    com.liferay.portal.NoSuchRoleException, SystemException {
3749:                try {
3750:                    removeRole.remove(pk, rolePK);
3751:                } catch (DataAccessException dae) {
3752:                    throw new SystemException(dae);
3753:                } finally {
3754:                    FinderCache.clearCache("Users_Roles");
3755:                }
3756:            }
3757:
3758:            public void removeRole(long pk, com.liferay.portal.model.Role role)
3759:                    throws NoSuchUserException,
3760:                    com.liferay.portal.NoSuchRoleException, SystemException {
3761:                try {
3762:                    removeRole.remove(pk, role.getPrimaryKey());
3763:                } catch (DataAccessException dae) {
3764:                    throw new SystemException(dae);
3765:                } finally {
3766:                    FinderCache.clearCache("Users_Roles");
3767:                }
3768:            }
3769:
3770:            public void removeRoles(long pk, long[] rolePKs)
3771:                    throws NoSuchUserException,
3772:                    com.liferay.portal.NoSuchRoleException, SystemException {
3773:                try {
3774:                    for (int i = 0; i < rolePKs.length; i++) {
3775:                        removeRole.remove(pk, rolePKs[i]);
3776:                    }
3777:                } catch (DataAccessException dae) {
3778:                    throw new SystemException(dae);
3779:                } finally {
3780:                    FinderCache.clearCache("Users_Roles");
3781:                }
3782:            }
3783:
3784:            public void removeRoles(long pk, List roles)
3785:                    throws NoSuchUserException,
3786:                    com.liferay.portal.NoSuchRoleException, SystemException {
3787:                try {
3788:                    for (int i = 0; i < roles.size(); i++) {
3789:                        com.liferay.portal.model.Role role = (com.liferay.portal.model.Role) roles
3790:                                .get(i);
3791:
3792:                        removeRole.remove(pk, role.getPrimaryKey());
3793:                    }
3794:                } catch (DataAccessException dae) {
3795:                    throw new SystemException(dae);
3796:                } finally {
3797:                    FinderCache.clearCache("Users_Roles");
3798:                }
3799:            }
3800:
3801:            public void setRoles(long pk, long[] rolePKs)
3802:                    throws NoSuchUserException,
3803:                    com.liferay.portal.NoSuchRoleException, SystemException {
3804:                try {
3805:                    clearRoles.clear(pk);
3806:
3807:                    for (int i = 0; i < rolePKs.length; i++) {
3808:                        addRole.add(pk, rolePKs[i]);
3809:                    }
3810:                } catch (DataAccessException dae) {
3811:                    throw new SystemException(dae);
3812:                } finally {
3813:                    FinderCache.clearCache("Users_Roles");
3814:                }
3815:            }
3816:
3817:            public void setRoles(long pk, List roles)
3818:                    throws NoSuchUserException,
3819:                    com.liferay.portal.NoSuchRoleException, SystemException {
3820:                try {
3821:                    clearRoles.clear(pk);
3822:
3823:                    for (int i = 0; i < roles.size(); i++) {
3824:                        com.liferay.portal.model.Role role = (com.liferay.portal.model.Role) roles
3825:                                .get(i);
3826:
3827:                        addRole.add(pk, role.getPrimaryKey());
3828:                    }
3829:                } catch (DataAccessException dae) {
3830:                    throw new SystemException(dae);
3831:                } finally {
3832:                    FinderCache.clearCache("Users_Roles");
3833:                }
3834:            }
3835:
3836:            public List getUserGroups(long pk) throws NoSuchUserException,
3837:                    SystemException {
3838:                return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3839:            }
3840:
3841:            public List getUserGroups(long pk, int begin, int end)
3842:                    throws NoSuchUserException, SystemException {
3843:                return getUserGroups(pk, begin, end, null);
3844:            }
3845:
3846:            public List getUserGroups(long pk, int begin, int end,
3847:                    OrderByComparator obc) throws NoSuchUserException,
3848:                    SystemException {
3849:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
3850:                String finderClassName = "Users_UserGroups";
3851:                String finderMethodName = "getUserGroups";
3852:                String[] finderParams = new String[] { Long.class.getName(),
3853:                        "java.lang.Integer", "java.lang.Integer",
3854:                        "com.liferay.portal.kernel.util.OrderByComparator" };
3855:                Object[] finderArgs = new Object[] { new Long(pk),
3856:                        String.valueOf(begin), String.valueOf(end),
3857:                        String.valueOf(obc) };
3858:
3859:                Object result = null;
3860:
3861:                if (finderClassNameCacheEnabled) {
3862:                    result = FinderCache.getResult(finderClassName,
3863:                            finderMethodName, finderParams, finderArgs,
3864:                            getSessionFactory());
3865:                }
3866:
3867:                if (result == null) {
3868:                    Session session = null;
3869:
3870:                    try {
3871:                        session = HibernateUtil.openSession();
3872:
3873:                        StringMaker sm = new StringMaker();
3874:
3875:                        sm.append(_SQL_GETUSERGROUPS);
3876:
3877:                        if (obc != null) {
3878:                            sm.append("ORDER BY ");
3879:                            sm.append(obc.getOrderBy());
3880:                        }
3881:
3882:                        else {
3883:                            sm.append("ORDER BY ");
3884:
3885:                            sm.append("UserGroup.name ASC");
3886:                        }
3887:
3888:                        String sql = sm.toString();
3889:
3890:                        SQLQuery q = session.createSQLQuery(sql);
3891:
3892:                        q
3893:                                .addEntity(
3894:                                        "UserGroup",
3895:                                        com.liferay.portal.model.impl.UserGroupImpl.class);
3896:
3897:                        QueryPos qPos = QueryPos.getInstance(q);
3898:
3899:                        qPos.add(pk);
3900:
3901:                        List list = QueryUtil.list(q, getDialect(), begin, end);
3902:
3903:                        FinderCache.putResult(finderClassNameCacheEnabled,
3904:                                finderClassName, finderMethodName,
3905:                                finderParams, finderArgs, list);
3906:
3907:                        return list;
3908:                    } catch (Exception e) {
3909:                        throw new SystemException(e);
3910:                    } finally {
3911:                        closeSession(session);
3912:                    }
3913:                } else {
3914:                    return (List) result;
3915:                }
3916:            }
3917:
3918:            public int getUserGroupsSize(long pk) throws SystemException {
3919:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
3920:                String finderClassName = "Users_UserGroups";
3921:                String finderMethodName = "getUserGroupsSize";
3922:                String[] finderParams = new String[] { Long.class.getName() };
3923:                Object[] finderArgs = new Object[] { new Long(pk) };
3924:
3925:                Object result = null;
3926:
3927:                if (finderClassNameCacheEnabled) {
3928:                    result = FinderCache.getResult(finderClassName,
3929:                            finderMethodName, finderParams, finderArgs,
3930:                            getSessionFactory());
3931:                }
3932:
3933:                if (result == null) {
3934:                    Session session = null;
3935:
3936:                    try {
3937:                        session = openSession();
3938:
3939:                        SQLQuery q = session
3940:                                .createSQLQuery(_SQL_GETUSERGROUPSSIZE);
3941:
3942:                        q.addScalar(HibernateUtil.getCountColumnName(),
3943:                                Hibernate.LONG);
3944:
3945:                        QueryPos qPos = QueryPos.getInstance(q);
3946:
3947:                        qPos.add(pk);
3948:
3949:                        Long count = null;
3950:
3951:                        Iterator itr = q.list().iterator();
3952:
3953:                        if (itr.hasNext()) {
3954:                            count = (Long) itr.next();
3955:                        }
3956:
3957:                        if (count == null) {
3958:                            count = new Long(0);
3959:                        }
3960:
3961:                        FinderCache.putResult(finderClassNameCacheEnabled,
3962:                                finderClassName, finderMethodName,
3963:                                finderParams, finderArgs, count);
3964:
3965:                        return count.intValue();
3966:                    } catch (Exception e) {
3967:                        throw HibernateUtil.processException(e);
3968:                    } finally {
3969:                        closeSession(session);
3970:                    }
3971:                } else {
3972:                    return ((Long) result).intValue();
3973:                }
3974:            }
3975:
3976:            public boolean containsUserGroup(long pk, long userGroupPK)
3977:                    throws SystemException {
3978:                boolean finderClassNameCacheEnabled = UserModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
3979:                String finderClassName = "Users_UserGroups";
3980:                String finderMethodName = "containsUserGroups";
3981:                String[] finderParams = new String[] { Long.class.getName(),
3982:
3983:                Long.class.getName() };
3984:                Object[] finderArgs = new Object[] { new Long(pk),
3985:                        new Long(userGroupPK) };
3986:
3987:                Object result = null;
3988:
3989:                if (finderClassNameCacheEnabled) {
3990:                    result = FinderCache.getResult(finderClassName,
3991:                            finderMethodName, finderParams, finderArgs,
3992:                            getSessionFactory());
3993:                }
3994:
3995:                if (result == null) {
3996:                    try {
3997:                        Boolean value = Boolean.valueOf(containsUserGroup
3998:                                .contains(pk, userGroupPK));
3999:
4000:                        FinderCache.putResult(finderClassNameCacheEnabled,
4001:                                finderClassName, finderMethodName,
4002:                                finderParams, finderArgs, value);
4003:
4004:                        return value.booleanValue();
4005:                    } catch (DataAccessException dae) {
4006:                        throw new SystemException(dae);
4007:                    }
4008:                } else {
4009:                    return ((Boolean) result).booleanValue();
4010:                }
4011:            }
4012:
4013:            public boolean containsUserGroups(long pk) throws SystemException {
4014:                if (getUserGroupsSize(pk) > 0) {
4015:                    return true;
4016:                } else {
4017:                    return false;
4018:                }
4019:            }
4020:
4021:            public void addUserGroup(long pk, long userGroupPK)
4022:                    throws NoSuchUserException,
4023:                    com.liferay.portal.NoSuchUserGroupException,
4024:                    SystemException {
4025:                try {
4026:                    addUserGroup.add(pk, userGroupPK);
4027:                } catch (DataAccessException dae) {
4028:                    throw new SystemException(dae);
4029:                } finally {
4030:                    FinderCache.clearCache("Users_UserGroups");
4031:                }
4032:            }
4033:
4034:            public void addUserGroup(long pk,
4035:                    com.liferay.portal.model.UserGroup userGroup)
4036:                    throws NoSuchUserException,
4037:                    com.liferay.portal.NoSuchUserGroupException,
4038:                    SystemException {
4039:                try {
4040:                    addUserGroup.add(pk, userGroup.getPrimaryKey());
4041:                } catch (DataAccessException dae) {
4042:                    throw new SystemException(dae);
4043:                } finally {
4044:                    FinderCache.clearCache("Users_UserGroups");
4045:                }
4046:            }
4047:
4048:            public void addUserGroups(long pk, long[] userGroupPKs)
4049:                    throws NoSuchUserException,
4050:                    com.liferay.portal.NoSuchUserGroupException,
4051:                    SystemException {
4052:                try {
4053:                    for (int i = 0; i < userGroupPKs.length; i++) {
4054:                        addUserGroup.add(pk, userGroupPKs[i]);
4055:                    }
4056:                } catch (DataAccessException dae) {
4057:                    throw new SystemException(dae);
4058:                } finally {
4059:                    FinderCache.clearCache("Users_UserGroups");
4060:                }
4061:            }
4062:
4063:            public void addUserGroups(long pk, List userGroups)
4064:                    throws NoSuchUserException,
4065:                    com.liferay.portal.NoSuchUserGroupException,
4066:                    SystemException {
4067:                try {
4068:                    for (int i = 0; i < userGroups.size(); i++) {
4069:                        com.liferay.portal.model.UserGroup userGroup = (com.liferay.portal.model.UserGroup) userGroups
4070:                                .get(i);
4071:
4072:                        addUserGroup.add(pk, userGroup.getPrimaryKey());
4073:                    }
4074:                } catch (DataAccessException dae) {
4075:                    throw new SystemException(dae);
4076:                } finally {
4077:                    FinderCache.clearCache("Users_UserGroups");
4078:                }
4079:            }
4080:
4081:            public void clearUserGroups(long pk) throws NoSuchUserException,
4082:                    SystemException {
4083:                try {
4084:                    clearUserGroups.clear(pk);
4085:                } catch (DataAccessException dae) {
4086:                    throw new SystemException(dae);
4087:                } finally {
4088:                    FinderCache.clearCache("Users_UserGroups");
4089:                }
4090:            }
4091:
4092:            public void removeUserGroup(long pk, long userGroupPK)
4093:                    throws NoSuchUserException,
4094:                    com.liferay.portal.NoSuchUserGroupException,
4095:                    SystemException {
4096:                try {
4097:                    removeUserGroup.remove(pk, userGroupPK);
4098:                } catch (DataAccessException dae) {
4099:                    throw new SystemException(dae);
4100:                } finally {
4101:                    FinderCache.clearCache("Users_UserGroups");
4102:                }
4103:            }
4104:
4105:            public void removeUserGroup(long pk,
4106:                    com.liferay.portal.model.UserGroup userGroup)
4107:                    throws NoSuchUserException,
4108:                    com.liferay.portal.NoSuchUserGroupException,
4109:                    SystemException {
4110:                try {
4111:                    removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4112:                } catch (DataAccessException dae) {
4113:                    throw new SystemException(dae);
4114:                } finally {
4115:                    FinderCache.clearCache("Users_UserGroups");
4116:                }
4117:            }
4118:
4119:            public void removeUserGroups(long pk, long[] userGroupPKs)
4120:                    throws NoSuchUserException,
4121:                    com.liferay.portal.NoSuchUserGroupException,
4122:                    SystemException {
4123:                try {
4124:                    for (int i = 0; i < userGroupPKs.length; i++) {
4125:                        removeUserGroup.remove(pk, userGroupPKs[i]);
4126:                    }
4127:                } catch (DataAccessException dae) {
4128:                    throw new SystemException(dae);
4129:                } finally {
4130:                    FinderCache.clearCache("Users_UserGroups");
4131:                }
4132:            }
4133:
4134:            public void removeUserGroups(long pk, List userGroups)
4135:                    throws NoSuchUserException,
4136:                    com.liferay.portal.NoSuchUserGroupException,
4137:                    SystemException {
4138:                try {
4139:                    for (int i = 0; i < userGroups.size(); i++) {
4140:                        com.liferay.portal.model.UserGroup userGroup = (com.liferay.portal.model.UserGroup) userGroups
4141:                                .get(i);
4142:
4143:                        removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4144:                    }
4145:                } catch (DataAccessException dae) {
4146:                    throw new SystemException(dae);
4147:                } finally {
4148:                    FinderCache.clearCache("Users_UserGroups");
4149:                }
4150:            }
4151:
4152:            public void setUserGroups(long pk, long[] userGroupPKs)
4153:                    throws NoSuchUserException,
4154:                    com.liferay.portal.NoSuchUserGroupException,
4155:                    SystemException {
4156:                try {
4157:                    clearUserGroups.clear(pk);
4158:
4159:                    for (int i = 0; i < userGroupPKs.length; i++) {
4160:                        addUserGroup.add(pk, userGroupPKs[i]);
4161:                    }
4162:                } catch (DataAccessException dae) {
4163:                    throw new SystemException(dae);
4164:                } finally {
4165:                    FinderCache.clearCache("Users_UserGroups");
4166:                }
4167:            }
4168:
4169:            public void setUserGroups(long pk, List userGroups)
4170:                    throws NoSuchUserException,
4171:                    com.liferay.portal.NoSuchUserGroupException,
4172:                    SystemException {
4173:                try {
4174:                    clearUserGroups.clear(pk);
4175:
4176:                    for (int i = 0; i < userGroups.size(); i++) {
4177:                        com.liferay.portal.model.UserGroup userGroup = (com.liferay.portal.model.UserGroup) userGroups
4178:                                .get(i);
4179:
4180:                        addUserGroup.add(pk, userGroup.getPrimaryKey());
4181:                    }
4182:                } catch (DataAccessException dae) {
4183:                    throw new SystemException(dae);
4184:                } finally {
4185:                    FinderCache.clearCache("Users_UserGroups");
4186:                }
4187:            }
4188:
4189:            protected void initDao() {
4190:                containsGroup = new ContainsGroup(this );
4191:
4192:                addGroup = new AddGroup(this );
4193:                clearGroups = new ClearGroups(this );
4194:                removeGroup = new RemoveGroup(this );
4195:
4196:                containsOrganization = new ContainsOrganization(this );
4197:
4198:                addOrganization = new AddOrganization(this );
4199:                clearOrganizations = new ClearOrganizations(this );
4200:                removeOrganization = new RemoveOrganization(this );
4201:
4202:                containsPermission = new ContainsPermission(this );
4203:
4204:                addPermission = new AddPermission(this );
4205:                clearPermissions = new ClearPermissions(this );
4206:                removePermission = new RemovePermission(this );
4207:
4208:                containsRole = new ContainsRole(this );
4209:
4210:                addRole = new AddRole(this );
4211:                clearRoles = new ClearRoles(this );
4212:                removeRole = new RemoveRole(this );
4213:
4214:                containsUserGroup = new ContainsUserGroup(this );
4215:
4216:                addUserGroup = new AddUserGroup(this );
4217:                clearUserGroups = new ClearUserGroups(this );
4218:                removeUserGroup = new RemoveUserGroup(this );
4219:            }
4220:
4221:            protected ContainsGroup containsGroup;
4222:            protected AddGroup addGroup;
4223:            protected ClearGroups clearGroups;
4224:            protected RemoveGroup removeGroup;
4225:            protected ContainsOrganization containsOrganization;
4226:            protected AddOrganization addOrganization;
4227:            protected ClearOrganizations clearOrganizations;
4228:            protected RemoveOrganization removeOrganization;
4229:            protected ContainsPermission containsPermission;
4230:            protected AddPermission addPermission;
4231:            protected ClearPermissions clearPermissions;
4232:            protected RemovePermission removePermission;
4233:            protected ContainsRole containsRole;
4234:            protected AddRole addRole;
4235:            protected ClearRoles clearRoles;
4236:            protected RemoveRole removeRole;
4237:            protected ContainsUserGroup containsUserGroup;
4238:            protected AddUserGroup addUserGroup;
4239:            protected ClearUserGroups clearUserGroups;
4240:            protected RemoveUserGroup removeUserGroup;
4241:
4242:            protected class ContainsGroup extends MappingSqlQuery {
4243:                protected ContainsGroup(UserPersistenceImpl persistenceImpl) {
4244:                    super (persistenceImpl.getDataSource(), _SQL_CONTAINSGROUP);
4245:
4246:                    declareParameter(new SqlParameter(Types.BIGINT));
4247:                    declareParameter(new SqlParameter(Types.BIGINT));
4248:
4249:                    compile();
4250:                }
4251:
4252:                protected Object mapRow(ResultSet rs, int rowNumber)
4253:                        throws SQLException {
4254:                    return new Integer(rs.getInt("COUNT_VALUE"));
4255:                }
4256:
4257:                protected boolean contains(long userId, long groupId) {
4258:                    List results = execute(new Object[] { new Long(userId),
4259:                            new Long(groupId) });
4260:
4261:                    if (results.size() > 0) {
4262:                        Integer count = (Integer) results.get(0);
4263:
4264:                        if (count.intValue() > 0) {
4265:                            return true;
4266:                        }
4267:                    }
4268:
4269:                    return false;
4270:                }
4271:            }
4272:
4273:            protected class AddGroup extends SqlUpdate {
4274:                protected AddGroup(UserPersistenceImpl persistenceImpl) {
4275:                    super (persistenceImpl.getDataSource(),
4276:                            "INSERT INTO Users_Groups (userId, groupId) VALUES (?, ?)");
4277:
4278:                    _persistenceImpl = persistenceImpl;
4279:
4280:                    declareParameter(new SqlParameter(Types.BIGINT));
4281:                    declareParameter(new SqlParameter(Types.BIGINT));
4282:
4283:                    compile();
4284:                }
4285:
4286:                protected void add(long userId, long groupId) {
4287:                    if (!_persistenceImpl.containsGroup.contains(userId,
4288:                            groupId)) {
4289:                        update(new Object[] { new Long(userId),
4290:                                new Long(groupId) });
4291:                    }
4292:                }
4293:
4294:                private UserPersistenceImpl _persistenceImpl;
4295:            }
4296:
4297:            protected class ClearGroups extends SqlUpdate {
4298:                protected ClearGroups(UserPersistenceImpl persistenceImpl) {
4299:                    super (persistenceImpl.getDataSource(),
4300:                            "DELETE FROM Users_Groups WHERE userId = ?");
4301:
4302:                    declareParameter(new SqlParameter(Types.BIGINT));
4303:
4304:                    compile();
4305:                }
4306:
4307:                protected void clear(long userId) {
4308:                    update(new Object[] { new Long(userId) });
4309:                }
4310:            }
4311:
4312:            protected class RemoveGroup extends SqlUpdate {
4313:                protected RemoveGroup(UserPersistenceImpl persistenceImpl) {
4314:                    super (persistenceImpl.getDataSource(),
4315:                            "DELETE FROM Users_Groups WHERE userId = ? AND groupId = ?");
4316:
4317:                    declareParameter(new SqlParameter(Types.BIGINT));
4318:                    declareParameter(new SqlParameter(Types.BIGINT));
4319:
4320:                    compile();
4321:                }
4322:
4323:                protected void remove(long userId, long groupId) {
4324:                    update(new Object[] { new Long(userId), new Long(groupId) });
4325:                }
4326:            }
4327:
4328:            protected class ContainsOrganization extends MappingSqlQuery {
4329:                protected ContainsOrganization(
4330:                        UserPersistenceImpl persistenceImpl) {
4331:                    super (persistenceImpl.getDataSource(),
4332:                            _SQL_CONTAINSORGANIZATION);
4333:
4334:                    declareParameter(new SqlParameter(Types.BIGINT));
4335:                    declareParameter(new SqlParameter(Types.BIGINT));
4336:
4337:                    compile();
4338:                }
4339:
4340:                protected Object mapRow(ResultSet rs, int rowNumber)
4341:                        throws SQLException {
4342:                    return new Integer(rs.getInt("COUNT_VALUE"));
4343:                }
4344:
4345:                protected boolean contains(long userId, long organizationId) {
4346:                    List results = execute(new Object[] { new Long(userId),
4347:                            new Long(organizationId) });
4348:
4349:                    if (results.size() > 0) {
4350:                        Integer count = (Integer) results.get(0);
4351:
4352:                        if (count.intValue() > 0) {
4353:                            return true;
4354:                        }
4355:                    }
4356:
4357:                    return false;
4358:                }
4359:            }
4360:
4361:            protected class AddOrganization extends SqlUpdate {
4362:                protected AddOrganization(UserPersistenceImpl persistenceImpl) {
4363:                    super (persistenceImpl.getDataSource(),
4364:                            "INSERT INTO Users_Orgs (userId, organizationId) VALUES (?, ?)");
4365:
4366:                    _persistenceImpl = persistenceImpl;
4367:
4368:                    declareParameter(new SqlParameter(Types.BIGINT));
4369:                    declareParameter(new SqlParameter(Types.BIGINT));
4370:
4371:                    compile();
4372:                }
4373:
4374:                protected void add(long userId, long organizationId) {
4375:                    if (!_persistenceImpl.containsOrganization.contains(userId,
4376:                            organizationId)) {
4377:                        update(new Object[] { new Long(userId),
4378:                                new Long(organizationId) });
4379:                    }
4380:                }
4381:
4382:                private UserPersistenceImpl _persistenceImpl;
4383:            }
4384:
4385:            protected class ClearOrganizations extends SqlUpdate {
4386:                protected ClearOrganizations(UserPersistenceImpl persistenceImpl) {
4387:                    super (persistenceImpl.getDataSource(),
4388:                            "DELETE FROM Users_Orgs WHERE userId = ?");
4389:
4390:                    declareParameter(new SqlParameter(Types.BIGINT));
4391:
4392:                    compile();
4393:                }
4394:
4395:                protected void clear(long userId) {
4396:                    update(new Object[] { new Long(userId) });
4397:                }
4398:            }
4399:
4400:            protected class RemoveOrganization extends SqlUpdate {
4401:                protected RemoveOrganization(UserPersistenceImpl persistenceImpl) {
4402:                    super (persistenceImpl.getDataSource(),
4403:                            "DELETE FROM Users_Orgs WHERE userId = ? AND organizationId = ?");
4404:
4405:                    declareParameter(new SqlParameter(Types.BIGINT));
4406:                    declareParameter(new SqlParameter(Types.BIGINT));
4407:
4408:                    compile();
4409:                }
4410:
4411:                protected void remove(long userId, long organizationId) {
4412:                    update(new Object[] { new Long(userId),
4413:                            new Long(organizationId) });
4414:                }
4415:            }
4416:
4417:            protected class ContainsPermission extends MappingSqlQuery {
4418:                protected ContainsPermission(UserPersistenceImpl persistenceImpl) {
4419:                    super (persistenceImpl.getDataSource(),
4420:                            _SQL_CONTAINSPERMISSION);
4421:
4422:                    declareParameter(new SqlParameter(Types.BIGINT));
4423:                    declareParameter(new SqlParameter(Types.BIGINT));
4424:
4425:                    compile();
4426:                }
4427:
4428:                protected Object mapRow(ResultSet rs, int rowNumber)
4429:                        throws SQLException {
4430:                    return new Integer(rs.getInt("COUNT_VALUE"));
4431:                }
4432:
4433:                protected boolean contains(long userId, long permissionId) {
4434:                    List results = execute(new Object[] { new Long(userId),
4435:                            new Long(permissionId) });
4436:
4437:                    if (results.size() > 0) {
4438:                        Integer count = (Integer) results.get(0);
4439:
4440:                        if (count.intValue() > 0) {
4441:                            return true;
4442:                        }
4443:                    }
4444:
4445:                    return false;
4446:                }
4447:            }
4448:
4449:            protected class AddPermission extends SqlUpdate {
4450:                protected AddPermission(UserPersistenceImpl persistenceImpl) {
4451:                    super (persistenceImpl.getDataSource(),
4452:                            "INSERT INTO Users_Permissions (userId, permissionId) VALUES (?, ?)");
4453:
4454:                    _persistenceImpl = persistenceImpl;
4455:
4456:                    declareParameter(new SqlParameter(Types.BIGINT));
4457:                    declareParameter(new SqlParameter(Types.BIGINT));
4458:
4459:                    compile();
4460:                }
4461:
4462:                protected void add(long userId, long permissionId) {
4463:                    if (!_persistenceImpl.containsPermission.contains(userId,
4464:                            permissionId)) {
4465:                        update(new Object[] { new Long(userId),
4466:                                new Long(permissionId) });
4467:                    }
4468:                }
4469:
4470:                private UserPersistenceImpl _persistenceImpl;
4471:            }
4472:
4473:            protected class ClearPermissions extends SqlUpdate {
4474:                protected ClearPermissions(UserPersistenceImpl persistenceImpl) {
4475:                    super (persistenceImpl.getDataSource(),
4476:                            "DELETE FROM Users_Permissions WHERE userId = ?");
4477:
4478:                    declareParameter(new SqlParameter(Types.BIGINT));
4479:
4480:                    compile();
4481:                }
4482:
4483:                protected void clear(long userId) {
4484:                    update(new Object[] { new Long(userId) });
4485:                }
4486:            }
4487:
4488:            protected class RemovePermission extends SqlUpdate {
4489:                protected RemovePermission(UserPersistenceImpl persistenceImpl) {
4490:                    super (persistenceImpl.getDataSource(),
4491:                            "DELETE FROM Users_Permissions WHERE userId = ? AND permissionId = ?");
4492:
4493:                    declareParameter(new SqlParameter(Types.BIGINT));
4494:                    declareParameter(new SqlParameter(Types.BIGINT));
4495:
4496:                    compile();
4497:                }
4498:
4499:                protected void remove(long userId, long permissionId) {
4500:                    update(new Object[] { new Long(userId),
4501:                            new Long(permissionId) });
4502:                }
4503:            }
4504:
4505:            protected class ContainsRole extends MappingSqlQuery {
4506:                protected ContainsRole(UserPersistenceImpl persistenceImpl) {
4507:                    super (persistenceImpl.getDataSource(), _SQL_CONTAINSROLE);
4508:
4509:                    declareParameter(new SqlParameter(Types.BIGINT));
4510:                    declareParameter(new SqlParameter(Types.BIGINT));
4511:
4512:                    compile();
4513:                }
4514:
4515:                protected Object mapRow(ResultSet rs, int rowNumber)
4516:                        throws SQLException {
4517:                    return new Integer(rs.getInt("COUNT_VALUE"));
4518:                }
4519:
4520:                protected boolean contains(long userId, long roleId) {
4521:                    List results = execute(new Object[] { new Long(userId),
4522:                            new Long(roleId) });
4523:
4524:                    if (results.size() > 0) {
4525:                        Integer count = (Integer) results.get(0);
4526:
4527:                        if (count.intValue() > 0) {
4528:                            return true;
4529:                        }
4530:                    }
4531:
4532:                    return false;
4533:                }
4534:            }
4535:
4536:            protected class AddRole extends SqlUpdate {
4537:                protected AddRole(UserPersistenceImpl persistenceImpl) {
4538:                    super (persistenceImpl.getDataSource(),
4539:                            "INSERT INTO Users_Roles (userId, roleId) VALUES (?, ?)");
4540:
4541:                    _persistenceImpl = persistenceImpl;
4542:
4543:                    declareParameter(new SqlParameter(Types.BIGINT));
4544:                    declareParameter(new SqlParameter(Types.BIGINT));
4545:
4546:                    compile();
4547:                }
4548:
4549:                protected void add(long userId, long roleId) {
4550:                    if (!_persistenceImpl.containsRole.contains(userId, roleId)) {
4551:                        update(new Object[] { new Long(userId),
4552:                                new Long(roleId) });
4553:                    }
4554:                }
4555:
4556:                private UserPersistenceImpl _persistenceImpl;
4557:            }
4558:
4559:            protected class ClearRoles extends SqlUpdate {
4560:                protected ClearRoles(UserPersistenceImpl persistenceImpl) {
4561:                    super (persistenceImpl.getDataSource(),
4562:                            "DELETE FROM Users_Roles WHERE userId = ?");
4563:
4564:                    declareParameter(new SqlParameter(Types.BIGINT));
4565:
4566:                    compile();
4567:                }
4568:
4569:                protected void clear(long userId) {
4570:                    update(new Object[] { new Long(userId) });
4571:                }
4572:            }
4573:
4574:            protected class RemoveRole extends SqlUpdate {
4575:                protected RemoveRole(UserPersistenceImpl persistenceImpl) {
4576:                    super (persistenceImpl.getDataSource(),
4577:                            "DELETE FROM Users_Roles WHERE userId = ? AND roleId = ?");
4578:
4579:                    declareParameter(new SqlParameter(Types.BIGINT));
4580:                    declareParameter(new SqlParameter(Types.BIGINT));
4581:
4582:                    compile();
4583:                }
4584:
4585:                protected void remove(long userId, long roleId) {
4586:                    update(new Object[] { new Long(userId), new Long(roleId) });
4587:                }
4588:            }
4589:
4590:            protected class ContainsUserGroup extends MappingSqlQuery {
4591:                protected ContainsUserGroup(UserPersistenceImpl persistenceImpl) {
4592:                    super (persistenceImpl.getDataSource(),
4593:                            _SQL_CONTAINSUSERGROUP);
4594:
4595:                    declareParameter(new SqlParameter(Types.BIGINT));
4596:                    declareParameter(new SqlParameter(Types.BIGINT));
4597:
4598:                    compile();
4599:                }
4600:
4601:                protected Object mapRow(ResultSet rs, int rowNumber)
4602:                        throws SQLException {
4603:                    return new Integer(rs.getInt("COUNT_VALUE"));
4604:                }
4605:
4606:                protected boolean contains(long userId, long userGroupId) {
4607:                    List results = execute(new Object[] { new Long(userId),
4608:                            new Long(userGroupId) });
4609:
4610:                    if (results.size() > 0) {
4611:                        Integer count = (Integer) results.get(0);
4612:
4613:                        if (count.intValue() > 0) {
4614:                            return true;
4615:                        }
4616:                    }
4617:
4618:                    return false;
4619:                }
4620:            }
4621:
4622:            protected class AddUserGroup extends SqlUpdate {
4623:                protected AddUserGroup(UserPersistenceImpl persistenceImpl) {
4624:                    super (persistenceImpl.getDataSource(),
4625:                            "INSERT INTO Users_UserGroups (userId, userGroupId) VALUES (?, ?)");
4626:
4627:                    _persistenceImpl = persistenceImpl;
4628:
4629:                    declareParameter(new SqlParameter(Types.BIGINT));
4630:                    declareParameter(new SqlParameter(Types.BIGINT));
4631:
4632:                    compile();
4633:                }
4634:
4635:                protected void add(long userId, long userGroupId) {
4636:                    if (!_persistenceImpl.containsUserGroup.contains(userId,
4637:                            userGroupId)) {
4638:                        update(new Object[] { new Long(userId),
4639:                                new Long(userGroupId) });
4640:                    }
4641:                }
4642:
4643:                private UserPersistenceImpl _persistenceImpl;
4644:            }
4645:
4646:            protected class ClearUserGroups extends SqlUpdate {
4647:                protected ClearUserGroups(UserPersistenceImpl persistenceImpl) {
4648:                    super (persistenceImpl.getDataSource(),
4649:                            "DELETE FROM Users_UserGroups WHERE userId = ?");
4650:
4651:                    declareParameter(new SqlParameter(Types.BIGINT));
4652:
4653:                    compile();
4654:                }
4655:
4656:                protected void clear(long userId) {
4657:                    update(new Object[] { new Long(userId) });
4658:                }
4659:            }
4660:
4661:            protected class RemoveUserGroup extends SqlUpdate {
4662:                protected RemoveUserGroup(UserPersistenceImpl persistenceImpl) {
4663:                    super (persistenceImpl.getDataSource(),
4664:                            "DELETE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?");
4665:
4666:                    declareParameter(new SqlParameter(Types.BIGINT));
4667:                    declareParameter(new SqlParameter(Types.BIGINT));
4668:
4669:                    compile();
4670:                }
4671:
4672:                protected void remove(long userId, long userGroupId) {
4673:                    update(new Object[] { new Long(userId),
4674:                            new Long(userGroupId) });
4675:                }
4676:            }
4677:
4678:            private static ModelListener _getListener() {
4679:                if (Validator.isNotNull(_LISTENER)) {
4680:                    try {
4681:                        return (ModelListener) Class.forName(_LISTENER)
4682:                                .newInstance();
4683:                    } catch (Exception e) {
4684:                        _log.error(e);
4685:                    }
4686:                }
4687:
4688:                return null;
4689:            }
4690:
4691:            private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Users_Groups.userId = ?)";
4692:            private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ?";
4693:            private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ? AND groupId = ?";
4694:            private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Organization_.organizationId) WHERE (Users_Orgs.userId = ?)";
4695:            private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ?";
4696:            private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ? AND organizationId = ?";
4697:            private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Users_Permissions ON (Users_Permissions.permissionId = Permission_.permissionId) WHERE (Users_Permissions.userId = ?)";
4698:            private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ?";
4699:            private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ? AND permissionId = ?";
4700:            private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Users_Roles ON (Users_Roles.roleId = Role_.roleId) WHERE (Users_Roles.userId = ?)";
4701:            private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ?";
4702:            private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ? AND roleId = ?";
4703:            private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Users_UserGroups.userId = ?)";
4704:            private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ?";
4705:            private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?";
4706:            private static final String _LISTENER = GetterUtil
4707:                    .getString(PropsUtil
4708:                            .get("value.object.listener.com.liferay.portal.model.User"));
4709:            private static Log _log = LogFactory
4710:                    .getLog(UserPersistenceImpl.class);
4711:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.