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