Source Code Cross Referenced for MBStatsUserPersistenceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portlet » messageboards » 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.portlet.messageboards.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.portlet.messageboards.service.persistence;
0022:
0023:        import com.liferay.portal.SystemException;
0024:        import com.liferay.portal.kernel.dao.DynamicQuery;
0025:        import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
0026:        import com.liferay.portal.kernel.util.GetterUtil;
0027:        import com.liferay.portal.kernel.util.OrderByComparator;
0028:        import com.liferay.portal.kernel.util.StringMaker;
0029:        import com.liferay.portal.kernel.util.StringPool;
0030:        import com.liferay.portal.kernel.util.Validator;
0031:        import com.liferay.portal.model.ModelListener;
0032:        import com.liferay.portal.service.persistence.BasePersistence;
0033:        import com.liferay.portal.spring.hibernate.FinderCache;
0034:        import com.liferay.portal.spring.hibernate.HibernateUtil;
0035:        import com.liferay.portal.util.PropsUtil;
0036:
0037:        import com.liferay.portlet.messageboards.NoSuchStatsUserException;
0038:        import com.liferay.portlet.messageboards.model.MBStatsUser;
0039:        import com.liferay.portlet.messageboards.model.impl.MBStatsUserImpl;
0040:        import com.liferay.portlet.messageboards.model.impl.MBStatsUserModelImpl;
0041:
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.Query;
0048:        import org.hibernate.Session;
0049:
0050:        import java.util.Collections;
0051:        import java.util.Iterator;
0052:        import java.util.List;
0053:
0054:        /**
0055:         * <a href="MBStatsUserPersistenceImpl.java.html"><b><i>View Source</i></b></a>
0056:         *
0057:         * @author Brian Wing Shun Chan
0058:         *
0059:         */
0060:        public class MBStatsUserPersistenceImpl extends BasePersistence
0061:                implements  MBStatsUserPersistence {
0062:            public MBStatsUser create(long statsUserId) {
0063:                MBStatsUser mbStatsUser = new MBStatsUserImpl();
0064:
0065:                mbStatsUser.setNew(true);
0066:                mbStatsUser.setPrimaryKey(statsUserId);
0067:
0068:                return mbStatsUser;
0069:            }
0070:
0071:            public MBStatsUser remove(long statsUserId)
0072:                    throws NoSuchStatsUserException, SystemException {
0073:                Session session = null;
0074:
0075:                try {
0076:                    session = openSession();
0077:
0078:                    MBStatsUser mbStatsUser = (MBStatsUser) session.get(
0079:                            MBStatsUserImpl.class, new Long(statsUserId));
0080:
0081:                    if (mbStatsUser == null) {
0082:                        if (_log.isWarnEnabled()) {
0083:                            _log
0084:                                    .warn("No MBStatsUser exists with the primary key "
0085:                                            + statsUserId);
0086:                        }
0087:
0088:                        throw new NoSuchStatsUserException(
0089:                                "No MBStatsUser exists with the primary key "
0090:                                        + statsUserId);
0091:                    }
0092:
0093:                    return remove(mbStatsUser);
0094:                } catch (NoSuchStatsUserException nsee) {
0095:                    throw nsee;
0096:                } catch (Exception e) {
0097:                    throw HibernateUtil.processException(e);
0098:                } finally {
0099:                    closeSession(session);
0100:                }
0101:            }
0102:
0103:            public MBStatsUser remove(MBStatsUser mbStatsUser)
0104:                    throws SystemException {
0105:                ModelListener listener = _getListener();
0106:
0107:                if (listener != null) {
0108:                    listener.onBeforeRemove(mbStatsUser);
0109:                }
0110:
0111:                mbStatsUser = removeImpl(mbStatsUser);
0112:
0113:                if (listener != null) {
0114:                    listener.onAfterRemove(mbStatsUser);
0115:                }
0116:
0117:                return mbStatsUser;
0118:            }
0119:
0120:            protected MBStatsUser removeImpl(MBStatsUser mbStatsUser)
0121:                    throws SystemException {
0122:                Session session = null;
0123:
0124:                try {
0125:                    session = openSession();
0126:
0127:                    session.delete(mbStatsUser);
0128:
0129:                    session.flush();
0130:
0131:                    return mbStatsUser;
0132:                } catch (Exception e) {
0133:                    throw HibernateUtil.processException(e);
0134:                } finally {
0135:                    closeSession(session);
0136:
0137:                    FinderCache.clearCache(MBStatsUser.class.getName());
0138:                }
0139:            }
0140:
0141:            public MBStatsUser update(MBStatsUser mbStatsUser)
0142:                    throws SystemException {
0143:                return update(mbStatsUser, false);
0144:            }
0145:
0146:            public MBStatsUser update(MBStatsUser mbStatsUser, boolean merge)
0147:                    throws SystemException {
0148:                ModelListener listener = _getListener();
0149:
0150:                boolean isNew = mbStatsUser.isNew();
0151:
0152:                if (listener != null) {
0153:                    if (isNew) {
0154:                        listener.onBeforeCreate(mbStatsUser);
0155:                    } else {
0156:                        listener.onBeforeUpdate(mbStatsUser);
0157:                    }
0158:                }
0159:
0160:                mbStatsUser = updateImpl(mbStatsUser, merge);
0161:
0162:                if (listener != null) {
0163:                    if (isNew) {
0164:                        listener.onAfterCreate(mbStatsUser);
0165:                    } else {
0166:                        listener.onAfterUpdate(mbStatsUser);
0167:                    }
0168:                }
0169:
0170:                return mbStatsUser;
0171:            }
0172:
0173:            public MBStatsUser updateImpl(
0174:                    com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser,
0175:                    boolean merge) throws SystemException {
0176:                Session session = null;
0177:
0178:                try {
0179:                    session = openSession();
0180:
0181:                    if (merge) {
0182:                        session.merge(mbStatsUser);
0183:                    } else {
0184:                        if (mbStatsUser.isNew()) {
0185:                            session.save(mbStatsUser);
0186:                        }
0187:                    }
0188:
0189:                    session.flush();
0190:
0191:                    mbStatsUser.setNew(false);
0192:
0193:                    return mbStatsUser;
0194:                } catch (Exception e) {
0195:                    throw HibernateUtil.processException(e);
0196:                } finally {
0197:                    closeSession(session);
0198:
0199:                    FinderCache.clearCache(MBStatsUser.class.getName());
0200:                }
0201:            }
0202:
0203:            public MBStatsUser findByPrimaryKey(long statsUserId)
0204:                    throws NoSuchStatsUserException, SystemException {
0205:                MBStatsUser mbStatsUser = fetchByPrimaryKey(statsUserId);
0206:
0207:                if (mbStatsUser == null) {
0208:                    if (_log.isWarnEnabled()) {
0209:                        _log.warn("No MBStatsUser exists with the primary key "
0210:                                + statsUserId);
0211:                    }
0212:
0213:                    throw new NoSuchStatsUserException(
0214:                            "No MBStatsUser exists with the primary key "
0215:                                    + statsUserId);
0216:                }
0217:
0218:                return mbStatsUser;
0219:            }
0220:
0221:            public MBStatsUser fetchByPrimaryKey(long statsUserId)
0222:                    throws SystemException {
0223:                Session session = null;
0224:
0225:                try {
0226:                    session = openSession();
0227:
0228:                    return (MBStatsUser) session.get(MBStatsUserImpl.class,
0229:                            new Long(statsUserId));
0230:                } catch (Exception e) {
0231:                    throw HibernateUtil.processException(e);
0232:                } finally {
0233:                    closeSession(session);
0234:                }
0235:            }
0236:
0237:            public List findByGroupId(long groupId) throws SystemException {
0238:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
0239:                String finderClassName = MBStatsUser.class.getName();
0240:                String finderMethodName = "findByGroupId";
0241:                String[] finderParams = new String[] { Long.class.getName() };
0242:                Object[] finderArgs = new Object[] { new Long(groupId) };
0243:
0244:                Object result = null;
0245:
0246:                if (finderClassNameCacheEnabled) {
0247:                    result = FinderCache.getResult(finderClassName,
0248:                            finderMethodName, finderParams, finderArgs,
0249:                            getSessionFactory());
0250:                }
0251:
0252:                if (result == null) {
0253:                    Session session = null;
0254:
0255:                    try {
0256:                        session = openSession();
0257:
0258:                        StringMaker query = new StringMaker();
0259:
0260:                        query
0261:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0262:
0263:                        query.append("groupId = ?");
0264:
0265:                        query.append(" ");
0266:
0267:                        query.append("ORDER BY ");
0268:
0269:                        query.append("messageCount DESC");
0270:
0271:                        Query q = session.createQuery(query.toString());
0272:
0273:                        int queryPos = 0;
0274:
0275:                        q.setLong(queryPos++, groupId);
0276:
0277:                        List list = q.list();
0278:
0279:                        FinderCache.putResult(finderClassNameCacheEnabled,
0280:                                finderClassName, finderMethodName,
0281:                                finderParams, finderArgs, list);
0282:
0283:                        return list;
0284:                    } catch (Exception e) {
0285:                        throw HibernateUtil.processException(e);
0286:                    } finally {
0287:                        closeSession(session);
0288:                    }
0289:                } else {
0290:                    return (List) result;
0291:                }
0292:            }
0293:
0294:            public List findByGroupId(long groupId, int begin, int end)
0295:                    throws SystemException {
0296:                return findByGroupId(groupId, begin, end, null);
0297:            }
0298:
0299:            public List findByGroupId(long groupId, int begin, int end,
0300:                    OrderByComparator obc) throws SystemException {
0301:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
0302:                String finderClassName = MBStatsUser.class.getName();
0303:                String finderMethodName = "findByGroupId";
0304:                String[] finderParams = new String[] { Long.class.getName(),
0305:
0306:                "java.lang.Integer", "java.lang.Integer",
0307:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0308:                Object[] finderArgs = new Object[] { new Long(groupId),
0309:
0310:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0311:
0312:                Object result = null;
0313:
0314:                if (finderClassNameCacheEnabled) {
0315:                    result = FinderCache.getResult(finderClassName,
0316:                            finderMethodName, finderParams, finderArgs,
0317:                            getSessionFactory());
0318:                }
0319:
0320:                if (result == null) {
0321:                    Session session = null;
0322:
0323:                    try {
0324:                        session = openSession();
0325:
0326:                        StringMaker query = new StringMaker();
0327:
0328:                        query
0329:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0330:
0331:                        query.append("groupId = ?");
0332:
0333:                        query.append(" ");
0334:
0335:                        if (obc != null) {
0336:                            query.append("ORDER BY ");
0337:                            query.append(obc.getOrderBy());
0338:                        }
0339:
0340:                        else {
0341:                            query.append("ORDER BY ");
0342:
0343:                            query.append("messageCount DESC");
0344:                        }
0345:
0346:                        Query q = session.createQuery(query.toString());
0347:
0348:                        int queryPos = 0;
0349:
0350:                        q.setLong(queryPos++, groupId);
0351:
0352:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0353:
0354:                        FinderCache.putResult(finderClassNameCacheEnabled,
0355:                                finderClassName, finderMethodName,
0356:                                finderParams, finderArgs, list);
0357:
0358:                        return list;
0359:                    } catch (Exception e) {
0360:                        throw HibernateUtil.processException(e);
0361:                    } finally {
0362:                        closeSession(session);
0363:                    }
0364:                } else {
0365:                    return (List) result;
0366:                }
0367:            }
0368:
0369:            public MBStatsUser findByGroupId_First(long groupId,
0370:                    OrderByComparator obc) throws NoSuchStatsUserException,
0371:                    SystemException {
0372:                List list = findByGroupId(groupId, 0, 1, obc);
0373:
0374:                if (list.size() == 0) {
0375:                    StringMaker msg = new StringMaker();
0376:
0377:                    msg.append("No MBStatsUser exists with the key {");
0378:
0379:                    msg.append("groupId=" + groupId);
0380:
0381:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0382:
0383:                    throw new NoSuchStatsUserException(msg.toString());
0384:                } else {
0385:                    return (MBStatsUser) list.get(0);
0386:                }
0387:            }
0388:
0389:            public MBStatsUser findByGroupId_Last(long groupId,
0390:                    OrderByComparator obc) throws NoSuchStatsUserException,
0391:                    SystemException {
0392:                int count = countByGroupId(groupId);
0393:
0394:                List list = findByGroupId(groupId, count - 1, count, obc);
0395:
0396:                if (list.size() == 0) {
0397:                    StringMaker msg = new StringMaker();
0398:
0399:                    msg.append("No MBStatsUser exists with the key {");
0400:
0401:                    msg.append("groupId=" + groupId);
0402:
0403:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0404:
0405:                    throw new NoSuchStatsUserException(msg.toString());
0406:                } else {
0407:                    return (MBStatsUser) list.get(0);
0408:                }
0409:            }
0410:
0411:            public MBStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
0412:                    long groupId, OrderByComparator obc)
0413:                    throws NoSuchStatsUserException, SystemException {
0414:                MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
0415:
0416:                int count = countByGroupId(groupId);
0417:
0418:                Session session = null;
0419:
0420:                try {
0421:                    session = openSession();
0422:
0423:                    StringMaker query = new StringMaker();
0424:
0425:                    query
0426:                            .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0427:
0428:                    query.append("groupId = ?");
0429:
0430:                    query.append(" ");
0431:
0432:                    if (obc != null) {
0433:                        query.append("ORDER BY ");
0434:                        query.append(obc.getOrderBy());
0435:                    }
0436:
0437:                    else {
0438:                        query.append("ORDER BY ");
0439:
0440:                        query.append("messageCount DESC");
0441:                    }
0442:
0443:                    Query q = session.createQuery(query.toString());
0444:
0445:                    int queryPos = 0;
0446:
0447:                    q.setLong(queryPos++, groupId);
0448:
0449:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0450:                            mbStatsUser);
0451:
0452:                    MBStatsUser[] array = new MBStatsUserImpl[3];
0453:
0454:                    array[0] = (MBStatsUser) objArray[0];
0455:                    array[1] = (MBStatsUser) objArray[1];
0456:                    array[2] = (MBStatsUser) objArray[2];
0457:
0458:                    return array;
0459:                } catch (Exception e) {
0460:                    throw HibernateUtil.processException(e);
0461:                } finally {
0462:                    closeSession(session);
0463:                }
0464:            }
0465:
0466:            public List findByUserId(long userId) throws SystemException {
0467:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
0468:                String finderClassName = MBStatsUser.class.getName();
0469:                String finderMethodName = "findByUserId";
0470:                String[] finderParams = new String[] { Long.class.getName() };
0471:                Object[] finderArgs = new Object[] { new Long(userId) };
0472:
0473:                Object result = null;
0474:
0475:                if (finderClassNameCacheEnabled) {
0476:                    result = FinderCache.getResult(finderClassName,
0477:                            finderMethodName, finderParams, finderArgs,
0478:                            getSessionFactory());
0479:                }
0480:
0481:                if (result == null) {
0482:                    Session session = null;
0483:
0484:                    try {
0485:                        session = openSession();
0486:
0487:                        StringMaker query = new StringMaker();
0488:
0489:                        query
0490:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0491:
0492:                        query.append("userId = ?");
0493:
0494:                        query.append(" ");
0495:
0496:                        query.append("ORDER BY ");
0497:
0498:                        query.append("messageCount DESC");
0499:
0500:                        Query q = session.createQuery(query.toString());
0501:
0502:                        int queryPos = 0;
0503:
0504:                        q.setLong(queryPos++, userId);
0505:
0506:                        List list = q.list();
0507:
0508:                        FinderCache.putResult(finderClassNameCacheEnabled,
0509:                                finderClassName, finderMethodName,
0510:                                finderParams, finderArgs, list);
0511:
0512:                        return list;
0513:                    } catch (Exception e) {
0514:                        throw HibernateUtil.processException(e);
0515:                    } finally {
0516:                        closeSession(session);
0517:                    }
0518:                } else {
0519:                    return (List) result;
0520:                }
0521:            }
0522:
0523:            public List findByUserId(long userId, int begin, int end)
0524:                    throws SystemException {
0525:                return findByUserId(userId, begin, end, null);
0526:            }
0527:
0528:            public List findByUserId(long userId, int begin, int end,
0529:                    OrderByComparator obc) throws SystemException {
0530:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
0531:                String finderClassName = MBStatsUser.class.getName();
0532:                String finderMethodName = "findByUserId";
0533:                String[] finderParams = new String[] { Long.class.getName(),
0534:
0535:                "java.lang.Integer", "java.lang.Integer",
0536:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0537:                Object[] finderArgs = new Object[] { new Long(userId),
0538:
0539:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0540:
0541:                Object result = null;
0542:
0543:                if (finderClassNameCacheEnabled) {
0544:                    result = FinderCache.getResult(finderClassName,
0545:                            finderMethodName, finderParams, finderArgs,
0546:                            getSessionFactory());
0547:                }
0548:
0549:                if (result == null) {
0550:                    Session session = null;
0551:
0552:                    try {
0553:                        session = openSession();
0554:
0555:                        StringMaker query = new StringMaker();
0556:
0557:                        query
0558:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0559:
0560:                        query.append("userId = ?");
0561:
0562:                        query.append(" ");
0563:
0564:                        if (obc != null) {
0565:                            query.append("ORDER BY ");
0566:                            query.append(obc.getOrderBy());
0567:                        }
0568:
0569:                        else {
0570:                            query.append("ORDER BY ");
0571:
0572:                            query.append("messageCount DESC");
0573:                        }
0574:
0575:                        Query q = session.createQuery(query.toString());
0576:
0577:                        int queryPos = 0;
0578:
0579:                        q.setLong(queryPos++, userId);
0580:
0581:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0582:
0583:                        FinderCache.putResult(finderClassNameCacheEnabled,
0584:                                finderClassName, finderMethodName,
0585:                                finderParams, finderArgs, list);
0586:
0587:                        return list;
0588:                    } catch (Exception e) {
0589:                        throw HibernateUtil.processException(e);
0590:                    } finally {
0591:                        closeSession(session);
0592:                    }
0593:                } else {
0594:                    return (List) result;
0595:                }
0596:            }
0597:
0598:            public MBStatsUser findByUserId_First(long userId,
0599:                    OrderByComparator obc) throws NoSuchStatsUserException,
0600:                    SystemException {
0601:                List list = findByUserId(userId, 0, 1, obc);
0602:
0603:                if (list.size() == 0) {
0604:                    StringMaker msg = new StringMaker();
0605:
0606:                    msg.append("No MBStatsUser exists with the key {");
0607:
0608:                    msg.append("userId=" + userId);
0609:
0610:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0611:
0612:                    throw new NoSuchStatsUserException(msg.toString());
0613:                } else {
0614:                    return (MBStatsUser) list.get(0);
0615:                }
0616:            }
0617:
0618:            public MBStatsUser findByUserId_Last(long userId,
0619:                    OrderByComparator obc) throws NoSuchStatsUserException,
0620:                    SystemException {
0621:                int count = countByUserId(userId);
0622:
0623:                List list = findByUserId(userId, count - 1, count, obc);
0624:
0625:                if (list.size() == 0) {
0626:                    StringMaker msg = new StringMaker();
0627:
0628:                    msg.append("No MBStatsUser exists with the key {");
0629:
0630:                    msg.append("userId=" + userId);
0631:
0632:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0633:
0634:                    throw new NoSuchStatsUserException(msg.toString());
0635:                } else {
0636:                    return (MBStatsUser) list.get(0);
0637:                }
0638:            }
0639:
0640:            public MBStatsUser[] findByUserId_PrevAndNext(long statsUserId,
0641:                    long userId, OrderByComparator obc)
0642:                    throws NoSuchStatsUserException, SystemException {
0643:                MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
0644:
0645:                int count = countByUserId(userId);
0646:
0647:                Session session = null;
0648:
0649:                try {
0650:                    session = openSession();
0651:
0652:                    StringMaker query = new StringMaker();
0653:
0654:                    query
0655:                            .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0656:
0657:                    query.append("userId = ?");
0658:
0659:                    query.append(" ");
0660:
0661:                    if (obc != null) {
0662:                        query.append("ORDER BY ");
0663:                        query.append(obc.getOrderBy());
0664:                    }
0665:
0666:                    else {
0667:                        query.append("ORDER BY ");
0668:
0669:                        query.append("messageCount DESC");
0670:                    }
0671:
0672:                    Query q = session.createQuery(query.toString());
0673:
0674:                    int queryPos = 0;
0675:
0676:                    q.setLong(queryPos++, userId);
0677:
0678:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0679:                            mbStatsUser);
0680:
0681:                    MBStatsUser[] array = new MBStatsUserImpl[3];
0682:
0683:                    array[0] = (MBStatsUser) objArray[0];
0684:                    array[1] = (MBStatsUser) objArray[1];
0685:                    array[2] = (MBStatsUser) objArray[2];
0686:
0687:                    return array;
0688:                } catch (Exception e) {
0689:                    throw HibernateUtil.processException(e);
0690:                } finally {
0691:                    closeSession(session);
0692:                }
0693:            }
0694:
0695:            public MBStatsUser findByG_U(long groupId, long userId)
0696:                    throws NoSuchStatsUserException, SystemException {
0697:                MBStatsUser mbStatsUser = fetchByG_U(groupId, userId);
0698:
0699:                if (mbStatsUser == null) {
0700:                    StringMaker msg = new StringMaker();
0701:
0702:                    msg.append("No MBStatsUser exists with the key {");
0703:
0704:                    msg.append("groupId=" + groupId);
0705:
0706:                    msg.append(", ");
0707:                    msg.append("userId=" + userId);
0708:
0709:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0710:
0711:                    if (_log.isWarnEnabled()) {
0712:                        _log.warn(msg.toString());
0713:                    }
0714:
0715:                    throw new NoSuchStatsUserException(msg.toString());
0716:                }
0717:
0718:                return mbStatsUser;
0719:            }
0720:
0721:            public MBStatsUser fetchByG_U(long groupId, long userId)
0722:                    throws SystemException {
0723:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
0724:                String finderClassName = MBStatsUser.class.getName();
0725:                String finderMethodName = "fetchByG_U";
0726:                String[] finderParams = new String[] { Long.class.getName(),
0727:                        Long.class.getName() };
0728:                Object[] finderArgs = new Object[] { new Long(groupId),
0729:                        new Long(userId) };
0730:
0731:                Object result = null;
0732:
0733:                if (finderClassNameCacheEnabled) {
0734:                    result = FinderCache.getResult(finderClassName,
0735:                            finderMethodName, finderParams, finderArgs,
0736:                            getSessionFactory());
0737:                }
0738:
0739:                if (result == null) {
0740:                    Session session = null;
0741:
0742:                    try {
0743:                        session = openSession();
0744:
0745:                        StringMaker query = new StringMaker();
0746:
0747:                        query
0748:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0749:
0750:                        query.append("groupId = ?");
0751:
0752:                        query.append(" AND ");
0753:
0754:                        query.append("userId = ?");
0755:
0756:                        query.append(" ");
0757:
0758:                        query.append("ORDER BY ");
0759:
0760:                        query.append("messageCount DESC");
0761:
0762:                        Query q = session.createQuery(query.toString());
0763:
0764:                        int queryPos = 0;
0765:
0766:                        q.setLong(queryPos++, groupId);
0767:
0768:                        q.setLong(queryPos++, userId);
0769:
0770:                        List list = q.list();
0771:
0772:                        FinderCache.putResult(finderClassNameCacheEnabled,
0773:                                finderClassName, finderMethodName,
0774:                                finderParams, finderArgs, list);
0775:
0776:                        if (list.size() == 0) {
0777:                            return null;
0778:                        } else {
0779:                            return (MBStatsUser) list.get(0);
0780:                        }
0781:                    } catch (Exception e) {
0782:                        throw HibernateUtil.processException(e);
0783:                    } finally {
0784:                        closeSession(session);
0785:                    }
0786:                } else {
0787:                    List list = (List) result;
0788:
0789:                    if (list.size() == 0) {
0790:                        return null;
0791:                    } else {
0792:                        return (MBStatsUser) list.get(0);
0793:                    }
0794:                }
0795:            }
0796:
0797:            public List findByG_M(long groupId, int messageCount)
0798:                    throws SystemException {
0799:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
0800:                String finderClassName = MBStatsUser.class.getName();
0801:                String finderMethodName = "findByG_M";
0802:                String[] finderParams = new String[] { Long.class.getName(),
0803:                        Integer.class.getName() };
0804:                Object[] finderArgs = new Object[] { new Long(groupId),
0805:                        new Integer(messageCount) };
0806:
0807:                Object result = null;
0808:
0809:                if (finderClassNameCacheEnabled) {
0810:                    result = FinderCache.getResult(finderClassName,
0811:                            finderMethodName, finderParams, finderArgs,
0812:                            getSessionFactory());
0813:                }
0814:
0815:                if (result == null) {
0816:                    Session session = null;
0817:
0818:                    try {
0819:                        session = openSession();
0820:
0821:                        StringMaker query = new StringMaker();
0822:
0823:                        query
0824:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0825:
0826:                        query.append("groupId = ?");
0827:
0828:                        query.append(" AND ");
0829:
0830:                        query.append("messageCount != ?");
0831:
0832:                        query.append(" ");
0833:
0834:                        query.append("ORDER BY ");
0835:
0836:                        query.append("messageCount DESC");
0837:
0838:                        Query q = session.createQuery(query.toString());
0839:
0840:                        int queryPos = 0;
0841:
0842:                        q.setLong(queryPos++, groupId);
0843:
0844:                        q.setInteger(queryPos++, messageCount);
0845:
0846:                        List list = q.list();
0847:
0848:                        FinderCache.putResult(finderClassNameCacheEnabled,
0849:                                finderClassName, finderMethodName,
0850:                                finderParams, finderArgs, list);
0851:
0852:                        return list;
0853:                    } catch (Exception e) {
0854:                        throw HibernateUtil.processException(e);
0855:                    } finally {
0856:                        closeSession(session);
0857:                    }
0858:                } else {
0859:                    return (List) result;
0860:                }
0861:            }
0862:
0863:            public List findByG_M(long groupId, int messageCount, int begin,
0864:                    int end) throws SystemException {
0865:                return findByG_M(groupId, messageCount, begin, end, null);
0866:            }
0867:
0868:            public List findByG_M(long groupId, int messageCount, int begin,
0869:                    int end, OrderByComparator obc) throws SystemException {
0870:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
0871:                String finderClassName = MBStatsUser.class.getName();
0872:                String finderMethodName = "findByG_M";
0873:                String[] finderParams = new String[] { Long.class.getName(),
0874:                        Integer.class.getName(),
0875:
0876:                        "java.lang.Integer", "java.lang.Integer",
0877:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0878:                Object[] finderArgs = new Object[] { new Long(groupId),
0879:                        new Integer(messageCount),
0880:
0881:                        String.valueOf(begin), String.valueOf(end),
0882:                        String.valueOf(obc) };
0883:
0884:                Object result = null;
0885:
0886:                if (finderClassNameCacheEnabled) {
0887:                    result = FinderCache.getResult(finderClassName,
0888:                            finderMethodName, finderParams, finderArgs,
0889:                            getSessionFactory());
0890:                }
0891:
0892:                if (result == null) {
0893:                    Session session = null;
0894:
0895:                    try {
0896:                        session = openSession();
0897:
0898:                        StringMaker query = new StringMaker();
0899:
0900:                        query
0901:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
0902:
0903:                        query.append("groupId = ?");
0904:
0905:                        query.append(" AND ");
0906:
0907:                        query.append("messageCount != ?");
0908:
0909:                        query.append(" ");
0910:
0911:                        if (obc != null) {
0912:                            query.append("ORDER BY ");
0913:                            query.append(obc.getOrderBy());
0914:                        }
0915:
0916:                        else {
0917:                            query.append("ORDER BY ");
0918:
0919:                            query.append("messageCount DESC");
0920:                        }
0921:
0922:                        Query q = session.createQuery(query.toString());
0923:
0924:                        int queryPos = 0;
0925:
0926:                        q.setLong(queryPos++, groupId);
0927:
0928:                        q.setInteger(queryPos++, messageCount);
0929:
0930:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0931:
0932:                        FinderCache.putResult(finderClassNameCacheEnabled,
0933:                                finderClassName, finderMethodName,
0934:                                finderParams, finderArgs, list);
0935:
0936:                        return list;
0937:                    } catch (Exception e) {
0938:                        throw HibernateUtil.processException(e);
0939:                    } finally {
0940:                        closeSession(session);
0941:                    }
0942:                } else {
0943:                    return (List) result;
0944:                }
0945:            }
0946:
0947:            public MBStatsUser findByG_M_First(long groupId, int messageCount,
0948:                    OrderByComparator obc) throws NoSuchStatsUserException,
0949:                    SystemException {
0950:                List list = findByG_M(groupId, messageCount, 0, 1, obc);
0951:
0952:                if (list.size() == 0) {
0953:                    StringMaker msg = new StringMaker();
0954:
0955:                    msg.append("No MBStatsUser exists with the key {");
0956:
0957:                    msg.append("groupId=" + groupId);
0958:
0959:                    msg.append(", ");
0960:                    msg.append("messageCount=" + messageCount);
0961:
0962:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0963:
0964:                    throw new NoSuchStatsUserException(msg.toString());
0965:                } else {
0966:                    return (MBStatsUser) list.get(0);
0967:                }
0968:            }
0969:
0970:            public MBStatsUser findByG_M_Last(long groupId, int messageCount,
0971:                    OrderByComparator obc) throws NoSuchStatsUserException,
0972:                    SystemException {
0973:                int count = countByG_M(groupId, messageCount);
0974:
0975:                List list = findByG_M(groupId, messageCount, count - 1, count,
0976:                        obc);
0977:
0978:                if (list.size() == 0) {
0979:                    StringMaker msg = new StringMaker();
0980:
0981:                    msg.append("No MBStatsUser exists with the key {");
0982:
0983:                    msg.append("groupId=" + groupId);
0984:
0985:                    msg.append(", ");
0986:                    msg.append("messageCount=" + messageCount);
0987:
0988:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0989:
0990:                    throw new NoSuchStatsUserException(msg.toString());
0991:                } else {
0992:                    return (MBStatsUser) list.get(0);
0993:                }
0994:            }
0995:
0996:            public MBStatsUser[] findByG_M_PrevAndNext(long statsUserId,
0997:                    long groupId, int messageCount, OrderByComparator obc)
0998:                    throws NoSuchStatsUserException, SystemException {
0999:                MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
1000:
1001:                int count = countByG_M(groupId, messageCount);
1002:
1003:                Session session = null;
1004:
1005:                try {
1006:                    session = openSession();
1007:
1008:                    StringMaker query = new StringMaker();
1009:
1010:                    query
1011:                            .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1012:
1013:                    query.append("groupId = ?");
1014:
1015:                    query.append(" AND ");
1016:
1017:                    query.append("messageCount != ?");
1018:
1019:                    query.append(" ");
1020:
1021:                    if (obc != null) {
1022:                        query.append("ORDER BY ");
1023:                        query.append(obc.getOrderBy());
1024:                    }
1025:
1026:                    else {
1027:                        query.append("ORDER BY ");
1028:
1029:                        query.append("messageCount DESC");
1030:                    }
1031:
1032:                    Query q = session.createQuery(query.toString());
1033:
1034:                    int queryPos = 0;
1035:
1036:                    q.setLong(queryPos++, groupId);
1037:
1038:                    q.setInteger(queryPos++, messageCount);
1039:
1040:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1041:                            mbStatsUser);
1042:
1043:                    MBStatsUser[] array = new MBStatsUserImpl[3];
1044:
1045:                    array[0] = (MBStatsUser) objArray[0];
1046:                    array[1] = (MBStatsUser) objArray[1];
1047:                    array[2] = (MBStatsUser) objArray[2];
1048:
1049:                    return array;
1050:                } catch (Exception e) {
1051:                    throw HibernateUtil.processException(e);
1052:                } finally {
1053:                    closeSession(session);
1054:                }
1055:            }
1056:
1057:            public List findWithDynamicQuery(
1058:                    DynamicQueryInitializer queryInitializer)
1059:                    throws SystemException {
1060:                Session session = null;
1061:
1062:                try {
1063:                    session = openSession();
1064:
1065:                    DynamicQuery query = queryInitializer.initialize(session);
1066:
1067:                    return query.list();
1068:                } catch (Exception e) {
1069:                    throw HibernateUtil.processException(e);
1070:                } finally {
1071:                    closeSession(session);
1072:                }
1073:            }
1074:
1075:            public List findWithDynamicQuery(
1076:                    DynamicQueryInitializer queryInitializer, int begin, int end)
1077:                    throws SystemException {
1078:                Session session = null;
1079:
1080:                try {
1081:                    session = openSession();
1082:
1083:                    DynamicQuery query = queryInitializer.initialize(session);
1084:
1085:                    query.setLimit(begin, end);
1086:
1087:                    return query.list();
1088:                } catch (Exception e) {
1089:                    throw HibernateUtil.processException(e);
1090:                } finally {
1091:                    closeSession(session);
1092:                }
1093:            }
1094:
1095:            public List findAll() throws SystemException {
1096:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1097:            }
1098:
1099:            public List findAll(int begin, int end) throws SystemException {
1100:                return findAll(begin, end, null);
1101:            }
1102:
1103:            public List findAll(int begin, int end, OrderByComparator obc)
1104:                    throws SystemException {
1105:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1106:                String finderClassName = MBStatsUser.class.getName();
1107:                String finderMethodName = "findAll";
1108:                String[] finderParams = new String[] { "java.lang.Integer",
1109:                        "java.lang.Integer",
1110:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1111:                Object[] finderArgs = new Object[] { String.valueOf(begin),
1112:                        String.valueOf(end), String.valueOf(obc) };
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.portlet.messageboards.model.MBStatsUser ");
1132:
1133:                        if (obc != null) {
1134:                            query.append("ORDER BY ");
1135:                            query.append(obc.getOrderBy());
1136:                        }
1137:
1138:                        else {
1139:                            query.append("ORDER BY ");
1140:
1141:                            query.append("messageCount DESC");
1142:                        }
1143:
1144:                        Query q = session.createQuery(query.toString());
1145:
1146:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1147:
1148:                        if (obc == null) {
1149:                            Collections.sort(list);
1150:                        }
1151:
1152:                        FinderCache.putResult(finderClassNameCacheEnabled,
1153:                                finderClassName, finderMethodName,
1154:                                finderParams, finderArgs, list);
1155:
1156:                        return list;
1157:                    } catch (Exception e) {
1158:                        throw HibernateUtil.processException(e);
1159:                    } finally {
1160:                        closeSession(session);
1161:                    }
1162:                } else {
1163:                    return (List) result;
1164:                }
1165:            }
1166:
1167:            public void removeByGroupId(long groupId) throws SystemException {
1168:                Iterator itr = findByGroupId(groupId).iterator();
1169:
1170:                while (itr.hasNext()) {
1171:                    MBStatsUser mbStatsUser = (MBStatsUser) itr.next();
1172:
1173:                    remove(mbStatsUser);
1174:                }
1175:            }
1176:
1177:            public void removeByUserId(long userId) throws SystemException {
1178:                Iterator itr = findByUserId(userId).iterator();
1179:
1180:                while (itr.hasNext()) {
1181:                    MBStatsUser mbStatsUser = (MBStatsUser) itr.next();
1182:
1183:                    remove(mbStatsUser);
1184:                }
1185:            }
1186:
1187:            public void removeByG_U(long groupId, long userId)
1188:                    throws NoSuchStatsUserException, SystemException {
1189:                MBStatsUser mbStatsUser = findByG_U(groupId, userId);
1190:
1191:                remove(mbStatsUser);
1192:            }
1193:
1194:            public void removeByG_M(long groupId, int messageCount)
1195:                    throws SystemException {
1196:                Iterator itr = findByG_M(groupId, messageCount).iterator();
1197:
1198:                while (itr.hasNext()) {
1199:                    MBStatsUser mbStatsUser = (MBStatsUser) itr.next();
1200:
1201:                    remove(mbStatsUser);
1202:                }
1203:            }
1204:
1205:            public void removeAll() throws SystemException {
1206:                Iterator itr = findAll().iterator();
1207:
1208:                while (itr.hasNext()) {
1209:                    remove((MBStatsUser) itr.next());
1210:                }
1211:            }
1212:
1213:            public int countByGroupId(long groupId) throws SystemException {
1214:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1215:                String finderClassName = MBStatsUser.class.getName();
1216:                String finderMethodName = "countByGroupId";
1217:                String[] finderParams = new String[] { Long.class.getName() };
1218:                Object[] finderArgs = new Object[] { new Long(groupId) };
1219:
1220:                Object result = null;
1221:
1222:                if (finderClassNameCacheEnabled) {
1223:                    result = FinderCache.getResult(finderClassName,
1224:                            finderMethodName, finderParams, finderArgs,
1225:                            getSessionFactory());
1226:                }
1227:
1228:                if (result == null) {
1229:                    Session session = null;
1230:
1231:                    try {
1232:                        session = openSession();
1233:
1234:                        StringMaker query = new StringMaker();
1235:
1236:                        query.append("SELECT COUNT(*) ");
1237:                        query
1238:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1239:
1240:                        query.append("groupId = ?");
1241:
1242:                        query.append(" ");
1243:
1244:                        Query q = session.createQuery(query.toString());
1245:
1246:                        int queryPos = 0;
1247:
1248:                        q.setLong(queryPos++, groupId);
1249:
1250:                        Long count = null;
1251:
1252:                        Iterator itr = q.list().iterator();
1253:
1254:                        if (itr.hasNext()) {
1255:                            count = (Long) itr.next();
1256:                        }
1257:
1258:                        if (count == null) {
1259:                            count = new Long(0);
1260:                        }
1261:
1262:                        FinderCache.putResult(finderClassNameCacheEnabled,
1263:                                finderClassName, finderMethodName,
1264:                                finderParams, finderArgs, count);
1265:
1266:                        return count.intValue();
1267:                    } catch (Exception e) {
1268:                        throw HibernateUtil.processException(e);
1269:                    } finally {
1270:                        closeSession(session);
1271:                    }
1272:                } else {
1273:                    return ((Long) result).intValue();
1274:                }
1275:            }
1276:
1277:            public int countByUserId(long userId) throws SystemException {
1278:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1279:                String finderClassName = MBStatsUser.class.getName();
1280:                String finderMethodName = "countByUserId";
1281:                String[] finderParams = new String[] { Long.class.getName() };
1282:                Object[] finderArgs = new Object[] { new Long(userId) };
1283:
1284:                Object result = null;
1285:
1286:                if (finderClassNameCacheEnabled) {
1287:                    result = FinderCache.getResult(finderClassName,
1288:                            finderMethodName, finderParams, finderArgs,
1289:                            getSessionFactory());
1290:                }
1291:
1292:                if (result == null) {
1293:                    Session session = null;
1294:
1295:                    try {
1296:                        session = openSession();
1297:
1298:                        StringMaker query = new StringMaker();
1299:
1300:                        query.append("SELECT COUNT(*) ");
1301:                        query
1302:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1303:
1304:                        query.append("userId = ?");
1305:
1306:                        query.append(" ");
1307:
1308:                        Query q = session.createQuery(query.toString());
1309:
1310:                        int queryPos = 0;
1311:
1312:                        q.setLong(queryPos++, userId);
1313:
1314:                        Long count = null;
1315:
1316:                        Iterator itr = q.list().iterator();
1317:
1318:                        if (itr.hasNext()) {
1319:                            count = (Long) itr.next();
1320:                        }
1321:
1322:                        if (count == null) {
1323:                            count = new Long(0);
1324:                        }
1325:
1326:                        FinderCache.putResult(finderClassNameCacheEnabled,
1327:                                finderClassName, finderMethodName,
1328:                                finderParams, finderArgs, count);
1329:
1330:                        return count.intValue();
1331:                    } catch (Exception e) {
1332:                        throw HibernateUtil.processException(e);
1333:                    } finally {
1334:                        closeSession(session);
1335:                    }
1336:                } else {
1337:                    return ((Long) result).intValue();
1338:                }
1339:            }
1340:
1341:            public int countByG_U(long groupId, long userId)
1342:                    throws SystemException {
1343:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1344:                String finderClassName = MBStatsUser.class.getName();
1345:                String finderMethodName = "countByG_U";
1346:                String[] finderParams = new String[] { Long.class.getName(),
1347:                        Long.class.getName() };
1348:                Object[] finderArgs = new Object[] { new Long(groupId),
1349:                        new Long(userId) };
1350:
1351:                Object result = null;
1352:
1353:                if (finderClassNameCacheEnabled) {
1354:                    result = FinderCache.getResult(finderClassName,
1355:                            finderMethodName, finderParams, finderArgs,
1356:                            getSessionFactory());
1357:                }
1358:
1359:                if (result == null) {
1360:                    Session session = null;
1361:
1362:                    try {
1363:                        session = openSession();
1364:
1365:                        StringMaker query = new StringMaker();
1366:
1367:                        query.append("SELECT COUNT(*) ");
1368:                        query
1369:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1370:
1371:                        query.append("groupId = ?");
1372:
1373:                        query.append(" AND ");
1374:
1375:                        query.append("userId = ?");
1376:
1377:                        query.append(" ");
1378:
1379:                        Query q = session.createQuery(query.toString());
1380:
1381:                        int queryPos = 0;
1382:
1383:                        q.setLong(queryPos++, groupId);
1384:
1385:                        q.setLong(queryPos++, userId);
1386:
1387:                        Long count = null;
1388:
1389:                        Iterator itr = q.list().iterator();
1390:
1391:                        if (itr.hasNext()) {
1392:                            count = (Long) itr.next();
1393:                        }
1394:
1395:                        if (count == null) {
1396:                            count = new Long(0);
1397:                        }
1398:
1399:                        FinderCache.putResult(finderClassNameCacheEnabled,
1400:                                finderClassName, finderMethodName,
1401:                                finderParams, finderArgs, count);
1402:
1403:                        return count.intValue();
1404:                    } catch (Exception e) {
1405:                        throw HibernateUtil.processException(e);
1406:                    } finally {
1407:                        closeSession(session);
1408:                    }
1409:                } else {
1410:                    return ((Long) result).intValue();
1411:                }
1412:            }
1413:
1414:            public int countByG_M(long groupId, int messageCount)
1415:                    throws SystemException {
1416:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1417:                String finderClassName = MBStatsUser.class.getName();
1418:                String finderMethodName = "countByG_M";
1419:                String[] finderParams = new String[] { Long.class.getName(),
1420:                        Integer.class.getName() };
1421:                Object[] finderArgs = new Object[] { new Long(groupId),
1422:                        new Integer(messageCount) };
1423:
1424:                Object result = null;
1425:
1426:                if (finderClassNameCacheEnabled) {
1427:                    result = FinderCache.getResult(finderClassName,
1428:                            finderMethodName, finderParams, finderArgs,
1429:                            getSessionFactory());
1430:                }
1431:
1432:                if (result == null) {
1433:                    Session session = null;
1434:
1435:                    try {
1436:                        session = openSession();
1437:
1438:                        StringMaker query = new StringMaker();
1439:
1440:                        query.append("SELECT COUNT(*) ");
1441:                        query
1442:                                .append("FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1443:
1444:                        query.append("groupId = ?");
1445:
1446:                        query.append(" AND ");
1447:
1448:                        query.append("messageCount != ?");
1449:
1450:                        query.append(" ");
1451:
1452:                        Query q = session.createQuery(query.toString());
1453:
1454:                        int queryPos = 0;
1455:
1456:                        q.setLong(queryPos++, groupId);
1457:
1458:                        q.setInteger(queryPos++, messageCount);
1459:
1460:                        Long count = null;
1461:
1462:                        Iterator itr = q.list().iterator();
1463:
1464:                        if (itr.hasNext()) {
1465:                            count = (Long) itr.next();
1466:                        }
1467:
1468:                        if (count == null) {
1469:                            count = new Long(0);
1470:                        }
1471:
1472:                        FinderCache.putResult(finderClassNameCacheEnabled,
1473:                                finderClassName, finderMethodName,
1474:                                finderParams, finderArgs, count);
1475:
1476:                        return count.intValue();
1477:                    } catch (Exception e) {
1478:                        throw HibernateUtil.processException(e);
1479:                    } finally {
1480:                        closeSession(session);
1481:                    }
1482:                } else {
1483:                    return ((Long) result).intValue();
1484:                }
1485:            }
1486:
1487:            public int countAll() throws SystemException {
1488:                boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1489:                String finderClassName = MBStatsUser.class.getName();
1490:                String finderMethodName = "countAll";
1491:                String[] finderParams = new String[] {};
1492:                Object[] finderArgs = new Object[] {};
1493:
1494:                Object result = null;
1495:
1496:                if (finderClassNameCacheEnabled) {
1497:                    result = FinderCache.getResult(finderClassName,
1498:                            finderMethodName, finderParams, finderArgs,
1499:                            getSessionFactory());
1500:                }
1501:
1502:                if (result == null) {
1503:                    Session session = null;
1504:
1505:                    try {
1506:                        session = openSession();
1507:
1508:                        Query q = session
1509:                                .createQuery("SELECT COUNT(*) FROM com.liferay.portlet.messageboards.model.MBStatsUser");
1510:
1511:                        Long count = null;
1512:
1513:                        Iterator itr = q.list().iterator();
1514:
1515:                        if (itr.hasNext()) {
1516:                            count = (Long) itr.next();
1517:                        }
1518:
1519:                        if (count == null) {
1520:                            count = new Long(0);
1521:                        }
1522:
1523:                        FinderCache.putResult(finderClassNameCacheEnabled,
1524:                                finderClassName, finderMethodName,
1525:                                finderParams, finderArgs, count);
1526:
1527:                        return count.intValue();
1528:                    } catch (Exception e) {
1529:                        throw HibernateUtil.processException(e);
1530:                    } finally {
1531:                        closeSession(session);
1532:                    }
1533:                } else {
1534:                    return ((Long) result).intValue();
1535:                }
1536:            }
1537:
1538:            protected void initDao() {
1539:            }
1540:
1541:            private static ModelListener _getListener() {
1542:                if (Validator.isNotNull(_LISTENER)) {
1543:                    try {
1544:                        return (ModelListener) Class.forName(_LISTENER)
1545:                                .newInstance();
1546:                    } catch (Exception e) {
1547:                        _log.error(e);
1548:                    }
1549:                }
1550:
1551:                return null;
1552:            }
1553:
1554:            private static final String _LISTENER = GetterUtil
1555:                    .getString(PropsUtil
1556:                            .get("value.object.listener.com.liferay.portlet.messageboards.model.MBStatsUser"));
1557:            private static Log _log = LogFactory
1558:                    .getLog(MBStatsUserPersistenceImpl.class);
1559:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.