Source Code Cross Referenced for JournalTemplatePersistenceImpl.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.NoSuchTemplateException;
0039:        import com.liferay.portlet.journal.model.JournalTemplate;
0040:        import com.liferay.portlet.journal.model.impl.JournalTemplateImpl;
0041:        import com.liferay.portlet.journal.model.impl.JournalTemplateModelImpl;
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="JournalTemplatePersistenceImpl.java.html"><b><i>View Source</i></b></a>
0057:         *
0058:         * @author Brian Wing Shun Chan
0059:         *
0060:         */
0061:        public class JournalTemplatePersistenceImpl extends BasePersistence
0062:                implements  JournalTemplatePersistence {
0063:            public JournalTemplate create(long id) {
0064:                JournalTemplate journalTemplate = new JournalTemplateImpl();
0065:
0066:                journalTemplate.setNew(true);
0067:                journalTemplate.setPrimaryKey(id);
0068:
0069:                String uuid = PortalUUIDUtil.generate();
0070:
0071:                journalTemplate.setUuid(uuid);
0072:
0073:                return journalTemplate;
0074:            }
0075:
0076:            public JournalTemplate remove(long id)
0077:                    throws NoSuchTemplateException, SystemException {
0078:                Session session = null;
0079:
0080:                try {
0081:                    session = openSession();
0082:
0083:                    JournalTemplate journalTemplate = (JournalTemplate) session
0084:                            .get(JournalTemplateImpl.class, new Long(id));
0085:
0086:                    if (journalTemplate == null) {
0087:                        if (_log.isWarnEnabled()) {
0088:                            _log
0089:                                    .warn("No JournalTemplate exists with the primary key "
0090:                                            + id);
0091:                        }
0092:
0093:                        throw new NoSuchTemplateException(
0094:                                "No JournalTemplate exists with the primary key "
0095:                                        + id);
0096:                    }
0097:
0098:                    return remove(journalTemplate);
0099:                } catch (NoSuchTemplateException nsee) {
0100:                    throw nsee;
0101:                } catch (Exception e) {
0102:                    throw HibernateUtil.processException(e);
0103:                } finally {
0104:                    closeSession(session);
0105:                }
0106:            }
0107:
0108:            public JournalTemplate remove(JournalTemplate journalTemplate)
0109:                    throws SystemException {
0110:                ModelListener listener = _getListener();
0111:
0112:                if (listener != null) {
0113:                    listener.onBeforeRemove(journalTemplate);
0114:                }
0115:
0116:                journalTemplate = removeImpl(journalTemplate);
0117:
0118:                if (listener != null) {
0119:                    listener.onAfterRemove(journalTemplate);
0120:                }
0121:
0122:                return journalTemplate;
0123:            }
0124:
0125:            protected JournalTemplate removeImpl(JournalTemplate journalTemplate)
0126:                    throws SystemException {
0127:                Session session = null;
0128:
0129:                try {
0130:                    session = openSession();
0131:
0132:                    session.delete(journalTemplate);
0133:
0134:                    session.flush();
0135:
0136:                    return journalTemplate;
0137:                } catch (Exception e) {
0138:                    throw HibernateUtil.processException(e);
0139:                } finally {
0140:                    closeSession(session);
0141:
0142:                    FinderCache.clearCache(JournalTemplate.class.getName());
0143:                }
0144:            }
0145:
0146:            public JournalTemplate update(JournalTemplate journalTemplate)
0147:                    throws SystemException {
0148:                return update(journalTemplate, false);
0149:            }
0150:
0151:            public JournalTemplate update(JournalTemplate journalTemplate,
0152:                    boolean merge) throws SystemException {
0153:                ModelListener listener = _getListener();
0154:
0155:                boolean isNew = journalTemplate.isNew();
0156:
0157:                if (listener != null) {
0158:                    if (isNew) {
0159:                        listener.onBeforeCreate(journalTemplate);
0160:                    } else {
0161:                        listener.onBeforeUpdate(journalTemplate);
0162:                    }
0163:                }
0164:
0165:                journalTemplate = updateImpl(journalTemplate, merge);
0166:
0167:                if (listener != null) {
0168:                    if (isNew) {
0169:                        listener.onAfterCreate(journalTemplate);
0170:                    } else {
0171:                        listener.onAfterUpdate(journalTemplate);
0172:                    }
0173:                }
0174:
0175:                return journalTemplate;
0176:            }
0177:
0178:            public JournalTemplate updateImpl(
0179:                    com.liferay.portlet.journal.model.JournalTemplate journalTemplate,
0180:                    boolean merge) throws SystemException {
0181:                if (Validator.isNull(journalTemplate.getUuid())) {
0182:                    String uuid = PortalUUIDUtil.generate();
0183:
0184:                    journalTemplate.setUuid(uuid);
0185:                }
0186:
0187:                Session session = null;
0188:
0189:                try {
0190:                    session = openSession();
0191:
0192:                    if (merge) {
0193:                        session.merge(journalTemplate);
0194:                    } else {
0195:                        if (journalTemplate.isNew()) {
0196:                            session.save(journalTemplate);
0197:                        }
0198:                    }
0199:
0200:                    session.flush();
0201:
0202:                    journalTemplate.setNew(false);
0203:
0204:                    return journalTemplate;
0205:                } catch (Exception e) {
0206:                    throw HibernateUtil.processException(e);
0207:                } finally {
0208:                    closeSession(session);
0209:
0210:                    FinderCache.clearCache(JournalTemplate.class.getName());
0211:                }
0212:            }
0213:
0214:            public JournalTemplate findByPrimaryKey(long id)
0215:                    throws NoSuchTemplateException, SystemException {
0216:                JournalTemplate journalTemplate = fetchByPrimaryKey(id);
0217:
0218:                if (journalTemplate == null) {
0219:                    if (_log.isWarnEnabled()) {
0220:                        _log
0221:                                .warn("No JournalTemplate exists with the primary key "
0222:                                        + id);
0223:                    }
0224:
0225:                    throw new NoSuchTemplateException(
0226:                            "No JournalTemplate exists with the primary key "
0227:                                    + id);
0228:                }
0229:
0230:                return journalTemplate;
0231:            }
0232:
0233:            public JournalTemplate fetchByPrimaryKey(long id)
0234:                    throws SystemException {
0235:                Session session = null;
0236:
0237:                try {
0238:                    session = openSession();
0239:
0240:                    return (JournalTemplate) session.get(
0241:                            JournalTemplateImpl.class, new Long(id));
0242:                } catch (Exception e) {
0243:                    throw HibernateUtil.processException(e);
0244:                } finally {
0245:                    closeSession(session);
0246:                }
0247:            }
0248:
0249:            public List findByUuid(String uuid) throws SystemException {
0250:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
0251:                String finderClassName = JournalTemplate.class.getName();
0252:                String finderMethodName = "findByUuid";
0253:                String[] finderParams = new String[] { String.class.getName() };
0254:                Object[] finderArgs = new Object[] { uuid };
0255:
0256:                Object result = null;
0257:
0258:                if (finderClassNameCacheEnabled) {
0259:                    result = FinderCache.getResult(finderClassName,
0260:                            finderMethodName, finderParams, finderArgs,
0261:                            getSessionFactory());
0262:                }
0263:
0264:                if (result == null) {
0265:                    Session session = null;
0266:
0267:                    try {
0268:                        session = openSession();
0269:
0270:                        StringMaker query = new StringMaker();
0271:
0272:                        query
0273:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0274:
0275:                        if (uuid == null) {
0276:                            query.append("uuid_ IS NULL");
0277:                        } else {
0278:                            query.append("uuid_ = ?");
0279:                        }
0280:
0281:                        query.append(" ");
0282:
0283:                        query.append("ORDER BY ");
0284:
0285:                        query.append("templateId ASC");
0286:
0287:                        Query q = session.createQuery(query.toString());
0288:
0289:                        int queryPos = 0;
0290:
0291:                        if (uuid != null) {
0292:                            q.setString(queryPos++, uuid);
0293:                        }
0294:
0295:                        List list = q.list();
0296:
0297:                        FinderCache.putResult(finderClassNameCacheEnabled,
0298:                                finderClassName, finderMethodName,
0299:                                finderParams, finderArgs, list);
0300:
0301:                        return list;
0302:                    } catch (Exception e) {
0303:                        throw HibernateUtil.processException(e);
0304:                    } finally {
0305:                        closeSession(session);
0306:                    }
0307:                } else {
0308:                    return (List) result;
0309:                }
0310:            }
0311:
0312:            public List findByUuid(String uuid, int begin, int end)
0313:                    throws SystemException {
0314:                return findByUuid(uuid, begin, end, null);
0315:            }
0316:
0317:            public List findByUuid(String uuid, int begin, int end,
0318:                    OrderByComparator obc) throws SystemException {
0319:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
0320:                String finderClassName = JournalTemplate.class.getName();
0321:                String finderMethodName = "findByUuid";
0322:                String[] finderParams = new String[] { String.class.getName(),
0323:
0324:                "java.lang.Integer", "java.lang.Integer",
0325:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0326:                Object[] finderArgs = new Object[] { uuid,
0327:
0328:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0329:
0330:                Object result = null;
0331:
0332:                if (finderClassNameCacheEnabled) {
0333:                    result = FinderCache.getResult(finderClassName,
0334:                            finderMethodName, finderParams, finderArgs,
0335:                            getSessionFactory());
0336:                }
0337:
0338:                if (result == null) {
0339:                    Session session = null;
0340:
0341:                    try {
0342:                        session = openSession();
0343:
0344:                        StringMaker query = new StringMaker();
0345:
0346:                        query
0347:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0348:
0349:                        if (uuid == null) {
0350:                            query.append("uuid_ IS NULL");
0351:                        } else {
0352:                            query.append("uuid_ = ?");
0353:                        }
0354:
0355:                        query.append(" ");
0356:
0357:                        if (obc != null) {
0358:                            query.append("ORDER BY ");
0359:                            query.append(obc.getOrderBy());
0360:                        }
0361:
0362:                        else {
0363:                            query.append("ORDER BY ");
0364:
0365:                            query.append("templateId ASC");
0366:                        }
0367:
0368:                        Query q = session.createQuery(query.toString());
0369:
0370:                        int queryPos = 0;
0371:
0372:                        if (uuid != null) {
0373:                            q.setString(queryPos++, uuid);
0374:                        }
0375:
0376:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0377:
0378:                        FinderCache.putResult(finderClassNameCacheEnabled,
0379:                                finderClassName, finderMethodName,
0380:                                finderParams, finderArgs, list);
0381:
0382:                        return list;
0383:                    } catch (Exception e) {
0384:                        throw HibernateUtil.processException(e);
0385:                    } finally {
0386:                        closeSession(session);
0387:                    }
0388:                } else {
0389:                    return (List) result;
0390:                }
0391:            }
0392:
0393:            public JournalTemplate findByUuid_First(String uuid,
0394:                    OrderByComparator obc) throws NoSuchTemplateException,
0395:                    SystemException {
0396:                List list = findByUuid(uuid, 0, 1, obc);
0397:
0398:                if (list.size() == 0) {
0399:                    StringMaker msg = new StringMaker();
0400:
0401:                    msg.append("No JournalTemplate exists with the key {");
0402:
0403:                    msg.append("uuid=" + uuid);
0404:
0405:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0406:
0407:                    throw new NoSuchTemplateException(msg.toString());
0408:                } else {
0409:                    return (JournalTemplate) list.get(0);
0410:                }
0411:            }
0412:
0413:            public JournalTemplate findByUuid_Last(String uuid,
0414:                    OrderByComparator obc) throws NoSuchTemplateException,
0415:                    SystemException {
0416:                int count = countByUuid(uuid);
0417:
0418:                List list = findByUuid(uuid, count - 1, count, obc);
0419:
0420:                if (list.size() == 0) {
0421:                    StringMaker msg = new StringMaker();
0422:
0423:                    msg.append("No JournalTemplate exists with the key {");
0424:
0425:                    msg.append("uuid=" + uuid);
0426:
0427:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0428:
0429:                    throw new NoSuchTemplateException(msg.toString());
0430:                } else {
0431:                    return (JournalTemplate) list.get(0);
0432:                }
0433:            }
0434:
0435:            public JournalTemplate[] findByUuid_PrevAndNext(long id,
0436:                    String uuid, OrderByComparator obc)
0437:                    throws NoSuchTemplateException, SystemException {
0438:                JournalTemplate journalTemplate = findByPrimaryKey(id);
0439:
0440:                int count = countByUuid(uuid);
0441:
0442:                Session session = null;
0443:
0444:                try {
0445:                    session = openSession();
0446:
0447:                    StringMaker query = new StringMaker();
0448:
0449:                    query
0450:                            .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0451:
0452:                    if (uuid == null) {
0453:                        query.append("uuid_ IS NULL");
0454:                    } else {
0455:                        query.append("uuid_ = ?");
0456:                    }
0457:
0458:                    query.append(" ");
0459:
0460:                    if (obc != null) {
0461:                        query.append("ORDER BY ");
0462:                        query.append(obc.getOrderBy());
0463:                    }
0464:
0465:                    else {
0466:                        query.append("ORDER BY ");
0467:
0468:                        query.append("templateId ASC");
0469:                    }
0470:
0471:                    Query q = session.createQuery(query.toString());
0472:
0473:                    int queryPos = 0;
0474:
0475:                    if (uuid != null) {
0476:                        q.setString(queryPos++, uuid);
0477:                    }
0478:
0479:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0480:                            journalTemplate);
0481:
0482:                    JournalTemplate[] array = new JournalTemplateImpl[3];
0483:
0484:                    array[0] = (JournalTemplate) objArray[0];
0485:                    array[1] = (JournalTemplate) objArray[1];
0486:                    array[2] = (JournalTemplate) objArray[2];
0487:
0488:                    return array;
0489:                } catch (Exception e) {
0490:                    throw HibernateUtil.processException(e);
0491:                } finally {
0492:                    closeSession(session);
0493:                }
0494:            }
0495:
0496:            public JournalTemplate findByUUID_G(String uuid, long groupId)
0497:                    throws NoSuchTemplateException, SystemException {
0498:                JournalTemplate journalTemplate = fetchByUUID_G(uuid, groupId);
0499:
0500:                if (journalTemplate == null) {
0501:                    StringMaker msg = new StringMaker();
0502:
0503:                    msg.append("No JournalTemplate exists with the key {");
0504:
0505:                    msg.append("uuid=" + uuid);
0506:
0507:                    msg.append(", ");
0508:                    msg.append("groupId=" + groupId);
0509:
0510:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0511:
0512:                    if (_log.isWarnEnabled()) {
0513:                        _log.warn(msg.toString());
0514:                    }
0515:
0516:                    throw new NoSuchTemplateException(msg.toString());
0517:                }
0518:
0519:                return journalTemplate;
0520:            }
0521:
0522:            public JournalTemplate fetchByUUID_G(String uuid, long groupId)
0523:                    throws SystemException {
0524:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
0525:                String finderClassName = JournalTemplate.class.getName();
0526:                String finderMethodName = "fetchByUUID_G";
0527:                String[] finderParams = new String[] { String.class.getName(),
0528:                        Long.class.getName() };
0529:                Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
0530:
0531:                Object result = null;
0532:
0533:                if (finderClassNameCacheEnabled) {
0534:                    result = FinderCache.getResult(finderClassName,
0535:                            finderMethodName, finderParams, finderArgs,
0536:                            getSessionFactory());
0537:                }
0538:
0539:                if (result == null) {
0540:                    Session session = null;
0541:
0542:                    try {
0543:                        session = openSession();
0544:
0545:                        StringMaker query = new StringMaker();
0546:
0547:                        query
0548:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0549:
0550:                        if (uuid == null) {
0551:                            query.append("uuid_ IS NULL");
0552:                        } else {
0553:                            query.append("uuid_ = ?");
0554:                        }
0555:
0556:                        query.append(" AND ");
0557:
0558:                        query.append("groupId = ?");
0559:
0560:                        query.append(" ");
0561:
0562:                        query.append("ORDER BY ");
0563:
0564:                        query.append("templateId ASC");
0565:
0566:                        Query q = session.createQuery(query.toString());
0567:
0568:                        int queryPos = 0;
0569:
0570:                        if (uuid != null) {
0571:                            q.setString(queryPos++, uuid);
0572:                        }
0573:
0574:                        q.setLong(queryPos++, groupId);
0575:
0576:                        List list = q.list();
0577:
0578:                        FinderCache.putResult(finderClassNameCacheEnabled,
0579:                                finderClassName, finderMethodName,
0580:                                finderParams, finderArgs, list);
0581:
0582:                        if (list.size() == 0) {
0583:                            return null;
0584:                        } else {
0585:                            return (JournalTemplate) list.get(0);
0586:                        }
0587:                    } catch (Exception e) {
0588:                        throw HibernateUtil.processException(e);
0589:                    } finally {
0590:                        closeSession(session);
0591:                    }
0592:                } else {
0593:                    List list = (List) result;
0594:
0595:                    if (list.size() == 0) {
0596:                        return null;
0597:                    } else {
0598:                        return (JournalTemplate) list.get(0);
0599:                    }
0600:                }
0601:            }
0602:
0603:            public List findByGroupId(long groupId) throws SystemException {
0604:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
0605:                String finderClassName = JournalTemplate.class.getName();
0606:                String finderMethodName = "findByGroupId";
0607:                String[] finderParams = new String[] { Long.class.getName() };
0608:                Object[] finderArgs = new Object[] { new Long(groupId) };
0609:
0610:                Object result = null;
0611:
0612:                if (finderClassNameCacheEnabled) {
0613:                    result = FinderCache.getResult(finderClassName,
0614:                            finderMethodName, finderParams, finderArgs,
0615:                            getSessionFactory());
0616:                }
0617:
0618:                if (result == null) {
0619:                    Session session = null;
0620:
0621:                    try {
0622:                        session = openSession();
0623:
0624:                        StringMaker query = new StringMaker();
0625:
0626:                        query
0627:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0628:
0629:                        query.append("groupId = ?");
0630:
0631:                        query.append(" ");
0632:
0633:                        query.append("ORDER BY ");
0634:
0635:                        query.append("templateId ASC");
0636:
0637:                        Query q = session.createQuery(query.toString());
0638:
0639:                        int queryPos = 0;
0640:
0641:                        q.setLong(queryPos++, groupId);
0642:
0643:                        List list = q.list();
0644:
0645:                        FinderCache.putResult(finderClassNameCacheEnabled,
0646:                                finderClassName, finderMethodName,
0647:                                finderParams, finderArgs, list);
0648:
0649:                        return list;
0650:                    } catch (Exception e) {
0651:                        throw HibernateUtil.processException(e);
0652:                    } finally {
0653:                        closeSession(session);
0654:                    }
0655:                } else {
0656:                    return (List) result;
0657:                }
0658:            }
0659:
0660:            public List findByGroupId(long groupId, int begin, int end)
0661:                    throws SystemException {
0662:                return findByGroupId(groupId, begin, end, null);
0663:            }
0664:
0665:            public List findByGroupId(long groupId, int begin, int end,
0666:                    OrderByComparator obc) throws SystemException {
0667:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
0668:                String finderClassName = JournalTemplate.class.getName();
0669:                String finderMethodName = "findByGroupId";
0670:                String[] finderParams = new String[] { Long.class.getName(),
0671:
0672:                "java.lang.Integer", "java.lang.Integer",
0673:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0674:                Object[] finderArgs = new Object[] { new Long(groupId),
0675:
0676:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0677:
0678:                Object result = null;
0679:
0680:                if (finderClassNameCacheEnabled) {
0681:                    result = FinderCache.getResult(finderClassName,
0682:                            finderMethodName, finderParams, finderArgs,
0683:                            getSessionFactory());
0684:                }
0685:
0686:                if (result == null) {
0687:                    Session session = null;
0688:
0689:                    try {
0690:                        session = openSession();
0691:
0692:                        StringMaker query = new StringMaker();
0693:
0694:                        query
0695:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0696:
0697:                        query.append("groupId = ?");
0698:
0699:                        query.append(" ");
0700:
0701:                        if (obc != null) {
0702:                            query.append("ORDER BY ");
0703:                            query.append(obc.getOrderBy());
0704:                        }
0705:
0706:                        else {
0707:                            query.append("ORDER BY ");
0708:
0709:                            query.append("templateId ASC");
0710:                        }
0711:
0712:                        Query q = session.createQuery(query.toString());
0713:
0714:                        int queryPos = 0;
0715:
0716:                        q.setLong(queryPos++, groupId);
0717:
0718:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0719:
0720:                        FinderCache.putResult(finderClassNameCacheEnabled,
0721:                                finderClassName, finderMethodName,
0722:                                finderParams, finderArgs, list);
0723:
0724:                        return list;
0725:                    } catch (Exception e) {
0726:                        throw HibernateUtil.processException(e);
0727:                    } finally {
0728:                        closeSession(session);
0729:                    }
0730:                } else {
0731:                    return (List) result;
0732:                }
0733:            }
0734:
0735:            public JournalTemplate findByGroupId_First(long groupId,
0736:                    OrderByComparator obc) throws NoSuchTemplateException,
0737:                    SystemException {
0738:                List list = findByGroupId(groupId, 0, 1, obc);
0739:
0740:                if (list.size() == 0) {
0741:                    StringMaker msg = new StringMaker();
0742:
0743:                    msg.append("No JournalTemplate exists with the key {");
0744:
0745:                    msg.append("groupId=" + groupId);
0746:
0747:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0748:
0749:                    throw new NoSuchTemplateException(msg.toString());
0750:                } else {
0751:                    return (JournalTemplate) list.get(0);
0752:                }
0753:            }
0754:
0755:            public JournalTemplate findByGroupId_Last(long groupId,
0756:                    OrderByComparator obc) throws NoSuchTemplateException,
0757:                    SystemException {
0758:                int count = countByGroupId(groupId);
0759:
0760:                List list = findByGroupId(groupId, count - 1, count, obc);
0761:
0762:                if (list.size() == 0) {
0763:                    StringMaker msg = new StringMaker();
0764:
0765:                    msg.append("No JournalTemplate exists with the key {");
0766:
0767:                    msg.append("groupId=" + groupId);
0768:
0769:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0770:
0771:                    throw new NoSuchTemplateException(msg.toString());
0772:                } else {
0773:                    return (JournalTemplate) list.get(0);
0774:                }
0775:            }
0776:
0777:            public JournalTemplate[] findByGroupId_PrevAndNext(long id,
0778:                    long groupId, OrderByComparator obc)
0779:                    throws NoSuchTemplateException, SystemException {
0780:                JournalTemplate journalTemplate = findByPrimaryKey(id);
0781:
0782:                int count = countByGroupId(groupId);
0783:
0784:                Session session = null;
0785:
0786:                try {
0787:                    session = openSession();
0788:
0789:                    StringMaker query = new StringMaker();
0790:
0791:                    query
0792:                            .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0793:
0794:                    query.append("groupId = ?");
0795:
0796:                    query.append(" ");
0797:
0798:                    if (obc != null) {
0799:                        query.append("ORDER BY ");
0800:                        query.append(obc.getOrderBy());
0801:                    }
0802:
0803:                    else {
0804:                        query.append("ORDER BY ");
0805:
0806:                        query.append("templateId ASC");
0807:                    }
0808:
0809:                    Query q = session.createQuery(query.toString());
0810:
0811:                    int queryPos = 0;
0812:
0813:                    q.setLong(queryPos++, groupId);
0814:
0815:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0816:                            journalTemplate);
0817:
0818:                    JournalTemplate[] array = new JournalTemplateImpl[3];
0819:
0820:                    array[0] = (JournalTemplate) objArray[0];
0821:                    array[1] = (JournalTemplate) objArray[1];
0822:                    array[2] = (JournalTemplate) objArray[2];
0823:
0824:                    return array;
0825:                } catch (Exception e) {
0826:                    throw HibernateUtil.processException(e);
0827:                } finally {
0828:                    closeSession(session);
0829:                }
0830:            }
0831:
0832:            public List findByTemplateId(String templateId)
0833:                    throws SystemException {
0834:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
0835:                String finderClassName = JournalTemplate.class.getName();
0836:                String finderMethodName = "findByTemplateId";
0837:                String[] finderParams = new String[] { String.class.getName() };
0838:                Object[] finderArgs = new Object[] { templateId };
0839:
0840:                Object result = null;
0841:
0842:                if (finderClassNameCacheEnabled) {
0843:                    result = FinderCache.getResult(finderClassName,
0844:                            finderMethodName, finderParams, finderArgs,
0845:                            getSessionFactory());
0846:                }
0847:
0848:                if (result == null) {
0849:                    Session session = null;
0850:
0851:                    try {
0852:                        session = openSession();
0853:
0854:                        StringMaker query = new StringMaker();
0855:
0856:                        query
0857:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0858:
0859:                        if (templateId == null) {
0860:                            query.append("templateId IS NULL");
0861:                        } else {
0862:                            query.append("templateId = ?");
0863:                        }
0864:
0865:                        query.append(" ");
0866:
0867:                        query.append("ORDER BY ");
0868:
0869:                        query.append("templateId ASC");
0870:
0871:                        Query q = session.createQuery(query.toString());
0872:
0873:                        int queryPos = 0;
0874:
0875:                        if (templateId != null) {
0876:                            q.setString(queryPos++, templateId);
0877:                        }
0878:
0879:                        List list = q.list();
0880:
0881:                        FinderCache.putResult(finderClassNameCacheEnabled,
0882:                                finderClassName, finderMethodName,
0883:                                finderParams, finderArgs, list);
0884:
0885:                        return list;
0886:                    } catch (Exception e) {
0887:                        throw HibernateUtil.processException(e);
0888:                    } finally {
0889:                        closeSession(session);
0890:                    }
0891:                } else {
0892:                    return (List) result;
0893:                }
0894:            }
0895:
0896:            public List findByTemplateId(String templateId, int begin, int end)
0897:                    throws SystemException {
0898:                return findByTemplateId(templateId, begin, end, null);
0899:            }
0900:
0901:            public List findByTemplateId(String templateId, int begin, int end,
0902:                    OrderByComparator obc) throws SystemException {
0903:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
0904:                String finderClassName = JournalTemplate.class.getName();
0905:                String finderMethodName = "findByTemplateId";
0906:                String[] finderParams = new String[] { String.class.getName(),
0907:
0908:                "java.lang.Integer", "java.lang.Integer",
0909:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0910:                Object[] finderArgs = new Object[] { templateId,
0911:
0912:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0913:
0914:                Object result = null;
0915:
0916:                if (finderClassNameCacheEnabled) {
0917:                    result = FinderCache.getResult(finderClassName,
0918:                            finderMethodName, finderParams, finderArgs,
0919:                            getSessionFactory());
0920:                }
0921:
0922:                if (result == null) {
0923:                    Session session = null;
0924:
0925:                    try {
0926:                        session = openSession();
0927:
0928:                        StringMaker query = new StringMaker();
0929:
0930:                        query
0931:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
0932:
0933:                        if (templateId == null) {
0934:                            query.append("templateId IS NULL");
0935:                        } else {
0936:                            query.append("templateId = ?");
0937:                        }
0938:
0939:                        query.append(" ");
0940:
0941:                        if (obc != null) {
0942:                            query.append("ORDER BY ");
0943:                            query.append(obc.getOrderBy());
0944:                        }
0945:
0946:                        else {
0947:                            query.append("ORDER BY ");
0948:
0949:                            query.append("templateId ASC");
0950:                        }
0951:
0952:                        Query q = session.createQuery(query.toString());
0953:
0954:                        int queryPos = 0;
0955:
0956:                        if (templateId != null) {
0957:                            q.setString(queryPos++, templateId);
0958:                        }
0959:
0960:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0961:
0962:                        FinderCache.putResult(finderClassNameCacheEnabled,
0963:                                finderClassName, finderMethodName,
0964:                                finderParams, finderArgs, list);
0965:
0966:                        return list;
0967:                    } catch (Exception e) {
0968:                        throw HibernateUtil.processException(e);
0969:                    } finally {
0970:                        closeSession(session);
0971:                    }
0972:                } else {
0973:                    return (List) result;
0974:                }
0975:            }
0976:
0977:            public JournalTemplate findByTemplateId_First(String templateId,
0978:                    OrderByComparator obc) throws NoSuchTemplateException,
0979:                    SystemException {
0980:                List list = findByTemplateId(templateId, 0, 1, obc);
0981:
0982:                if (list.size() == 0) {
0983:                    StringMaker msg = new StringMaker();
0984:
0985:                    msg.append("No JournalTemplate exists with the key {");
0986:
0987:                    msg.append("templateId=" + templateId);
0988:
0989:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0990:
0991:                    throw new NoSuchTemplateException(msg.toString());
0992:                } else {
0993:                    return (JournalTemplate) list.get(0);
0994:                }
0995:            }
0996:
0997:            public JournalTemplate findByTemplateId_Last(String templateId,
0998:                    OrderByComparator obc) throws NoSuchTemplateException,
0999:                    SystemException {
1000:                int count = countByTemplateId(templateId);
1001:
1002:                List list = findByTemplateId(templateId, count - 1, count, obc);
1003:
1004:                if (list.size() == 0) {
1005:                    StringMaker msg = new StringMaker();
1006:
1007:                    msg.append("No JournalTemplate exists with the key {");
1008:
1009:                    msg.append("templateId=" + templateId);
1010:
1011:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1012:
1013:                    throw new NoSuchTemplateException(msg.toString());
1014:                } else {
1015:                    return (JournalTemplate) list.get(0);
1016:                }
1017:            }
1018:
1019:            public JournalTemplate[] findByTemplateId_PrevAndNext(long id,
1020:                    String templateId, OrderByComparator obc)
1021:                    throws NoSuchTemplateException, SystemException {
1022:                JournalTemplate journalTemplate = findByPrimaryKey(id);
1023:
1024:                int count = countByTemplateId(templateId);
1025:
1026:                Session session = null;
1027:
1028:                try {
1029:                    session = openSession();
1030:
1031:                    StringMaker query = new StringMaker();
1032:
1033:                    query
1034:                            .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1035:
1036:                    if (templateId == null) {
1037:                        query.append("templateId IS NULL");
1038:                    } else {
1039:                        query.append("templateId = ?");
1040:                    }
1041:
1042:                    query.append(" ");
1043:
1044:                    if (obc != null) {
1045:                        query.append("ORDER BY ");
1046:                        query.append(obc.getOrderBy());
1047:                    }
1048:
1049:                    else {
1050:                        query.append("ORDER BY ");
1051:
1052:                        query.append("templateId ASC");
1053:                    }
1054:
1055:                    Query q = session.createQuery(query.toString());
1056:
1057:                    int queryPos = 0;
1058:
1059:                    if (templateId != null) {
1060:                        q.setString(queryPos++, templateId);
1061:                    }
1062:
1063:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1064:                            journalTemplate);
1065:
1066:                    JournalTemplate[] array = new JournalTemplateImpl[3];
1067:
1068:                    array[0] = (JournalTemplate) objArray[0];
1069:                    array[1] = (JournalTemplate) objArray[1];
1070:                    array[2] = (JournalTemplate) objArray[2];
1071:
1072:                    return array;
1073:                } catch (Exception e) {
1074:                    throw HibernateUtil.processException(e);
1075:                } finally {
1076:                    closeSession(session);
1077:                }
1078:            }
1079:
1080:            public JournalTemplate findBySmallImageId(long smallImageId)
1081:                    throws NoSuchTemplateException, SystemException {
1082:                JournalTemplate journalTemplate = fetchBySmallImageId(smallImageId);
1083:
1084:                if (journalTemplate == null) {
1085:                    StringMaker msg = new StringMaker();
1086:
1087:                    msg.append("No JournalTemplate exists with the key {");
1088:
1089:                    msg.append("smallImageId=" + smallImageId);
1090:
1091:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1092:
1093:                    if (_log.isWarnEnabled()) {
1094:                        _log.warn(msg.toString());
1095:                    }
1096:
1097:                    throw new NoSuchTemplateException(msg.toString());
1098:                }
1099:
1100:                return journalTemplate;
1101:            }
1102:
1103:            public JournalTemplate fetchBySmallImageId(long smallImageId)
1104:                    throws SystemException {
1105:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1106:                String finderClassName = JournalTemplate.class.getName();
1107:                String finderMethodName = "fetchBySmallImageId";
1108:                String[] finderParams = new String[] { Long.class.getName() };
1109:                Object[] finderArgs = new Object[] { new Long(smallImageId) };
1110:
1111:                Object result = null;
1112:
1113:                if (finderClassNameCacheEnabled) {
1114:                    result = FinderCache.getResult(finderClassName,
1115:                            finderMethodName, finderParams, finderArgs,
1116:                            getSessionFactory());
1117:                }
1118:
1119:                if (result == null) {
1120:                    Session session = null;
1121:
1122:                    try {
1123:                        session = openSession();
1124:
1125:                        StringMaker query = new StringMaker();
1126:
1127:                        query
1128:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1129:
1130:                        query.append("smallImageId = ?");
1131:
1132:                        query.append(" ");
1133:
1134:                        query.append("ORDER BY ");
1135:
1136:                        query.append("templateId ASC");
1137:
1138:                        Query q = session.createQuery(query.toString());
1139:
1140:                        int queryPos = 0;
1141:
1142:                        q.setLong(queryPos++, smallImageId);
1143:
1144:                        List list = q.list();
1145:
1146:                        FinderCache.putResult(finderClassNameCacheEnabled,
1147:                                finderClassName, finderMethodName,
1148:                                finderParams, finderArgs, list);
1149:
1150:                        if (list.size() == 0) {
1151:                            return null;
1152:                        } else {
1153:                            return (JournalTemplate) list.get(0);
1154:                        }
1155:                    } catch (Exception e) {
1156:                        throw HibernateUtil.processException(e);
1157:                    } finally {
1158:                        closeSession(session);
1159:                    }
1160:                } else {
1161:                    List list = (List) result;
1162:
1163:                    if (list.size() == 0) {
1164:                        return null;
1165:                    } else {
1166:                        return (JournalTemplate) list.get(0);
1167:                    }
1168:                }
1169:            }
1170:
1171:            public JournalTemplate findByG_T(long groupId, String templateId)
1172:                    throws NoSuchTemplateException, SystemException {
1173:                JournalTemplate journalTemplate = fetchByG_T(groupId,
1174:                        templateId);
1175:
1176:                if (journalTemplate == null) {
1177:                    StringMaker msg = new StringMaker();
1178:
1179:                    msg.append("No JournalTemplate exists with the key {");
1180:
1181:                    msg.append("groupId=" + groupId);
1182:
1183:                    msg.append(", ");
1184:                    msg.append("templateId=" + templateId);
1185:
1186:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1187:
1188:                    if (_log.isWarnEnabled()) {
1189:                        _log.warn(msg.toString());
1190:                    }
1191:
1192:                    throw new NoSuchTemplateException(msg.toString());
1193:                }
1194:
1195:                return journalTemplate;
1196:            }
1197:
1198:            public JournalTemplate fetchByG_T(long groupId, String templateId)
1199:                    throws SystemException {
1200:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1201:                String finderClassName = JournalTemplate.class.getName();
1202:                String finderMethodName = "fetchByG_T";
1203:                String[] finderParams = new String[] { Long.class.getName(),
1204:                        String.class.getName() };
1205:                Object[] finderArgs = new Object[] { new Long(groupId),
1206:                        templateId };
1207:
1208:                Object result = null;
1209:
1210:                if (finderClassNameCacheEnabled) {
1211:                    result = FinderCache.getResult(finderClassName,
1212:                            finderMethodName, finderParams, finderArgs,
1213:                            getSessionFactory());
1214:                }
1215:
1216:                if (result == null) {
1217:                    Session session = null;
1218:
1219:                    try {
1220:                        session = openSession();
1221:
1222:                        StringMaker query = new StringMaker();
1223:
1224:                        query
1225:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1226:
1227:                        query.append("groupId = ?");
1228:
1229:                        query.append(" AND ");
1230:
1231:                        if (templateId == null) {
1232:                            query.append("templateId IS NULL");
1233:                        } else {
1234:                            query.append("templateId = ?");
1235:                        }
1236:
1237:                        query.append(" ");
1238:
1239:                        query.append("ORDER BY ");
1240:
1241:                        query.append("templateId ASC");
1242:
1243:                        Query q = session.createQuery(query.toString());
1244:
1245:                        int queryPos = 0;
1246:
1247:                        q.setLong(queryPos++, groupId);
1248:
1249:                        if (templateId != null) {
1250:                            q.setString(queryPos++, templateId);
1251:                        }
1252:
1253:                        List list = q.list();
1254:
1255:                        FinderCache.putResult(finderClassNameCacheEnabled,
1256:                                finderClassName, finderMethodName,
1257:                                finderParams, finderArgs, list);
1258:
1259:                        if (list.size() == 0) {
1260:                            return null;
1261:                        } else {
1262:                            return (JournalTemplate) list.get(0);
1263:                        }
1264:                    } catch (Exception e) {
1265:                        throw HibernateUtil.processException(e);
1266:                    } finally {
1267:                        closeSession(session);
1268:                    }
1269:                } else {
1270:                    List list = (List) result;
1271:
1272:                    if (list.size() == 0) {
1273:                        return null;
1274:                    } else {
1275:                        return (JournalTemplate) list.get(0);
1276:                    }
1277:                }
1278:            }
1279:
1280:            public List findByG_S(long groupId, String structureId)
1281:                    throws SystemException {
1282:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1283:                String finderClassName = JournalTemplate.class.getName();
1284:                String finderMethodName = "findByG_S";
1285:                String[] finderParams = new String[] { Long.class.getName(),
1286:                        String.class.getName() };
1287:                Object[] finderArgs = new Object[] { new Long(groupId),
1288:                        structureId };
1289:
1290:                Object result = null;
1291:
1292:                if (finderClassNameCacheEnabled) {
1293:                    result = FinderCache.getResult(finderClassName,
1294:                            finderMethodName, finderParams, finderArgs,
1295:                            getSessionFactory());
1296:                }
1297:
1298:                if (result == null) {
1299:                    Session session = null;
1300:
1301:                    try {
1302:                        session = openSession();
1303:
1304:                        StringMaker query = new StringMaker();
1305:
1306:                        query
1307:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1308:
1309:                        query.append("groupId = ?");
1310:
1311:                        query.append(" AND ");
1312:
1313:                        if (structureId == null) {
1314:                            query.append("structureId IS NULL");
1315:                        } else {
1316:                            query.append("structureId = ?");
1317:                        }
1318:
1319:                        query.append(" ");
1320:
1321:                        query.append("ORDER BY ");
1322:
1323:                        query.append("templateId ASC");
1324:
1325:                        Query q = session.createQuery(query.toString());
1326:
1327:                        int queryPos = 0;
1328:
1329:                        q.setLong(queryPos++, groupId);
1330:
1331:                        if (structureId != null) {
1332:                            q.setString(queryPos++, structureId);
1333:                        }
1334:
1335:                        List list = q.list();
1336:
1337:                        FinderCache.putResult(finderClassNameCacheEnabled,
1338:                                finderClassName, finderMethodName,
1339:                                finderParams, finderArgs, list);
1340:
1341:                        return list;
1342:                    } catch (Exception e) {
1343:                        throw HibernateUtil.processException(e);
1344:                    } finally {
1345:                        closeSession(session);
1346:                    }
1347:                } else {
1348:                    return (List) result;
1349:                }
1350:            }
1351:
1352:            public List findByG_S(long groupId, String structureId, int begin,
1353:                    int end) throws SystemException {
1354:                return findByG_S(groupId, structureId, begin, end, null);
1355:            }
1356:
1357:            public List findByG_S(long groupId, String structureId, int begin,
1358:                    int end, OrderByComparator obc) throws SystemException {
1359:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1360:                String finderClassName = JournalTemplate.class.getName();
1361:                String finderMethodName = "findByG_S";
1362:                String[] finderParams = new String[] { Long.class.getName(),
1363:                        String.class.getName(),
1364:
1365:                        "java.lang.Integer", "java.lang.Integer",
1366:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1367:                Object[] finderArgs = new Object[] { new Long(groupId),
1368:
1369:                structureId,
1370:
1371:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
1372:
1373:                Object result = null;
1374:
1375:                if (finderClassNameCacheEnabled) {
1376:                    result = FinderCache.getResult(finderClassName,
1377:                            finderMethodName, finderParams, finderArgs,
1378:                            getSessionFactory());
1379:                }
1380:
1381:                if (result == null) {
1382:                    Session session = null;
1383:
1384:                    try {
1385:                        session = openSession();
1386:
1387:                        StringMaker query = new StringMaker();
1388:
1389:                        query
1390:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1391:
1392:                        query.append("groupId = ?");
1393:
1394:                        query.append(" AND ");
1395:
1396:                        if (structureId == null) {
1397:                            query.append("structureId IS NULL");
1398:                        } else {
1399:                            query.append("structureId = ?");
1400:                        }
1401:
1402:                        query.append(" ");
1403:
1404:                        if (obc != null) {
1405:                            query.append("ORDER BY ");
1406:                            query.append(obc.getOrderBy());
1407:                        }
1408:
1409:                        else {
1410:                            query.append("ORDER BY ");
1411:
1412:                            query.append("templateId ASC");
1413:                        }
1414:
1415:                        Query q = session.createQuery(query.toString());
1416:
1417:                        int queryPos = 0;
1418:
1419:                        q.setLong(queryPos++, groupId);
1420:
1421:                        if (structureId != null) {
1422:                            q.setString(queryPos++, structureId);
1423:                        }
1424:
1425:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1426:
1427:                        FinderCache.putResult(finderClassNameCacheEnabled,
1428:                                finderClassName, finderMethodName,
1429:                                finderParams, finderArgs, list);
1430:
1431:                        return list;
1432:                    } catch (Exception e) {
1433:                        throw HibernateUtil.processException(e);
1434:                    } finally {
1435:                        closeSession(session);
1436:                    }
1437:                } else {
1438:                    return (List) result;
1439:                }
1440:            }
1441:
1442:            public JournalTemplate findByG_S_First(long groupId,
1443:                    String structureId, OrderByComparator obc)
1444:                    throws NoSuchTemplateException, SystemException {
1445:                List list = findByG_S(groupId, structureId, 0, 1, obc);
1446:
1447:                if (list.size() == 0) {
1448:                    StringMaker msg = new StringMaker();
1449:
1450:                    msg.append("No JournalTemplate exists with the key {");
1451:
1452:                    msg.append("groupId=" + groupId);
1453:
1454:                    msg.append(", ");
1455:                    msg.append("structureId=" + structureId);
1456:
1457:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1458:
1459:                    throw new NoSuchTemplateException(msg.toString());
1460:                } else {
1461:                    return (JournalTemplate) list.get(0);
1462:                }
1463:            }
1464:
1465:            public JournalTemplate findByG_S_Last(long groupId,
1466:                    String structureId, OrderByComparator obc)
1467:                    throws NoSuchTemplateException, SystemException {
1468:                int count = countByG_S(groupId, structureId);
1469:
1470:                List list = findByG_S(groupId, structureId, count - 1, count,
1471:                        obc);
1472:
1473:                if (list.size() == 0) {
1474:                    StringMaker msg = new StringMaker();
1475:
1476:                    msg.append("No JournalTemplate exists with the key {");
1477:
1478:                    msg.append("groupId=" + groupId);
1479:
1480:                    msg.append(", ");
1481:                    msg.append("structureId=" + structureId);
1482:
1483:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1484:
1485:                    throw new NoSuchTemplateException(msg.toString());
1486:                } else {
1487:                    return (JournalTemplate) list.get(0);
1488:                }
1489:            }
1490:
1491:            public JournalTemplate[] findByG_S_PrevAndNext(long id,
1492:                    long groupId, String structureId, OrderByComparator obc)
1493:                    throws NoSuchTemplateException, SystemException {
1494:                JournalTemplate journalTemplate = findByPrimaryKey(id);
1495:
1496:                int count = countByG_S(groupId, structureId);
1497:
1498:                Session session = null;
1499:
1500:                try {
1501:                    session = openSession();
1502:
1503:                    StringMaker query = new StringMaker();
1504:
1505:                    query
1506:                            .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1507:
1508:                    query.append("groupId = ?");
1509:
1510:                    query.append(" AND ");
1511:
1512:                    if (structureId == null) {
1513:                        query.append("structureId IS NULL");
1514:                    } else {
1515:                        query.append("structureId = ?");
1516:                    }
1517:
1518:                    query.append(" ");
1519:
1520:                    if (obc != null) {
1521:                        query.append("ORDER BY ");
1522:                        query.append(obc.getOrderBy());
1523:                    }
1524:
1525:                    else {
1526:                        query.append("ORDER BY ");
1527:
1528:                        query.append("templateId ASC");
1529:                    }
1530:
1531:                    Query q = session.createQuery(query.toString());
1532:
1533:                    int queryPos = 0;
1534:
1535:                    q.setLong(queryPos++, groupId);
1536:
1537:                    if (structureId != null) {
1538:                        q.setString(queryPos++, structureId);
1539:                    }
1540:
1541:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1542:                            journalTemplate);
1543:
1544:                    JournalTemplate[] array = new JournalTemplateImpl[3];
1545:
1546:                    array[0] = (JournalTemplate) objArray[0];
1547:                    array[1] = (JournalTemplate) objArray[1];
1548:                    array[2] = (JournalTemplate) objArray[2];
1549:
1550:                    return array;
1551:                } catch (Exception e) {
1552:                    throw HibernateUtil.processException(e);
1553:                } finally {
1554:                    closeSession(session);
1555:                }
1556:            }
1557:
1558:            public List findWithDynamicQuery(
1559:                    DynamicQueryInitializer queryInitializer)
1560:                    throws SystemException {
1561:                Session session = null;
1562:
1563:                try {
1564:                    session = openSession();
1565:
1566:                    DynamicQuery query = queryInitializer.initialize(session);
1567:
1568:                    return query.list();
1569:                } catch (Exception e) {
1570:                    throw HibernateUtil.processException(e);
1571:                } finally {
1572:                    closeSession(session);
1573:                }
1574:            }
1575:
1576:            public List findWithDynamicQuery(
1577:                    DynamicQueryInitializer queryInitializer, int begin, int end)
1578:                    throws SystemException {
1579:                Session session = null;
1580:
1581:                try {
1582:                    session = openSession();
1583:
1584:                    DynamicQuery query = queryInitializer.initialize(session);
1585:
1586:                    query.setLimit(begin, end);
1587:
1588:                    return query.list();
1589:                } catch (Exception e) {
1590:                    throw HibernateUtil.processException(e);
1591:                } finally {
1592:                    closeSession(session);
1593:                }
1594:            }
1595:
1596:            public List findAll() throws SystemException {
1597:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1598:            }
1599:
1600:            public List findAll(int begin, int end) throws SystemException {
1601:                return findAll(begin, end, null);
1602:            }
1603:
1604:            public List findAll(int begin, int end, OrderByComparator obc)
1605:                    throws SystemException {
1606:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1607:                String finderClassName = JournalTemplate.class.getName();
1608:                String finderMethodName = "findAll";
1609:                String[] finderParams = new String[] { "java.lang.Integer",
1610:                        "java.lang.Integer",
1611:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1612:                Object[] finderArgs = new Object[] { String.valueOf(begin),
1613:                        String.valueOf(end), String.valueOf(obc) };
1614:
1615:                Object result = null;
1616:
1617:                if (finderClassNameCacheEnabled) {
1618:                    result = FinderCache.getResult(finderClassName,
1619:                            finderMethodName, finderParams, finderArgs,
1620:                            getSessionFactory());
1621:                }
1622:
1623:                if (result == null) {
1624:                    Session session = null;
1625:
1626:                    try {
1627:                        session = openSession();
1628:
1629:                        StringMaker query = new StringMaker();
1630:
1631:                        query
1632:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate ");
1633:
1634:                        if (obc != null) {
1635:                            query.append("ORDER BY ");
1636:                            query.append(obc.getOrderBy());
1637:                        }
1638:
1639:                        else {
1640:                            query.append("ORDER BY ");
1641:
1642:                            query.append("templateId ASC");
1643:                        }
1644:
1645:                        Query q = session.createQuery(query.toString());
1646:
1647:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1648:
1649:                        if (obc == null) {
1650:                            Collections.sort(list);
1651:                        }
1652:
1653:                        FinderCache.putResult(finderClassNameCacheEnabled,
1654:                                finderClassName, finderMethodName,
1655:                                finderParams, finderArgs, list);
1656:
1657:                        return list;
1658:                    } catch (Exception e) {
1659:                        throw HibernateUtil.processException(e);
1660:                    } finally {
1661:                        closeSession(session);
1662:                    }
1663:                } else {
1664:                    return (List) result;
1665:                }
1666:            }
1667:
1668:            public void removeByUuid(String uuid) throws SystemException {
1669:                Iterator itr = findByUuid(uuid).iterator();
1670:
1671:                while (itr.hasNext()) {
1672:                    JournalTemplate journalTemplate = (JournalTemplate) itr
1673:                            .next();
1674:
1675:                    remove(journalTemplate);
1676:                }
1677:            }
1678:
1679:            public void removeByUUID_G(String uuid, long groupId)
1680:                    throws NoSuchTemplateException, SystemException {
1681:                JournalTemplate journalTemplate = findByUUID_G(uuid, groupId);
1682:
1683:                remove(journalTemplate);
1684:            }
1685:
1686:            public void removeByGroupId(long groupId) throws SystemException {
1687:                Iterator itr = findByGroupId(groupId).iterator();
1688:
1689:                while (itr.hasNext()) {
1690:                    JournalTemplate journalTemplate = (JournalTemplate) itr
1691:                            .next();
1692:
1693:                    remove(journalTemplate);
1694:                }
1695:            }
1696:
1697:            public void removeByTemplateId(String templateId)
1698:                    throws SystemException {
1699:                Iterator itr = findByTemplateId(templateId).iterator();
1700:
1701:                while (itr.hasNext()) {
1702:                    JournalTemplate journalTemplate = (JournalTemplate) itr
1703:                            .next();
1704:
1705:                    remove(journalTemplate);
1706:                }
1707:            }
1708:
1709:            public void removeBySmallImageId(long smallImageId)
1710:                    throws NoSuchTemplateException, SystemException {
1711:                JournalTemplate journalTemplate = findBySmallImageId(smallImageId);
1712:
1713:                remove(journalTemplate);
1714:            }
1715:
1716:            public void removeByG_T(long groupId, String templateId)
1717:                    throws NoSuchTemplateException, SystemException {
1718:                JournalTemplate journalTemplate = findByG_T(groupId, templateId);
1719:
1720:                remove(journalTemplate);
1721:            }
1722:
1723:            public void removeByG_S(long groupId, String structureId)
1724:                    throws SystemException {
1725:                Iterator itr = findByG_S(groupId, structureId).iterator();
1726:
1727:                while (itr.hasNext()) {
1728:                    JournalTemplate journalTemplate = (JournalTemplate) itr
1729:                            .next();
1730:
1731:                    remove(journalTemplate);
1732:                }
1733:            }
1734:
1735:            public void removeAll() throws SystemException {
1736:                Iterator itr = findAll().iterator();
1737:
1738:                while (itr.hasNext()) {
1739:                    remove((JournalTemplate) itr.next());
1740:                }
1741:            }
1742:
1743:            public int countByUuid(String uuid) throws SystemException {
1744:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1745:                String finderClassName = JournalTemplate.class.getName();
1746:                String finderMethodName = "countByUuid";
1747:                String[] finderParams = new String[] { String.class.getName() };
1748:                Object[] finderArgs = new Object[] { uuid };
1749:
1750:                Object result = null;
1751:
1752:                if (finderClassNameCacheEnabled) {
1753:                    result = FinderCache.getResult(finderClassName,
1754:                            finderMethodName, finderParams, finderArgs,
1755:                            getSessionFactory());
1756:                }
1757:
1758:                if (result == null) {
1759:                    Session session = null;
1760:
1761:                    try {
1762:                        session = openSession();
1763:
1764:                        StringMaker query = new StringMaker();
1765:
1766:                        query.append("SELECT COUNT(*) ");
1767:                        query
1768:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1769:
1770:                        if (uuid == null) {
1771:                            query.append("uuid_ IS NULL");
1772:                        } else {
1773:                            query.append("uuid_ = ?");
1774:                        }
1775:
1776:                        query.append(" ");
1777:
1778:                        Query q = session.createQuery(query.toString());
1779:
1780:                        int queryPos = 0;
1781:
1782:                        if (uuid != null) {
1783:                            q.setString(queryPos++, uuid);
1784:                        }
1785:
1786:                        Long count = null;
1787:
1788:                        Iterator itr = q.list().iterator();
1789:
1790:                        if (itr.hasNext()) {
1791:                            count = (Long) itr.next();
1792:                        }
1793:
1794:                        if (count == null) {
1795:                            count = new Long(0);
1796:                        }
1797:
1798:                        FinderCache.putResult(finderClassNameCacheEnabled,
1799:                                finderClassName, finderMethodName,
1800:                                finderParams, finderArgs, count);
1801:
1802:                        return count.intValue();
1803:                    } catch (Exception e) {
1804:                        throw HibernateUtil.processException(e);
1805:                    } finally {
1806:                        closeSession(session);
1807:                    }
1808:                } else {
1809:                    return ((Long) result).intValue();
1810:                }
1811:            }
1812:
1813:            public int countByUUID_G(String uuid, long groupId)
1814:                    throws SystemException {
1815:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1816:                String finderClassName = JournalTemplate.class.getName();
1817:                String finderMethodName = "countByUUID_G";
1818:                String[] finderParams = new String[] { String.class.getName(),
1819:                        Long.class.getName() };
1820:                Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1821:
1822:                Object result = null;
1823:
1824:                if (finderClassNameCacheEnabled) {
1825:                    result = FinderCache.getResult(finderClassName,
1826:                            finderMethodName, finderParams, finderArgs,
1827:                            getSessionFactory());
1828:                }
1829:
1830:                if (result == null) {
1831:                    Session session = null;
1832:
1833:                    try {
1834:                        session = openSession();
1835:
1836:                        StringMaker query = new StringMaker();
1837:
1838:                        query.append("SELECT COUNT(*) ");
1839:                        query
1840:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1841:
1842:                        if (uuid == null) {
1843:                            query.append("uuid_ IS NULL");
1844:                        } else {
1845:                            query.append("uuid_ = ?");
1846:                        }
1847:
1848:                        query.append(" AND ");
1849:
1850:                        query.append("groupId = ?");
1851:
1852:                        query.append(" ");
1853:
1854:                        Query q = session.createQuery(query.toString());
1855:
1856:                        int queryPos = 0;
1857:
1858:                        if (uuid != null) {
1859:                            q.setString(queryPos++, uuid);
1860:                        }
1861:
1862:                        q.setLong(queryPos++, groupId);
1863:
1864:                        Long count = null;
1865:
1866:                        Iterator itr = q.list().iterator();
1867:
1868:                        if (itr.hasNext()) {
1869:                            count = (Long) itr.next();
1870:                        }
1871:
1872:                        if (count == null) {
1873:                            count = new Long(0);
1874:                        }
1875:
1876:                        FinderCache.putResult(finderClassNameCacheEnabled,
1877:                                finderClassName, finderMethodName,
1878:                                finderParams, finderArgs, count);
1879:
1880:                        return count.intValue();
1881:                    } catch (Exception e) {
1882:                        throw HibernateUtil.processException(e);
1883:                    } finally {
1884:                        closeSession(session);
1885:                    }
1886:                } else {
1887:                    return ((Long) result).intValue();
1888:                }
1889:            }
1890:
1891:            public int countByGroupId(long groupId) throws SystemException {
1892:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1893:                String finderClassName = JournalTemplate.class.getName();
1894:                String finderMethodName = "countByGroupId";
1895:                String[] finderParams = new String[] { Long.class.getName() };
1896:                Object[] finderArgs = new Object[] { new Long(groupId) };
1897:
1898:                Object result = null;
1899:
1900:                if (finderClassNameCacheEnabled) {
1901:                    result = FinderCache.getResult(finderClassName,
1902:                            finderMethodName, finderParams, finderArgs,
1903:                            getSessionFactory());
1904:                }
1905:
1906:                if (result == null) {
1907:                    Session session = null;
1908:
1909:                    try {
1910:                        session = openSession();
1911:
1912:                        StringMaker query = new StringMaker();
1913:
1914:                        query.append("SELECT COUNT(*) ");
1915:                        query
1916:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1917:
1918:                        query.append("groupId = ?");
1919:
1920:                        query.append(" ");
1921:
1922:                        Query q = session.createQuery(query.toString());
1923:
1924:                        int queryPos = 0;
1925:
1926:                        q.setLong(queryPos++, groupId);
1927:
1928:                        Long count = null;
1929:
1930:                        Iterator itr = q.list().iterator();
1931:
1932:                        if (itr.hasNext()) {
1933:                            count = (Long) itr.next();
1934:                        }
1935:
1936:                        if (count == null) {
1937:                            count = new Long(0);
1938:                        }
1939:
1940:                        FinderCache.putResult(finderClassNameCacheEnabled,
1941:                                finderClassName, finderMethodName,
1942:                                finderParams, finderArgs, count);
1943:
1944:                        return count.intValue();
1945:                    } catch (Exception e) {
1946:                        throw HibernateUtil.processException(e);
1947:                    } finally {
1948:                        closeSession(session);
1949:                    }
1950:                } else {
1951:                    return ((Long) result).intValue();
1952:                }
1953:            }
1954:
1955:            public int countByTemplateId(String templateId)
1956:                    throws SystemException {
1957:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1958:                String finderClassName = JournalTemplate.class.getName();
1959:                String finderMethodName = "countByTemplateId";
1960:                String[] finderParams = new String[] { String.class.getName() };
1961:                Object[] finderArgs = new Object[] { templateId };
1962:
1963:                Object result = null;
1964:
1965:                if (finderClassNameCacheEnabled) {
1966:                    result = FinderCache.getResult(finderClassName,
1967:                            finderMethodName, finderParams, finderArgs,
1968:                            getSessionFactory());
1969:                }
1970:
1971:                if (result == null) {
1972:                    Session session = null;
1973:
1974:                    try {
1975:                        session = openSession();
1976:
1977:                        StringMaker query = new StringMaker();
1978:
1979:                        query.append("SELECT COUNT(*) ");
1980:                        query
1981:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1982:
1983:                        if (templateId == null) {
1984:                            query.append("templateId IS NULL");
1985:                        } else {
1986:                            query.append("templateId = ?");
1987:                        }
1988:
1989:                        query.append(" ");
1990:
1991:                        Query q = session.createQuery(query.toString());
1992:
1993:                        int queryPos = 0;
1994:
1995:                        if (templateId != null) {
1996:                            q.setString(queryPos++, templateId);
1997:                        }
1998:
1999:                        Long count = null;
2000:
2001:                        Iterator itr = q.list().iterator();
2002:
2003:                        if (itr.hasNext()) {
2004:                            count = (Long) itr.next();
2005:                        }
2006:
2007:                        if (count == null) {
2008:                            count = new Long(0);
2009:                        }
2010:
2011:                        FinderCache.putResult(finderClassNameCacheEnabled,
2012:                                finderClassName, finderMethodName,
2013:                                finderParams, finderArgs, count);
2014:
2015:                        return count.intValue();
2016:                    } catch (Exception e) {
2017:                        throw HibernateUtil.processException(e);
2018:                    } finally {
2019:                        closeSession(session);
2020:                    }
2021:                } else {
2022:                    return ((Long) result).intValue();
2023:                }
2024:            }
2025:
2026:            public int countBySmallImageId(long smallImageId)
2027:                    throws SystemException {
2028:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2029:                String finderClassName = JournalTemplate.class.getName();
2030:                String finderMethodName = "countBySmallImageId";
2031:                String[] finderParams = new String[] { Long.class.getName() };
2032:                Object[] finderArgs = new Object[] { new Long(smallImageId) };
2033:
2034:                Object result = null;
2035:
2036:                if (finderClassNameCacheEnabled) {
2037:                    result = FinderCache.getResult(finderClassName,
2038:                            finderMethodName, finderParams, finderArgs,
2039:                            getSessionFactory());
2040:                }
2041:
2042:                if (result == null) {
2043:                    Session session = null;
2044:
2045:                    try {
2046:                        session = openSession();
2047:
2048:                        StringMaker query = new StringMaker();
2049:
2050:                        query.append("SELECT COUNT(*) ");
2051:                        query
2052:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2053:
2054:                        query.append("smallImageId = ?");
2055:
2056:                        query.append(" ");
2057:
2058:                        Query q = session.createQuery(query.toString());
2059:
2060:                        int queryPos = 0;
2061:
2062:                        q.setLong(queryPos++, smallImageId);
2063:
2064:                        Long count = null;
2065:
2066:                        Iterator itr = q.list().iterator();
2067:
2068:                        if (itr.hasNext()) {
2069:                            count = (Long) itr.next();
2070:                        }
2071:
2072:                        if (count == null) {
2073:                            count = new Long(0);
2074:                        }
2075:
2076:                        FinderCache.putResult(finderClassNameCacheEnabled,
2077:                                finderClassName, finderMethodName,
2078:                                finderParams, finderArgs, count);
2079:
2080:                        return count.intValue();
2081:                    } catch (Exception e) {
2082:                        throw HibernateUtil.processException(e);
2083:                    } finally {
2084:                        closeSession(session);
2085:                    }
2086:                } else {
2087:                    return ((Long) result).intValue();
2088:                }
2089:            }
2090:
2091:            public int countByG_T(long groupId, String templateId)
2092:                    throws SystemException {
2093:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2094:                String finderClassName = JournalTemplate.class.getName();
2095:                String finderMethodName = "countByG_T";
2096:                String[] finderParams = new String[] { Long.class.getName(),
2097:                        String.class.getName() };
2098:                Object[] finderArgs = new Object[] { new Long(groupId),
2099:                        templateId };
2100:
2101:                Object result = null;
2102:
2103:                if (finderClassNameCacheEnabled) {
2104:                    result = FinderCache.getResult(finderClassName,
2105:                            finderMethodName, finderParams, finderArgs,
2106:                            getSessionFactory());
2107:                }
2108:
2109:                if (result == null) {
2110:                    Session session = null;
2111:
2112:                    try {
2113:                        session = openSession();
2114:
2115:                        StringMaker query = new StringMaker();
2116:
2117:                        query.append("SELECT COUNT(*) ");
2118:                        query
2119:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2120:
2121:                        query.append("groupId = ?");
2122:
2123:                        query.append(" AND ");
2124:
2125:                        if (templateId == null) {
2126:                            query.append("templateId IS NULL");
2127:                        } else {
2128:                            query.append("templateId = ?");
2129:                        }
2130:
2131:                        query.append(" ");
2132:
2133:                        Query q = session.createQuery(query.toString());
2134:
2135:                        int queryPos = 0;
2136:
2137:                        q.setLong(queryPos++, groupId);
2138:
2139:                        if (templateId != null) {
2140:                            q.setString(queryPos++, templateId);
2141:                        }
2142:
2143:                        Long count = null;
2144:
2145:                        Iterator itr = q.list().iterator();
2146:
2147:                        if (itr.hasNext()) {
2148:                            count = (Long) itr.next();
2149:                        }
2150:
2151:                        if (count == null) {
2152:                            count = new Long(0);
2153:                        }
2154:
2155:                        FinderCache.putResult(finderClassNameCacheEnabled,
2156:                                finderClassName, finderMethodName,
2157:                                finderParams, finderArgs, count);
2158:
2159:                        return count.intValue();
2160:                    } catch (Exception e) {
2161:                        throw HibernateUtil.processException(e);
2162:                    } finally {
2163:                        closeSession(session);
2164:                    }
2165:                } else {
2166:                    return ((Long) result).intValue();
2167:                }
2168:            }
2169:
2170:            public int countByG_S(long groupId, String structureId)
2171:                    throws SystemException {
2172:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2173:                String finderClassName = JournalTemplate.class.getName();
2174:                String finderMethodName = "countByG_S";
2175:                String[] finderParams = new String[] { Long.class.getName(),
2176:                        String.class.getName() };
2177:                Object[] finderArgs = new Object[] { new Long(groupId),
2178:                        structureId };
2179:
2180:                Object result = null;
2181:
2182:                if (finderClassNameCacheEnabled) {
2183:                    result = FinderCache.getResult(finderClassName,
2184:                            finderMethodName, finderParams, finderArgs,
2185:                            getSessionFactory());
2186:                }
2187:
2188:                if (result == null) {
2189:                    Session session = null;
2190:
2191:                    try {
2192:                        session = openSession();
2193:
2194:                        StringMaker query = new StringMaker();
2195:
2196:                        query.append("SELECT COUNT(*) ");
2197:                        query
2198:                                .append("FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2199:
2200:                        query.append("groupId = ?");
2201:
2202:                        query.append(" AND ");
2203:
2204:                        if (structureId == null) {
2205:                            query.append("structureId IS NULL");
2206:                        } else {
2207:                            query.append("structureId = ?");
2208:                        }
2209:
2210:                        query.append(" ");
2211:
2212:                        Query q = session.createQuery(query.toString());
2213:
2214:                        int queryPos = 0;
2215:
2216:                        q.setLong(queryPos++, groupId);
2217:
2218:                        if (structureId != null) {
2219:                            q.setString(queryPos++, structureId);
2220:                        }
2221:
2222:                        Long count = null;
2223:
2224:                        Iterator itr = q.list().iterator();
2225:
2226:                        if (itr.hasNext()) {
2227:                            count = (Long) itr.next();
2228:                        }
2229:
2230:                        if (count == null) {
2231:                            count = new Long(0);
2232:                        }
2233:
2234:                        FinderCache.putResult(finderClassNameCacheEnabled,
2235:                                finderClassName, finderMethodName,
2236:                                finderParams, finderArgs, count);
2237:
2238:                        return count.intValue();
2239:                    } catch (Exception e) {
2240:                        throw HibernateUtil.processException(e);
2241:                    } finally {
2242:                        closeSession(session);
2243:                    }
2244:                } else {
2245:                    return ((Long) result).intValue();
2246:                }
2247:            }
2248:
2249:            public int countAll() throws SystemException {
2250:                boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2251:                String finderClassName = JournalTemplate.class.getName();
2252:                String finderMethodName = "countAll";
2253:                String[] finderParams = new String[] {};
2254:                Object[] finderArgs = new Object[] {};
2255:
2256:                Object result = null;
2257:
2258:                if (finderClassNameCacheEnabled) {
2259:                    result = FinderCache.getResult(finderClassName,
2260:                            finderMethodName, finderParams, finderArgs,
2261:                            getSessionFactory());
2262:                }
2263:
2264:                if (result == null) {
2265:                    Session session = null;
2266:
2267:                    try {
2268:                        session = openSession();
2269:
2270:                        Query q = session
2271:                                .createQuery("SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalTemplate");
2272:
2273:                        Long count = null;
2274:
2275:                        Iterator itr = q.list().iterator();
2276:
2277:                        if (itr.hasNext()) {
2278:                            count = (Long) itr.next();
2279:                        }
2280:
2281:                        if (count == null) {
2282:                            count = new Long(0);
2283:                        }
2284:
2285:                        FinderCache.putResult(finderClassNameCacheEnabled,
2286:                                finderClassName, finderMethodName,
2287:                                finderParams, finderArgs, count);
2288:
2289:                        return count.intValue();
2290:                    } catch (Exception e) {
2291:                        throw HibernateUtil.processException(e);
2292:                    } finally {
2293:                        closeSession(session);
2294:                    }
2295:                } else {
2296:                    return ((Long) result).intValue();
2297:                }
2298:            }
2299:
2300:            protected void initDao() {
2301:            }
2302:
2303:            private static ModelListener _getListener() {
2304:                if (Validator.isNotNull(_LISTENER)) {
2305:                    try {
2306:                        return (ModelListener) Class.forName(_LISTENER)
2307:                                .newInstance();
2308:                    } catch (Exception e) {
2309:                        _log.error(e);
2310:                    }
2311:                }
2312:
2313:                return null;
2314:            }
2315:
2316:            private static final String _LISTENER = GetterUtil
2317:                    .getString(PropsUtil
2318:                            .get("value.object.listener.com.liferay.portlet.journal.model.JournalTemplate"));
2319:            private static Log _log = LogFactory
2320:                    .getLog(JournalTemplatePersistenceImpl.class);
2321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.