Source Code Cross Referenced for JournalArticlePersistenceImpl.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.NoSuchArticleException;
0039:        import com.liferay.portlet.journal.model.JournalArticle;
0040:        import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
0041:        import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
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="JournalArticlePersistenceImpl.java.html"><b><i>View Source</i></b></a>
0057:         *
0058:         * @author Brian Wing Shun Chan
0059:         *
0060:         */
0061:        public class JournalArticlePersistenceImpl extends BasePersistence
0062:                implements  JournalArticlePersistence {
0063:            public JournalArticle create(long id) {
0064:                JournalArticle journalArticle = new JournalArticleImpl();
0065:
0066:                journalArticle.setNew(true);
0067:                journalArticle.setPrimaryKey(id);
0068:
0069:                String uuid = PortalUUIDUtil.generate();
0070:
0071:                journalArticle.setUuid(uuid);
0072:
0073:                return journalArticle;
0074:            }
0075:
0076:            public JournalArticle remove(long id)
0077:                    throws NoSuchArticleException, SystemException {
0078:                Session session = null;
0079:
0080:                try {
0081:                    session = openSession();
0082:
0083:                    JournalArticle journalArticle = (JournalArticle) session
0084:                            .get(JournalArticleImpl.class, new Long(id));
0085:
0086:                    if (journalArticle == null) {
0087:                        if (_log.isWarnEnabled()) {
0088:                            _log
0089:                                    .warn("No JournalArticle exists with the primary key "
0090:                                            + id);
0091:                        }
0092:
0093:                        throw new NoSuchArticleException(
0094:                                "No JournalArticle exists with the primary key "
0095:                                        + id);
0096:                    }
0097:
0098:                    return remove(journalArticle);
0099:                } catch (NoSuchArticleException nsee) {
0100:                    throw nsee;
0101:                } catch (Exception e) {
0102:                    throw HibernateUtil.processException(e);
0103:                } finally {
0104:                    closeSession(session);
0105:                }
0106:            }
0107:
0108:            public JournalArticle remove(JournalArticle journalArticle)
0109:                    throws SystemException {
0110:                ModelListener listener = _getListener();
0111:
0112:                if (listener != null) {
0113:                    listener.onBeforeRemove(journalArticle);
0114:                }
0115:
0116:                journalArticle = removeImpl(journalArticle);
0117:
0118:                if (listener != null) {
0119:                    listener.onAfterRemove(journalArticle);
0120:                }
0121:
0122:                return journalArticle;
0123:            }
0124:
0125:            protected JournalArticle removeImpl(JournalArticle journalArticle)
0126:                    throws SystemException {
0127:                Session session = null;
0128:
0129:                try {
0130:                    session = openSession();
0131:
0132:                    session.delete(journalArticle);
0133:
0134:                    session.flush();
0135:
0136:                    return journalArticle;
0137:                } catch (Exception e) {
0138:                    throw HibernateUtil.processException(e);
0139:                } finally {
0140:                    closeSession(session);
0141:
0142:                    FinderCache.clearCache(JournalArticle.class.getName());
0143:                }
0144:            }
0145:
0146:            public JournalArticle update(JournalArticle journalArticle)
0147:                    throws SystemException {
0148:                return update(journalArticle, false);
0149:            }
0150:
0151:            public JournalArticle update(JournalArticle journalArticle,
0152:                    boolean merge) throws SystemException {
0153:                ModelListener listener = _getListener();
0154:
0155:                boolean isNew = journalArticle.isNew();
0156:
0157:                if (listener != null) {
0158:                    if (isNew) {
0159:                        listener.onBeforeCreate(journalArticle);
0160:                    } else {
0161:                        listener.onBeforeUpdate(journalArticle);
0162:                    }
0163:                }
0164:
0165:                journalArticle = updateImpl(journalArticle, merge);
0166:
0167:                if (listener != null) {
0168:                    if (isNew) {
0169:                        listener.onAfterCreate(journalArticle);
0170:                    } else {
0171:                        listener.onAfterUpdate(journalArticle);
0172:                    }
0173:                }
0174:
0175:                return journalArticle;
0176:            }
0177:
0178:            public JournalArticle updateImpl(
0179:                    com.liferay.portlet.journal.model.JournalArticle journalArticle,
0180:                    boolean merge) throws SystemException {
0181:                if (Validator.isNull(journalArticle.getUuid())) {
0182:                    String uuid = PortalUUIDUtil.generate();
0183:
0184:                    journalArticle.setUuid(uuid);
0185:                }
0186:
0187:                Session session = null;
0188:
0189:                try {
0190:                    session = openSession();
0191:
0192:                    if (merge) {
0193:                        session.merge(journalArticle);
0194:                    } else {
0195:                        if (journalArticle.isNew()) {
0196:                            session.save(journalArticle);
0197:                        }
0198:                    }
0199:
0200:                    session.flush();
0201:
0202:                    journalArticle.setNew(false);
0203:
0204:                    return journalArticle;
0205:                } catch (Exception e) {
0206:                    throw HibernateUtil.processException(e);
0207:                } finally {
0208:                    closeSession(session);
0209:
0210:                    FinderCache.clearCache(JournalArticle.class.getName());
0211:                }
0212:            }
0213:
0214:            public JournalArticle findByPrimaryKey(long id)
0215:                    throws NoSuchArticleException, SystemException {
0216:                JournalArticle journalArticle = fetchByPrimaryKey(id);
0217:
0218:                if (journalArticle == null) {
0219:                    if (_log.isWarnEnabled()) {
0220:                        _log
0221:                                .warn("No JournalArticle exists with the primary key "
0222:                                        + id);
0223:                    }
0224:
0225:                    throw new NoSuchArticleException(
0226:                            "No JournalArticle exists with the primary key "
0227:                                    + id);
0228:                }
0229:
0230:                return journalArticle;
0231:            }
0232:
0233:            public JournalArticle fetchByPrimaryKey(long id)
0234:                    throws SystemException {
0235:                Session session = null;
0236:
0237:                try {
0238:                    session = openSession();
0239:
0240:                    return (JournalArticle) session.get(
0241:                            JournalArticleImpl.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 = JournalArticleModelImpl.CACHE_ENABLED;
0251:                String finderClassName = JournalArticle.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.JournalArticle 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("articleId ASC, ");
0286:                        query.append("version DESC");
0287:
0288:                        Query q = session.createQuery(query.toString());
0289:
0290:                        int queryPos = 0;
0291:
0292:                        if (uuid != null) {
0293:                            q.setString(queryPos++, uuid);
0294:                        }
0295:
0296:                        List list = q.list();
0297:
0298:                        FinderCache.putResult(finderClassNameCacheEnabled,
0299:                                finderClassName, finderMethodName,
0300:                                finderParams, finderArgs, list);
0301:
0302:                        return list;
0303:                    } catch (Exception e) {
0304:                        throw HibernateUtil.processException(e);
0305:                    } finally {
0306:                        closeSession(session);
0307:                    }
0308:                } else {
0309:                    return (List) result;
0310:                }
0311:            }
0312:
0313:            public List findByUuid(String uuid, int begin, int end)
0314:                    throws SystemException {
0315:                return findByUuid(uuid, begin, end, null);
0316:            }
0317:
0318:            public List findByUuid(String uuid, int begin, int end,
0319:                    OrderByComparator obc) throws SystemException {
0320:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
0321:                String finderClassName = JournalArticle.class.getName();
0322:                String finderMethodName = "findByUuid";
0323:                String[] finderParams = new String[] { String.class.getName(),
0324:
0325:                "java.lang.Integer", "java.lang.Integer",
0326:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0327:                Object[] finderArgs = new Object[] { uuid,
0328:
0329:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0330:
0331:                Object result = null;
0332:
0333:                if (finderClassNameCacheEnabled) {
0334:                    result = FinderCache.getResult(finderClassName,
0335:                            finderMethodName, finderParams, finderArgs,
0336:                            getSessionFactory());
0337:                }
0338:
0339:                if (result == null) {
0340:                    Session session = null;
0341:
0342:                    try {
0343:                        session = openSession();
0344:
0345:                        StringMaker query = new StringMaker();
0346:
0347:                        query
0348:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0349:
0350:                        if (uuid == null) {
0351:                            query.append("uuid_ IS NULL");
0352:                        } else {
0353:                            query.append("uuid_ = ?");
0354:                        }
0355:
0356:                        query.append(" ");
0357:
0358:                        if (obc != null) {
0359:                            query.append("ORDER BY ");
0360:                            query.append(obc.getOrderBy());
0361:                        }
0362:
0363:                        else {
0364:                            query.append("ORDER BY ");
0365:
0366:                            query.append("articleId ASC, ");
0367:                            query.append("version DESC");
0368:                        }
0369:
0370:                        Query q = session.createQuery(query.toString());
0371:
0372:                        int queryPos = 0;
0373:
0374:                        if (uuid != null) {
0375:                            q.setString(queryPos++, uuid);
0376:                        }
0377:
0378:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0379:
0380:                        FinderCache.putResult(finderClassNameCacheEnabled,
0381:                                finderClassName, finderMethodName,
0382:                                finderParams, finderArgs, list);
0383:
0384:                        return list;
0385:                    } catch (Exception e) {
0386:                        throw HibernateUtil.processException(e);
0387:                    } finally {
0388:                        closeSession(session);
0389:                    }
0390:                } else {
0391:                    return (List) result;
0392:                }
0393:            }
0394:
0395:            public JournalArticle findByUuid_First(String uuid,
0396:                    OrderByComparator obc) throws NoSuchArticleException,
0397:                    SystemException {
0398:                List list = findByUuid(uuid, 0, 1, obc);
0399:
0400:                if (list.size() == 0) {
0401:                    StringMaker msg = new StringMaker();
0402:
0403:                    msg.append("No JournalArticle exists with the key {");
0404:
0405:                    msg.append("uuid=" + uuid);
0406:
0407:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0408:
0409:                    throw new NoSuchArticleException(msg.toString());
0410:                } else {
0411:                    return (JournalArticle) list.get(0);
0412:                }
0413:            }
0414:
0415:            public JournalArticle findByUuid_Last(String uuid,
0416:                    OrderByComparator obc) throws NoSuchArticleException,
0417:                    SystemException {
0418:                int count = countByUuid(uuid);
0419:
0420:                List list = findByUuid(uuid, count - 1, count, obc);
0421:
0422:                if (list.size() == 0) {
0423:                    StringMaker msg = new StringMaker();
0424:
0425:                    msg.append("No JournalArticle exists with the key {");
0426:
0427:                    msg.append("uuid=" + uuid);
0428:
0429:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0430:
0431:                    throw new NoSuchArticleException(msg.toString());
0432:                } else {
0433:                    return (JournalArticle) list.get(0);
0434:                }
0435:            }
0436:
0437:            public JournalArticle[] findByUuid_PrevAndNext(long id,
0438:                    String uuid, OrderByComparator obc)
0439:                    throws NoSuchArticleException, SystemException {
0440:                JournalArticle journalArticle = findByPrimaryKey(id);
0441:
0442:                int count = countByUuid(uuid);
0443:
0444:                Session session = null;
0445:
0446:                try {
0447:                    session = openSession();
0448:
0449:                    StringMaker query = new StringMaker();
0450:
0451:                    query
0452:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0453:
0454:                    if (uuid == null) {
0455:                        query.append("uuid_ IS NULL");
0456:                    } else {
0457:                        query.append("uuid_ = ?");
0458:                    }
0459:
0460:                    query.append(" ");
0461:
0462:                    if (obc != null) {
0463:                        query.append("ORDER BY ");
0464:                        query.append(obc.getOrderBy());
0465:                    }
0466:
0467:                    else {
0468:                        query.append("ORDER BY ");
0469:
0470:                        query.append("articleId ASC, ");
0471:                        query.append("version DESC");
0472:                    }
0473:
0474:                    Query q = session.createQuery(query.toString());
0475:
0476:                    int queryPos = 0;
0477:
0478:                    if (uuid != null) {
0479:                        q.setString(queryPos++, uuid);
0480:                    }
0481:
0482:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0483:                            journalArticle);
0484:
0485:                    JournalArticle[] array = new JournalArticleImpl[3];
0486:
0487:                    array[0] = (JournalArticle) objArray[0];
0488:                    array[1] = (JournalArticle) objArray[1];
0489:                    array[2] = (JournalArticle) objArray[2];
0490:
0491:                    return array;
0492:                } catch (Exception e) {
0493:                    throw HibernateUtil.processException(e);
0494:                } finally {
0495:                    closeSession(session);
0496:                }
0497:            }
0498:
0499:            public JournalArticle findByUUID_G(String uuid, long groupId)
0500:                    throws NoSuchArticleException, SystemException {
0501:                JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
0502:
0503:                if (journalArticle == null) {
0504:                    StringMaker msg = new StringMaker();
0505:
0506:                    msg.append("No JournalArticle exists with the key {");
0507:
0508:                    msg.append("uuid=" + uuid);
0509:
0510:                    msg.append(", ");
0511:                    msg.append("groupId=" + groupId);
0512:
0513:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0514:
0515:                    if (_log.isWarnEnabled()) {
0516:                        _log.warn(msg.toString());
0517:                    }
0518:
0519:                    throw new NoSuchArticleException(msg.toString());
0520:                }
0521:
0522:                return journalArticle;
0523:            }
0524:
0525:            public JournalArticle fetchByUUID_G(String uuid, long groupId)
0526:                    throws SystemException {
0527:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
0528:                String finderClassName = JournalArticle.class.getName();
0529:                String finderMethodName = "fetchByUUID_G";
0530:                String[] finderParams = new String[] { String.class.getName(),
0531:                        Long.class.getName() };
0532:                Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
0533:
0534:                Object result = null;
0535:
0536:                if (finderClassNameCacheEnabled) {
0537:                    result = FinderCache.getResult(finderClassName,
0538:                            finderMethodName, finderParams, finderArgs,
0539:                            getSessionFactory());
0540:                }
0541:
0542:                if (result == null) {
0543:                    Session session = null;
0544:
0545:                    try {
0546:                        session = openSession();
0547:
0548:                        StringMaker query = new StringMaker();
0549:
0550:                        query
0551:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0552:
0553:                        if (uuid == null) {
0554:                            query.append("uuid_ IS NULL");
0555:                        } else {
0556:                            query.append("uuid_ = ?");
0557:                        }
0558:
0559:                        query.append(" AND ");
0560:
0561:                        query.append("groupId = ?");
0562:
0563:                        query.append(" ");
0564:
0565:                        query.append("ORDER BY ");
0566:
0567:                        query.append("articleId ASC, ");
0568:                        query.append("version DESC");
0569:
0570:                        Query q = session.createQuery(query.toString());
0571:
0572:                        int queryPos = 0;
0573:
0574:                        if (uuid != null) {
0575:                            q.setString(queryPos++, uuid);
0576:                        }
0577:
0578:                        q.setLong(queryPos++, groupId);
0579:
0580:                        List list = q.list();
0581:
0582:                        FinderCache.putResult(finderClassNameCacheEnabled,
0583:                                finderClassName, finderMethodName,
0584:                                finderParams, finderArgs, list);
0585:
0586:                        if (list.size() == 0) {
0587:                            return null;
0588:                        } else {
0589:                            return (JournalArticle) list.get(0);
0590:                        }
0591:                    } catch (Exception e) {
0592:                        throw HibernateUtil.processException(e);
0593:                    } finally {
0594:                        closeSession(session);
0595:                    }
0596:                } else {
0597:                    List list = (List) result;
0598:
0599:                    if (list.size() == 0) {
0600:                        return null;
0601:                    } else {
0602:                        return (JournalArticle) list.get(0);
0603:                    }
0604:                }
0605:            }
0606:
0607:            public List findByGroupId(long groupId) throws SystemException {
0608:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
0609:                String finderClassName = JournalArticle.class.getName();
0610:                String finderMethodName = "findByGroupId";
0611:                String[] finderParams = new String[] { Long.class.getName() };
0612:                Object[] finderArgs = new Object[] { new Long(groupId) };
0613:
0614:                Object result = null;
0615:
0616:                if (finderClassNameCacheEnabled) {
0617:                    result = FinderCache.getResult(finderClassName,
0618:                            finderMethodName, finderParams, finderArgs,
0619:                            getSessionFactory());
0620:                }
0621:
0622:                if (result == null) {
0623:                    Session session = null;
0624:
0625:                    try {
0626:                        session = openSession();
0627:
0628:                        StringMaker query = new StringMaker();
0629:
0630:                        query
0631:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0632:
0633:                        query.append("groupId = ?");
0634:
0635:                        query.append(" ");
0636:
0637:                        query.append("ORDER BY ");
0638:
0639:                        query.append("articleId ASC, ");
0640:                        query.append("version DESC");
0641:
0642:                        Query q = session.createQuery(query.toString());
0643:
0644:                        int queryPos = 0;
0645:
0646:                        q.setLong(queryPos++, groupId);
0647:
0648:                        List list = q.list();
0649:
0650:                        FinderCache.putResult(finderClassNameCacheEnabled,
0651:                                finderClassName, finderMethodName,
0652:                                finderParams, finderArgs, list);
0653:
0654:                        return list;
0655:                    } catch (Exception e) {
0656:                        throw HibernateUtil.processException(e);
0657:                    } finally {
0658:                        closeSession(session);
0659:                    }
0660:                } else {
0661:                    return (List) result;
0662:                }
0663:            }
0664:
0665:            public List findByGroupId(long groupId, int begin, int end)
0666:                    throws SystemException {
0667:                return findByGroupId(groupId, begin, end, null);
0668:            }
0669:
0670:            public List findByGroupId(long groupId, int begin, int end,
0671:                    OrderByComparator obc) throws SystemException {
0672:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
0673:                String finderClassName = JournalArticle.class.getName();
0674:                String finderMethodName = "findByGroupId";
0675:                String[] finderParams = new String[] { Long.class.getName(),
0676:
0677:                "java.lang.Integer", "java.lang.Integer",
0678:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0679:                Object[] finderArgs = new Object[] { new Long(groupId),
0680:
0681:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0682:
0683:                Object result = null;
0684:
0685:                if (finderClassNameCacheEnabled) {
0686:                    result = FinderCache.getResult(finderClassName,
0687:                            finderMethodName, finderParams, finderArgs,
0688:                            getSessionFactory());
0689:                }
0690:
0691:                if (result == null) {
0692:                    Session session = null;
0693:
0694:                    try {
0695:                        session = openSession();
0696:
0697:                        StringMaker query = new StringMaker();
0698:
0699:                        query
0700:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0701:
0702:                        query.append("groupId = ?");
0703:
0704:                        query.append(" ");
0705:
0706:                        if (obc != null) {
0707:                            query.append("ORDER BY ");
0708:                            query.append(obc.getOrderBy());
0709:                        }
0710:
0711:                        else {
0712:                            query.append("ORDER BY ");
0713:
0714:                            query.append("articleId ASC, ");
0715:                            query.append("version DESC");
0716:                        }
0717:
0718:                        Query q = session.createQuery(query.toString());
0719:
0720:                        int queryPos = 0;
0721:
0722:                        q.setLong(queryPos++, groupId);
0723:
0724:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0725:
0726:                        FinderCache.putResult(finderClassNameCacheEnabled,
0727:                                finderClassName, finderMethodName,
0728:                                finderParams, finderArgs, list);
0729:
0730:                        return list;
0731:                    } catch (Exception e) {
0732:                        throw HibernateUtil.processException(e);
0733:                    } finally {
0734:                        closeSession(session);
0735:                    }
0736:                } else {
0737:                    return (List) result;
0738:                }
0739:            }
0740:
0741:            public JournalArticle findByGroupId_First(long groupId,
0742:                    OrderByComparator obc) throws NoSuchArticleException,
0743:                    SystemException {
0744:                List list = findByGroupId(groupId, 0, 1, obc);
0745:
0746:                if (list.size() == 0) {
0747:                    StringMaker msg = new StringMaker();
0748:
0749:                    msg.append("No JournalArticle exists with the key {");
0750:
0751:                    msg.append("groupId=" + groupId);
0752:
0753:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0754:
0755:                    throw new NoSuchArticleException(msg.toString());
0756:                } else {
0757:                    return (JournalArticle) list.get(0);
0758:                }
0759:            }
0760:
0761:            public JournalArticle findByGroupId_Last(long groupId,
0762:                    OrderByComparator obc) throws NoSuchArticleException,
0763:                    SystemException {
0764:                int count = countByGroupId(groupId);
0765:
0766:                List list = findByGroupId(groupId, count - 1, count, obc);
0767:
0768:                if (list.size() == 0) {
0769:                    StringMaker msg = new StringMaker();
0770:
0771:                    msg.append("No JournalArticle exists with the key {");
0772:
0773:                    msg.append("groupId=" + groupId);
0774:
0775:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0776:
0777:                    throw new NoSuchArticleException(msg.toString());
0778:                } else {
0779:                    return (JournalArticle) list.get(0);
0780:                }
0781:            }
0782:
0783:            public JournalArticle[] findByGroupId_PrevAndNext(long id,
0784:                    long groupId, OrderByComparator obc)
0785:                    throws NoSuchArticleException, SystemException {
0786:                JournalArticle journalArticle = findByPrimaryKey(id);
0787:
0788:                int count = countByGroupId(groupId);
0789:
0790:                Session session = null;
0791:
0792:                try {
0793:                    session = openSession();
0794:
0795:                    StringMaker query = new StringMaker();
0796:
0797:                    query
0798:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0799:
0800:                    query.append("groupId = ?");
0801:
0802:                    query.append(" ");
0803:
0804:                    if (obc != null) {
0805:                        query.append("ORDER BY ");
0806:                        query.append(obc.getOrderBy());
0807:                    }
0808:
0809:                    else {
0810:                        query.append("ORDER BY ");
0811:
0812:                        query.append("articleId ASC, ");
0813:                        query.append("version DESC");
0814:                    }
0815:
0816:                    Query q = session.createQuery(query.toString());
0817:
0818:                    int queryPos = 0;
0819:
0820:                    q.setLong(queryPos++, groupId);
0821:
0822:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0823:                            journalArticle);
0824:
0825:                    JournalArticle[] array = new JournalArticleImpl[3];
0826:
0827:                    array[0] = (JournalArticle) objArray[0];
0828:                    array[1] = (JournalArticle) objArray[1];
0829:                    array[2] = (JournalArticle) objArray[2];
0830:
0831:                    return array;
0832:                } catch (Exception e) {
0833:                    throw HibernateUtil.processException(e);
0834:                } finally {
0835:                    closeSession(session);
0836:                }
0837:            }
0838:
0839:            public List findByCompanyId(long companyId) throws SystemException {
0840:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
0841:                String finderClassName = JournalArticle.class.getName();
0842:                String finderMethodName = "findByCompanyId";
0843:                String[] finderParams = new String[] { Long.class.getName() };
0844:                Object[] finderArgs = new Object[] { new Long(companyId) };
0845:
0846:                Object result = null;
0847:
0848:                if (finderClassNameCacheEnabled) {
0849:                    result = FinderCache.getResult(finderClassName,
0850:                            finderMethodName, finderParams, finderArgs,
0851:                            getSessionFactory());
0852:                }
0853:
0854:                if (result == null) {
0855:                    Session session = null;
0856:
0857:                    try {
0858:                        session = openSession();
0859:
0860:                        StringMaker query = new StringMaker();
0861:
0862:                        query
0863:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0864:
0865:                        query.append("companyId = ?");
0866:
0867:                        query.append(" ");
0868:
0869:                        query.append("ORDER BY ");
0870:
0871:                        query.append("articleId ASC, ");
0872:                        query.append("version DESC");
0873:
0874:                        Query q = session.createQuery(query.toString());
0875:
0876:                        int queryPos = 0;
0877:
0878:                        q.setLong(queryPos++, companyId);
0879:
0880:                        List list = q.list();
0881:
0882:                        FinderCache.putResult(finderClassNameCacheEnabled,
0883:                                finderClassName, finderMethodName,
0884:                                finderParams, finderArgs, list);
0885:
0886:                        return list;
0887:                    } catch (Exception e) {
0888:                        throw HibernateUtil.processException(e);
0889:                    } finally {
0890:                        closeSession(session);
0891:                    }
0892:                } else {
0893:                    return (List) result;
0894:                }
0895:            }
0896:
0897:            public List findByCompanyId(long companyId, int begin, int end)
0898:                    throws SystemException {
0899:                return findByCompanyId(companyId, begin, end, null);
0900:            }
0901:
0902:            public List findByCompanyId(long companyId, int begin, int end,
0903:                    OrderByComparator obc) throws SystemException {
0904:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
0905:                String finderClassName = JournalArticle.class.getName();
0906:                String finderMethodName = "findByCompanyId";
0907:                String[] finderParams = new String[] { Long.class.getName(),
0908:
0909:                "java.lang.Integer", "java.lang.Integer",
0910:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0911:                Object[] finderArgs = new Object[] { new Long(companyId),
0912:
0913:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0914:
0915:                Object result = null;
0916:
0917:                if (finderClassNameCacheEnabled) {
0918:                    result = FinderCache.getResult(finderClassName,
0919:                            finderMethodName, finderParams, finderArgs,
0920:                            getSessionFactory());
0921:                }
0922:
0923:                if (result == null) {
0924:                    Session session = null;
0925:
0926:                    try {
0927:                        session = openSession();
0928:
0929:                        StringMaker query = new StringMaker();
0930:
0931:                        query
0932:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
0933:
0934:                        query.append("companyId = ?");
0935:
0936:                        query.append(" ");
0937:
0938:                        if (obc != null) {
0939:                            query.append("ORDER BY ");
0940:                            query.append(obc.getOrderBy());
0941:                        }
0942:
0943:                        else {
0944:                            query.append("ORDER BY ");
0945:
0946:                            query.append("articleId ASC, ");
0947:                            query.append("version DESC");
0948:                        }
0949:
0950:                        Query q = session.createQuery(query.toString());
0951:
0952:                        int queryPos = 0;
0953:
0954:                        q.setLong(queryPos++, companyId);
0955:
0956:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0957:
0958:                        FinderCache.putResult(finderClassNameCacheEnabled,
0959:                                finderClassName, finderMethodName,
0960:                                finderParams, finderArgs, list);
0961:
0962:                        return list;
0963:                    } catch (Exception e) {
0964:                        throw HibernateUtil.processException(e);
0965:                    } finally {
0966:                        closeSession(session);
0967:                    }
0968:                } else {
0969:                    return (List) result;
0970:                }
0971:            }
0972:
0973:            public JournalArticle findByCompanyId_First(long companyId,
0974:                    OrderByComparator obc) throws NoSuchArticleException,
0975:                    SystemException {
0976:                List list = findByCompanyId(companyId, 0, 1, obc);
0977:
0978:                if (list.size() == 0) {
0979:                    StringMaker msg = new StringMaker();
0980:
0981:                    msg.append("No JournalArticle exists with the key {");
0982:
0983:                    msg.append("companyId=" + companyId);
0984:
0985:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0986:
0987:                    throw new NoSuchArticleException(msg.toString());
0988:                } else {
0989:                    return (JournalArticle) list.get(0);
0990:                }
0991:            }
0992:
0993:            public JournalArticle findByCompanyId_Last(long companyId,
0994:                    OrderByComparator obc) throws NoSuchArticleException,
0995:                    SystemException {
0996:                int count = countByCompanyId(companyId);
0997:
0998:                List list = findByCompanyId(companyId, count - 1, count, obc);
0999:
1000:                if (list.size() == 0) {
1001:                    StringMaker msg = new StringMaker();
1002:
1003:                    msg.append("No JournalArticle exists with the key {");
1004:
1005:                    msg.append("companyId=" + companyId);
1006:
1007:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1008:
1009:                    throw new NoSuchArticleException(msg.toString());
1010:                } else {
1011:                    return (JournalArticle) list.get(0);
1012:                }
1013:            }
1014:
1015:            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
1016:                    long companyId, OrderByComparator obc)
1017:                    throws NoSuchArticleException, SystemException {
1018:                JournalArticle journalArticle = findByPrimaryKey(id);
1019:
1020:                int count = countByCompanyId(companyId);
1021:
1022:                Session session = null;
1023:
1024:                try {
1025:                    session = openSession();
1026:
1027:                    StringMaker query = new StringMaker();
1028:
1029:                    query
1030:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1031:
1032:                    query.append("companyId = ?");
1033:
1034:                    query.append(" ");
1035:
1036:                    if (obc != null) {
1037:                        query.append("ORDER BY ");
1038:                        query.append(obc.getOrderBy());
1039:                    }
1040:
1041:                    else {
1042:                        query.append("ORDER BY ");
1043:
1044:                        query.append("articleId ASC, ");
1045:                        query.append("version DESC");
1046:                    }
1047:
1048:                    Query q = session.createQuery(query.toString());
1049:
1050:                    int queryPos = 0;
1051:
1052:                    q.setLong(queryPos++, companyId);
1053:
1054:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1055:                            journalArticle);
1056:
1057:                    JournalArticle[] array = new JournalArticleImpl[3];
1058:
1059:                    array[0] = (JournalArticle) objArray[0];
1060:                    array[1] = (JournalArticle) objArray[1];
1061:                    array[2] = (JournalArticle) objArray[2];
1062:
1063:                    return array;
1064:                } catch (Exception e) {
1065:                    throw HibernateUtil.processException(e);
1066:                } finally {
1067:                    closeSession(session);
1068:                }
1069:            }
1070:
1071:            public List findBySmallImageId(long smallImageId)
1072:                    throws SystemException {
1073:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1074:                String finderClassName = JournalArticle.class.getName();
1075:                String finderMethodName = "findBySmallImageId";
1076:                String[] finderParams = new String[] { Long.class.getName() };
1077:                Object[] finderArgs = new Object[] { new Long(smallImageId) };
1078:
1079:                Object result = null;
1080:
1081:                if (finderClassNameCacheEnabled) {
1082:                    result = FinderCache.getResult(finderClassName,
1083:                            finderMethodName, finderParams, finderArgs,
1084:                            getSessionFactory());
1085:                }
1086:
1087:                if (result == null) {
1088:                    Session session = null;
1089:
1090:                    try {
1091:                        session = openSession();
1092:
1093:                        StringMaker query = new StringMaker();
1094:
1095:                        query
1096:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1097:
1098:                        query.append("smallImageId = ?");
1099:
1100:                        query.append(" ");
1101:
1102:                        query.append("ORDER BY ");
1103:
1104:                        query.append("articleId ASC, ");
1105:                        query.append("version DESC");
1106:
1107:                        Query q = session.createQuery(query.toString());
1108:
1109:                        int queryPos = 0;
1110:
1111:                        q.setLong(queryPos++, smallImageId);
1112:
1113:                        List list = q.list();
1114:
1115:                        FinderCache.putResult(finderClassNameCacheEnabled,
1116:                                finderClassName, finderMethodName,
1117:                                finderParams, finderArgs, list);
1118:
1119:                        return list;
1120:                    } catch (Exception e) {
1121:                        throw HibernateUtil.processException(e);
1122:                    } finally {
1123:                        closeSession(session);
1124:                    }
1125:                } else {
1126:                    return (List) result;
1127:                }
1128:            }
1129:
1130:            public List findBySmallImageId(long smallImageId, int begin, int end)
1131:                    throws SystemException {
1132:                return findBySmallImageId(smallImageId, begin, end, null);
1133:            }
1134:
1135:            public List findBySmallImageId(long smallImageId, int begin,
1136:                    int end, OrderByComparator obc) throws SystemException {
1137:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1138:                String finderClassName = JournalArticle.class.getName();
1139:                String finderMethodName = "findBySmallImageId";
1140:                String[] finderParams = new String[] { Long.class.getName(),
1141:
1142:                "java.lang.Integer", "java.lang.Integer",
1143:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1144:                Object[] finderArgs = new Object[] { new Long(smallImageId),
1145:
1146:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
1147:
1148:                Object result = null;
1149:
1150:                if (finderClassNameCacheEnabled) {
1151:                    result = FinderCache.getResult(finderClassName,
1152:                            finderMethodName, finderParams, finderArgs,
1153:                            getSessionFactory());
1154:                }
1155:
1156:                if (result == null) {
1157:                    Session session = null;
1158:
1159:                    try {
1160:                        session = openSession();
1161:
1162:                        StringMaker query = new StringMaker();
1163:
1164:                        query
1165:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1166:
1167:                        query.append("smallImageId = ?");
1168:
1169:                        query.append(" ");
1170:
1171:                        if (obc != null) {
1172:                            query.append("ORDER BY ");
1173:                            query.append(obc.getOrderBy());
1174:                        }
1175:
1176:                        else {
1177:                            query.append("ORDER BY ");
1178:
1179:                            query.append("articleId ASC, ");
1180:                            query.append("version DESC");
1181:                        }
1182:
1183:                        Query q = session.createQuery(query.toString());
1184:
1185:                        int queryPos = 0;
1186:
1187:                        q.setLong(queryPos++, smallImageId);
1188:
1189:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1190:
1191:                        FinderCache.putResult(finderClassNameCacheEnabled,
1192:                                finderClassName, finderMethodName,
1193:                                finderParams, finderArgs, list);
1194:
1195:                        return list;
1196:                    } catch (Exception e) {
1197:                        throw HibernateUtil.processException(e);
1198:                    } finally {
1199:                        closeSession(session);
1200:                    }
1201:                } else {
1202:                    return (List) result;
1203:                }
1204:            }
1205:
1206:            public JournalArticle findBySmallImageId_First(long smallImageId,
1207:                    OrderByComparator obc) throws NoSuchArticleException,
1208:                    SystemException {
1209:                List list = findBySmallImageId(smallImageId, 0, 1, obc);
1210:
1211:                if (list.size() == 0) {
1212:                    StringMaker msg = new StringMaker();
1213:
1214:                    msg.append("No JournalArticle exists with the key {");
1215:
1216:                    msg.append("smallImageId=" + smallImageId);
1217:
1218:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1219:
1220:                    throw new NoSuchArticleException(msg.toString());
1221:                } else {
1222:                    return (JournalArticle) list.get(0);
1223:                }
1224:            }
1225:
1226:            public JournalArticle findBySmallImageId_Last(long smallImageId,
1227:                    OrderByComparator obc) throws NoSuchArticleException,
1228:                    SystemException {
1229:                int count = countBySmallImageId(smallImageId);
1230:
1231:                List list = findBySmallImageId(smallImageId, count - 1, count,
1232:                        obc);
1233:
1234:                if (list.size() == 0) {
1235:                    StringMaker msg = new StringMaker();
1236:
1237:                    msg.append("No JournalArticle exists with the key {");
1238:
1239:                    msg.append("smallImageId=" + smallImageId);
1240:
1241:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1242:
1243:                    throw new NoSuchArticleException(msg.toString());
1244:                } else {
1245:                    return (JournalArticle) list.get(0);
1246:                }
1247:            }
1248:
1249:            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
1250:                    long smallImageId, OrderByComparator obc)
1251:                    throws NoSuchArticleException, SystemException {
1252:                JournalArticle journalArticle = findByPrimaryKey(id);
1253:
1254:                int count = countBySmallImageId(smallImageId);
1255:
1256:                Session session = null;
1257:
1258:                try {
1259:                    session = openSession();
1260:
1261:                    StringMaker query = new StringMaker();
1262:
1263:                    query
1264:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1265:
1266:                    query.append("smallImageId = ?");
1267:
1268:                    query.append(" ");
1269:
1270:                    if (obc != null) {
1271:                        query.append("ORDER BY ");
1272:                        query.append(obc.getOrderBy());
1273:                    }
1274:
1275:                    else {
1276:                        query.append("ORDER BY ");
1277:
1278:                        query.append("articleId ASC, ");
1279:                        query.append("version DESC");
1280:                    }
1281:
1282:                    Query q = session.createQuery(query.toString());
1283:
1284:                    int queryPos = 0;
1285:
1286:                    q.setLong(queryPos++, smallImageId);
1287:
1288:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1289:                            journalArticle);
1290:
1291:                    JournalArticle[] array = new JournalArticleImpl[3];
1292:
1293:                    array[0] = (JournalArticle) objArray[0];
1294:                    array[1] = (JournalArticle) objArray[1];
1295:                    array[2] = (JournalArticle) objArray[2];
1296:
1297:                    return array;
1298:                } catch (Exception e) {
1299:                    throw HibernateUtil.processException(e);
1300:                } finally {
1301:                    closeSession(session);
1302:                }
1303:            }
1304:
1305:            public List findByG_A(long groupId, String articleId)
1306:                    throws SystemException {
1307:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1308:                String finderClassName = JournalArticle.class.getName();
1309:                String finderMethodName = "findByG_A";
1310:                String[] finderParams = new String[] { Long.class.getName(),
1311:                        String.class.getName() };
1312:                Object[] finderArgs = new Object[] { new Long(groupId),
1313:                        articleId };
1314:
1315:                Object result = null;
1316:
1317:                if (finderClassNameCacheEnabled) {
1318:                    result = FinderCache.getResult(finderClassName,
1319:                            finderMethodName, finderParams, finderArgs,
1320:                            getSessionFactory());
1321:                }
1322:
1323:                if (result == null) {
1324:                    Session session = null;
1325:
1326:                    try {
1327:                        session = openSession();
1328:
1329:                        StringMaker query = new StringMaker();
1330:
1331:                        query
1332:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1333:
1334:                        query.append("groupId = ?");
1335:
1336:                        query.append(" AND ");
1337:
1338:                        if (articleId == null) {
1339:                            query.append("articleId IS NULL");
1340:                        } else {
1341:                            query.append("articleId = ?");
1342:                        }
1343:
1344:                        query.append(" ");
1345:
1346:                        query.append("ORDER BY ");
1347:
1348:                        query.append("articleId ASC, ");
1349:                        query.append("version DESC");
1350:
1351:                        Query q = session.createQuery(query.toString());
1352:
1353:                        int queryPos = 0;
1354:
1355:                        q.setLong(queryPos++, groupId);
1356:
1357:                        if (articleId != null) {
1358:                            q.setString(queryPos++, articleId);
1359:                        }
1360:
1361:                        List list = q.list();
1362:
1363:                        FinderCache.putResult(finderClassNameCacheEnabled,
1364:                                finderClassName, finderMethodName,
1365:                                finderParams, finderArgs, list);
1366:
1367:                        return list;
1368:                    } catch (Exception e) {
1369:                        throw HibernateUtil.processException(e);
1370:                    } finally {
1371:                        closeSession(session);
1372:                    }
1373:                } else {
1374:                    return (List) result;
1375:                }
1376:            }
1377:
1378:            public List findByG_A(long groupId, String articleId, int begin,
1379:                    int end) throws SystemException {
1380:                return findByG_A(groupId, articleId, begin, end, null);
1381:            }
1382:
1383:            public List findByG_A(long groupId, String articleId, int begin,
1384:                    int end, OrderByComparator obc) throws SystemException {
1385:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1386:                String finderClassName = JournalArticle.class.getName();
1387:                String finderMethodName = "findByG_A";
1388:                String[] finderParams = new String[] { Long.class.getName(),
1389:                        String.class.getName(),
1390:
1391:                        "java.lang.Integer", "java.lang.Integer",
1392:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1393:                Object[] finderArgs = new Object[] { new Long(groupId),
1394:
1395:                articleId,
1396:
1397:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
1398:
1399:                Object result = null;
1400:
1401:                if (finderClassNameCacheEnabled) {
1402:                    result = FinderCache.getResult(finderClassName,
1403:                            finderMethodName, finderParams, finderArgs,
1404:                            getSessionFactory());
1405:                }
1406:
1407:                if (result == null) {
1408:                    Session session = null;
1409:
1410:                    try {
1411:                        session = openSession();
1412:
1413:                        StringMaker query = new StringMaker();
1414:
1415:                        query
1416:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1417:
1418:                        query.append("groupId = ?");
1419:
1420:                        query.append(" AND ");
1421:
1422:                        if (articleId == null) {
1423:                            query.append("articleId IS NULL");
1424:                        } else {
1425:                            query.append("articleId = ?");
1426:                        }
1427:
1428:                        query.append(" ");
1429:
1430:                        if (obc != null) {
1431:                            query.append("ORDER BY ");
1432:                            query.append(obc.getOrderBy());
1433:                        }
1434:
1435:                        else {
1436:                            query.append("ORDER BY ");
1437:
1438:                            query.append("articleId ASC, ");
1439:                            query.append("version DESC");
1440:                        }
1441:
1442:                        Query q = session.createQuery(query.toString());
1443:
1444:                        int queryPos = 0;
1445:
1446:                        q.setLong(queryPos++, groupId);
1447:
1448:                        if (articleId != null) {
1449:                            q.setString(queryPos++, articleId);
1450:                        }
1451:
1452:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1453:
1454:                        FinderCache.putResult(finderClassNameCacheEnabled,
1455:                                finderClassName, finderMethodName,
1456:                                finderParams, finderArgs, list);
1457:
1458:                        return list;
1459:                    } catch (Exception e) {
1460:                        throw HibernateUtil.processException(e);
1461:                    } finally {
1462:                        closeSession(session);
1463:                    }
1464:                } else {
1465:                    return (List) result;
1466:                }
1467:            }
1468:
1469:            public JournalArticle findByG_A_First(long groupId,
1470:                    String articleId, OrderByComparator obc)
1471:                    throws NoSuchArticleException, SystemException {
1472:                List list = findByG_A(groupId, articleId, 0, 1, obc);
1473:
1474:                if (list.size() == 0) {
1475:                    StringMaker msg = new StringMaker();
1476:
1477:                    msg.append("No JournalArticle exists with the key {");
1478:
1479:                    msg.append("groupId=" + groupId);
1480:
1481:                    msg.append(", ");
1482:                    msg.append("articleId=" + articleId);
1483:
1484:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1485:
1486:                    throw new NoSuchArticleException(msg.toString());
1487:                } else {
1488:                    return (JournalArticle) list.get(0);
1489:                }
1490:            }
1491:
1492:            public JournalArticle findByG_A_Last(long groupId,
1493:                    String articleId, OrderByComparator obc)
1494:                    throws NoSuchArticleException, SystemException {
1495:                int count = countByG_A(groupId, articleId);
1496:
1497:                List list = findByG_A(groupId, articleId, count - 1, count, obc);
1498:
1499:                if (list.size() == 0) {
1500:                    StringMaker msg = new StringMaker();
1501:
1502:                    msg.append("No JournalArticle exists with the key {");
1503:
1504:                    msg.append("groupId=" + groupId);
1505:
1506:                    msg.append(", ");
1507:                    msg.append("articleId=" + articleId);
1508:
1509:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1510:
1511:                    throw new NoSuchArticleException(msg.toString());
1512:                } else {
1513:                    return (JournalArticle) list.get(0);
1514:                }
1515:            }
1516:
1517:            public JournalArticle[] findByG_A_PrevAndNext(long id,
1518:                    long groupId, String articleId, OrderByComparator obc)
1519:                    throws NoSuchArticleException, SystemException {
1520:                JournalArticle journalArticle = findByPrimaryKey(id);
1521:
1522:                int count = countByG_A(groupId, articleId);
1523:
1524:                Session session = null;
1525:
1526:                try {
1527:                    session = openSession();
1528:
1529:                    StringMaker query = new StringMaker();
1530:
1531:                    query
1532:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1533:
1534:                    query.append("groupId = ?");
1535:
1536:                    query.append(" AND ");
1537:
1538:                    if (articleId == null) {
1539:                        query.append("articleId IS NULL");
1540:                    } else {
1541:                        query.append("articleId = ?");
1542:                    }
1543:
1544:                    query.append(" ");
1545:
1546:                    if (obc != null) {
1547:                        query.append("ORDER BY ");
1548:                        query.append(obc.getOrderBy());
1549:                    }
1550:
1551:                    else {
1552:                        query.append("ORDER BY ");
1553:
1554:                        query.append("articleId ASC, ");
1555:                        query.append("version DESC");
1556:                    }
1557:
1558:                    Query q = session.createQuery(query.toString());
1559:
1560:                    int queryPos = 0;
1561:
1562:                    q.setLong(queryPos++, groupId);
1563:
1564:                    if (articleId != null) {
1565:                        q.setString(queryPos++, articleId);
1566:                    }
1567:
1568:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1569:                            journalArticle);
1570:
1571:                    JournalArticle[] array = new JournalArticleImpl[3];
1572:
1573:                    array[0] = (JournalArticle) objArray[0];
1574:                    array[1] = (JournalArticle) objArray[1];
1575:                    array[2] = (JournalArticle) objArray[2];
1576:
1577:                    return array;
1578:                } catch (Exception e) {
1579:                    throw HibernateUtil.processException(e);
1580:                } finally {
1581:                    closeSession(session);
1582:                }
1583:            }
1584:
1585:            public List findByG_S(long groupId, String structureId)
1586:                    throws SystemException {
1587:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1588:                String finderClassName = JournalArticle.class.getName();
1589:                String finderMethodName = "findByG_S";
1590:                String[] finderParams = new String[] { Long.class.getName(),
1591:                        String.class.getName() };
1592:                Object[] finderArgs = new Object[] { new Long(groupId),
1593:                        structureId };
1594:
1595:                Object result = null;
1596:
1597:                if (finderClassNameCacheEnabled) {
1598:                    result = FinderCache.getResult(finderClassName,
1599:                            finderMethodName, finderParams, finderArgs,
1600:                            getSessionFactory());
1601:                }
1602:
1603:                if (result == null) {
1604:                    Session session = null;
1605:
1606:                    try {
1607:                        session = openSession();
1608:
1609:                        StringMaker query = new StringMaker();
1610:
1611:                        query
1612:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1613:
1614:                        query.append("groupId = ?");
1615:
1616:                        query.append(" AND ");
1617:
1618:                        if (structureId == null) {
1619:                            query.append("structureId IS NULL");
1620:                        } else {
1621:                            query.append("structureId = ?");
1622:                        }
1623:
1624:                        query.append(" ");
1625:
1626:                        query.append("ORDER BY ");
1627:
1628:                        query.append("articleId ASC, ");
1629:                        query.append("version DESC");
1630:
1631:                        Query q = session.createQuery(query.toString());
1632:
1633:                        int queryPos = 0;
1634:
1635:                        q.setLong(queryPos++, groupId);
1636:
1637:                        if (structureId != null) {
1638:                            q.setString(queryPos++, structureId);
1639:                        }
1640:
1641:                        List list = q.list();
1642:
1643:                        FinderCache.putResult(finderClassNameCacheEnabled,
1644:                                finderClassName, finderMethodName,
1645:                                finderParams, finderArgs, list);
1646:
1647:                        return list;
1648:                    } catch (Exception e) {
1649:                        throw HibernateUtil.processException(e);
1650:                    } finally {
1651:                        closeSession(session);
1652:                    }
1653:                } else {
1654:                    return (List) result;
1655:                }
1656:            }
1657:
1658:            public List findByG_S(long groupId, String structureId, int begin,
1659:                    int end) throws SystemException {
1660:                return findByG_S(groupId, structureId, begin, end, null);
1661:            }
1662:
1663:            public List findByG_S(long groupId, String structureId, int begin,
1664:                    int end, OrderByComparator obc) throws SystemException {
1665:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1666:                String finderClassName = JournalArticle.class.getName();
1667:                String finderMethodName = "findByG_S";
1668:                String[] finderParams = new String[] { Long.class.getName(),
1669:                        String.class.getName(),
1670:
1671:                        "java.lang.Integer", "java.lang.Integer",
1672:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1673:                Object[] finderArgs = new Object[] { new Long(groupId),
1674:
1675:                structureId,
1676:
1677:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
1678:
1679:                Object result = null;
1680:
1681:                if (finderClassNameCacheEnabled) {
1682:                    result = FinderCache.getResult(finderClassName,
1683:                            finderMethodName, finderParams, finderArgs,
1684:                            getSessionFactory());
1685:                }
1686:
1687:                if (result == null) {
1688:                    Session session = null;
1689:
1690:                    try {
1691:                        session = openSession();
1692:
1693:                        StringMaker query = new StringMaker();
1694:
1695:                        query
1696:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1697:
1698:                        query.append("groupId = ?");
1699:
1700:                        query.append(" AND ");
1701:
1702:                        if (structureId == null) {
1703:                            query.append("structureId IS NULL");
1704:                        } else {
1705:                            query.append("structureId = ?");
1706:                        }
1707:
1708:                        query.append(" ");
1709:
1710:                        if (obc != null) {
1711:                            query.append("ORDER BY ");
1712:                            query.append(obc.getOrderBy());
1713:                        }
1714:
1715:                        else {
1716:                            query.append("ORDER BY ");
1717:
1718:                            query.append("articleId ASC, ");
1719:                            query.append("version DESC");
1720:                        }
1721:
1722:                        Query q = session.createQuery(query.toString());
1723:
1724:                        int queryPos = 0;
1725:
1726:                        q.setLong(queryPos++, groupId);
1727:
1728:                        if (structureId != null) {
1729:                            q.setString(queryPos++, structureId);
1730:                        }
1731:
1732:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1733:
1734:                        FinderCache.putResult(finderClassNameCacheEnabled,
1735:                                finderClassName, finderMethodName,
1736:                                finderParams, finderArgs, list);
1737:
1738:                        return list;
1739:                    } catch (Exception e) {
1740:                        throw HibernateUtil.processException(e);
1741:                    } finally {
1742:                        closeSession(session);
1743:                    }
1744:                } else {
1745:                    return (List) result;
1746:                }
1747:            }
1748:
1749:            public JournalArticle findByG_S_First(long groupId,
1750:                    String structureId, OrderByComparator obc)
1751:                    throws NoSuchArticleException, SystemException {
1752:                List list = findByG_S(groupId, structureId, 0, 1, obc);
1753:
1754:                if (list.size() == 0) {
1755:                    StringMaker msg = new StringMaker();
1756:
1757:                    msg.append("No JournalArticle exists with the key {");
1758:
1759:                    msg.append("groupId=" + groupId);
1760:
1761:                    msg.append(", ");
1762:                    msg.append("structureId=" + structureId);
1763:
1764:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1765:
1766:                    throw new NoSuchArticleException(msg.toString());
1767:                } else {
1768:                    return (JournalArticle) list.get(0);
1769:                }
1770:            }
1771:
1772:            public JournalArticle findByG_S_Last(long groupId,
1773:                    String structureId, OrderByComparator obc)
1774:                    throws NoSuchArticleException, SystemException {
1775:                int count = countByG_S(groupId, structureId);
1776:
1777:                List list = findByG_S(groupId, structureId, count - 1, count,
1778:                        obc);
1779:
1780:                if (list.size() == 0) {
1781:                    StringMaker msg = new StringMaker();
1782:
1783:                    msg.append("No JournalArticle exists with the key {");
1784:
1785:                    msg.append("groupId=" + groupId);
1786:
1787:                    msg.append(", ");
1788:                    msg.append("structureId=" + structureId);
1789:
1790:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1791:
1792:                    throw new NoSuchArticleException(msg.toString());
1793:                } else {
1794:                    return (JournalArticle) list.get(0);
1795:                }
1796:            }
1797:
1798:            public JournalArticle[] findByG_S_PrevAndNext(long id,
1799:                    long groupId, String structureId, OrderByComparator obc)
1800:                    throws NoSuchArticleException, SystemException {
1801:                JournalArticle journalArticle = findByPrimaryKey(id);
1802:
1803:                int count = countByG_S(groupId, structureId);
1804:
1805:                Session session = null;
1806:
1807:                try {
1808:                    session = openSession();
1809:
1810:                    StringMaker query = new StringMaker();
1811:
1812:                    query
1813:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1814:
1815:                    query.append("groupId = ?");
1816:
1817:                    query.append(" AND ");
1818:
1819:                    if (structureId == null) {
1820:                        query.append("structureId IS NULL");
1821:                    } else {
1822:                        query.append("structureId = ?");
1823:                    }
1824:
1825:                    query.append(" ");
1826:
1827:                    if (obc != null) {
1828:                        query.append("ORDER BY ");
1829:                        query.append(obc.getOrderBy());
1830:                    }
1831:
1832:                    else {
1833:                        query.append("ORDER BY ");
1834:
1835:                        query.append("articleId ASC, ");
1836:                        query.append("version DESC");
1837:                    }
1838:
1839:                    Query q = session.createQuery(query.toString());
1840:
1841:                    int queryPos = 0;
1842:
1843:                    q.setLong(queryPos++, groupId);
1844:
1845:                    if (structureId != null) {
1846:                        q.setString(queryPos++, structureId);
1847:                    }
1848:
1849:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1850:                            journalArticle);
1851:
1852:                    JournalArticle[] array = new JournalArticleImpl[3];
1853:
1854:                    array[0] = (JournalArticle) objArray[0];
1855:                    array[1] = (JournalArticle) objArray[1];
1856:                    array[2] = (JournalArticle) objArray[2];
1857:
1858:                    return array;
1859:                } catch (Exception e) {
1860:                    throw HibernateUtil.processException(e);
1861:                } finally {
1862:                    closeSession(session);
1863:                }
1864:            }
1865:
1866:            public List findByG_T(long groupId, String templateId)
1867:                    throws SystemException {
1868:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1869:                String finderClassName = JournalArticle.class.getName();
1870:                String finderMethodName = "findByG_T";
1871:                String[] finderParams = new String[] { Long.class.getName(),
1872:                        String.class.getName() };
1873:                Object[] finderArgs = new Object[] { new Long(groupId),
1874:                        templateId };
1875:
1876:                Object result = null;
1877:
1878:                if (finderClassNameCacheEnabled) {
1879:                    result = FinderCache.getResult(finderClassName,
1880:                            finderMethodName, finderParams, finderArgs,
1881:                            getSessionFactory());
1882:                }
1883:
1884:                if (result == null) {
1885:                    Session session = null;
1886:
1887:                    try {
1888:                        session = openSession();
1889:
1890:                        StringMaker query = new StringMaker();
1891:
1892:                        query
1893:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1894:
1895:                        query.append("groupId = ?");
1896:
1897:                        query.append(" AND ");
1898:
1899:                        if (templateId == null) {
1900:                            query.append("templateId IS NULL");
1901:                        } else {
1902:                            query.append("templateId = ?");
1903:                        }
1904:
1905:                        query.append(" ");
1906:
1907:                        query.append("ORDER BY ");
1908:
1909:                        query.append("articleId ASC, ");
1910:                        query.append("version DESC");
1911:
1912:                        Query q = session.createQuery(query.toString());
1913:
1914:                        int queryPos = 0;
1915:
1916:                        q.setLong(queryPos++, groupId);
1917:
1918:                        if (templateId != null) {
1919:                            q.setString(queryPos++, templateId);
1920:                        }
1921:
1922:                        List list = q.list();
1923:
1924:                        FinderCache.putResult(finderClassNameCacheEnabled,
1925:                                finderClassName, finderMethodName,
1926:                                finderParams, finderArgs, list);
1927:
1928:                        return list;
1929:                    } catch (Exception e) {
1930:                        throw HibernateUtil.processException(e);
1931:                    } finally {
1932:                        closeSession(session);
1933:                    }
1934:                } else {
1935:                    return (List) result;
1936:                }
1937:            }
1938:
1939:            public List findByG_T(long groupId, String templateId, int begin,
1940:                    int end) throws SystemException {
1941:                return findByG_T(groupId, templateId, begin, end, null);
1942:            }
1943:
1944:            public List findByG_T(long groupId, String templateId, int begin,
1945:                    int end, OrderByComparator obc) throws SystemException {
1946:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1947:                String finderClassName = JournalArticle.class.getName();
1948:                String finderMethodName = "findByG_T";
1949:                String[] finderParams = new String[] { Long.class.getName(),
1950:                        String.class.getName(),
1951:
1952:                        "java.lang.Integer", "java.lang.Integer",
1953:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1954:                Object[] finderArgs = new Object[] { new Long(groupId),
1955:
1956:                templateId,
1957:
1958:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
1959:
1960:                Object result = null;
1961:
1962:                if (finderClassNameCacheEnabled) {
1963:                    result = FinderCache.getResult(finderClassName,
1964:                            finderMethodName, finderParams, finderArgs,
1965:                            getSessionFactory());
1966:                }
1967:
1968:                if (result == null) {
1969:                    Session session = null;
1970:
1971:                    try {
1972:                        session = openSession();
1973:
1974:                        StringMaker query = new StringMaker();
1975:
1976:                        query
1977:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1978:
1979:                        query.append("groupId = ?");
1980:
1981:                        query.append(" AND ");
1982:
1983:                        if (templateId == null) {
1984:                            query.append("templateId IS NULL");
1985:                        } else {
1986:                            query.append("templateId = ?");
1987:                        }
1988:
1989:                        query.append(" ");
1990:
1991:                        if (obc != null) {
1992:                            query.append("ORDER BY ");
1993:                            query.append(obc.getOrderBy());
1994:                        }
1995:
1996:                        else {
1997:                            query.append("ORDER BY ");
1998:
1999:                            query.append("articleId ASC, ");
2000:                            query.append("version DESC");
2001:                        }
2002:
2003:                        Query q = session.createQuery(query.toString());
2004:
2005:                        int queryPos = 0;
2006:
2007:                        q.setLong(queryPos++, groupId);
2008:
2009:                        if (templateId != null) {
2010:                            q.setString(queryPos++, templateId);
2011:                        }
2012:
2013:                        List list = QueryUtil.list(q, getDialect(), begin, end);
2014:
2015:                        FinderCache.putResult(finderClassNameCacheEnabled,
2016:                                finderClassName, finderMethodName,
2017:                                finderParams, finderArgs, list);
2018:
2019:                        return list;
2020:                    } catch (Exception e) {
2021:                        throw HibernateUtil.processException(e);
2022:                    } finally {
2023:                        closeSession(session);
2024:                    }
2025:                } else {
2026:                    return (List) result;
2027:                }
2028:            }
2029:
2030:            public JournalArticle findByG_T_First(long groupId,
2031:                    String templateId, OrderByComparator obc)
2032:                    throws NoSuchArticleException, SystemException {
2033:                List list = findByG_T(groupId, templateId, 0, 1, obc);
2034:
2035:                if (list.size() == 0) {
2036:                    StringMaker msg = new StringMaker();
2037:
2038:                    msg.append("No JournalArticle exists with the key {");
2039:
2040:                    msg.append("groupId=" + groupId);
2041:
2042:                    msg.append(", ");
2043:                    msg.append("templateId=" + templateId);
2044:
2045:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2046:
2047:                    throw new NoSuchArticleException(msg.toString());
2048:                } else {
2049:                    return (JournalArticle) list.get(0);
2050:                }
2051:            }
2052:
2053:            public JournalArticle findByG_T_Last(long groupId,
2054:                    String templateId, OrderByComparator obc)
2055:                    throws NoSuchArticleException, SystemException {
2056:                int count = countByG_T(groupId, templateId);
2057:
2058:                List list = findByG_T(groupId, templateId, count - 1, count,
2059:                        obc);
2060:
2061:                if (list.size() == 0) {
2062:                    StringMaker msg = new StringMaker();
2063:
2064:                    msg.append("No JournalArticle exists with the key {");
2065:
2066:                    msg.append("groupId=" + groupId);
2067:
2068:                    msg.append(", ");
2069:                    msg.append("templateId=" + templateId);
2070:
2071:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2072:
2073:                    throw new NoSuchArticleException(msg.toString());
2074:                } else {
2075:                    return (JournalArticle) list.get(0);
2076:                }
2077:            }
2078:
2079:            public JournalArticle[] findByG_T_PrevAndNext(long id,
2080:                    long groupId, String templateId, OrderByComparator obc)
2081:                    throws NoSuchArticleException, SystemException {
2082:                JournalArticle journalArticle = findByPrimaryKey(id);
2083:
2084:                int count = countByG_T(groupId, templateId);
2085:
2086:                Session session = null;
2087:
2088:                try {
2089:                    session = openSession();
2090:
2091:                    StringMaker query = new StringMaker();
2092:
2093:                    query
2094:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2095:
2096:                    query.append("groupId = ?");
2097:
2098:                    query.append(" AND ");
2099:
2100:                    if (templateId == null) {
2101:                        query.append("templateId IS NULL");
2102:                    } else {
2103:                        query.append("templateId = ?");
2104:                    }
2105:
2106:                    query.append(" ");
2107:
2108:                    if (obc != null) {
2109:                        query.append("ORDER BY ");
2110:                        query.append(obc.getOrderBy());
2111:                    }
2112:
2113:                    else {
2114:                        query.append("ORDER BY ");
2115:
2116:                        query.append("articleId ASC, ");
2117:                        query.append("version DESC");
2118:                    }
2119:
2120:                    Query q = session.createQuery(query.toString());
2121:
2122:                    int queryPos = 0;
2123:
2124:                    q.setLong(queryPos++, groupId);
2125:
2126:                    if (templateId != null) {
2127:                        q.setString(queryPos++, templateId);
2128:                    }
2129:
2130:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2131:                            journalArticle);
2132:
2133:                    JournalArticle[] array = new JournalArticleImpl[3];
2134:
2135:                    array[0] = (JournalArticle) objArray[0];
2136:                    array[1] = (JournalArticle) objArray[1];
2137:                    array[2] = (JournalArticle) objArray[2];
2138:
2139:                    return array;
2140:                } catch (Exception e) {
2141:                    throw HibernateUtil.processException(e);
2142:                } finally {
2143:                    closeSession(session);
2144:                }
2145:            }
2146:
2147:            public JournalArticle findByG_A_V(long groupId, String articleId,
2148:                    double version) throws NoSuchArticleException,
2149:                    SystemException {
2150:                JournalArticle journalArticle = fetchByG_A_V(groupId,
2151:                        articleId, version);
2152:
2153:                if (journalArticle == null) {
2154:                    StringMaker msg = new StringMaker();
2155:
2156:                    msg.append("No JournalArticle exists with the key {");
2157:
2158:                    msg.append("groupId=" + groupId);
2159:
2160:                    msg.append(", ");
2161:                    msg.append("articleId=" + articleId);
2162:
2163:                    msg.append(", ");
2164:                    msg.append("version=" + version);
2165:
2166:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2167:
2168:                    if (_log.isWarnEnabled()) {
2169:                        _log.warn(msg.toString());
2170:                    }
2171:
2172:                    throw new NoSuchArticleException(msg.toString());
2173:                }
2174:
2175:                return journalArticle;
2176:            }
2177:
2178:            public JournalArticle fetchByG_A_V(long groupId, String articleId,
2179:                    double version) throws SystemException {
2180:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2181:                String finderClassName = JournalArticle.class.getName();
2182:                String finderMethodName = "fetchByG_A_V";
2183:                String[] finderParams = new String[] { Long.class.getName(),
2184:                        String.class.getName(), Double.class.getName() };
2185:                Object[] finderArgs = new Object[] { new Long(groupId),
2186:
2187:                articleId, new Double(version) };
2188:
2189:                Object result = null;
2190:
2191:                if (finderClassNameCacheEnabled) {
2192:                    result = FinderCache.getResult(finderClassName,
2193:                            finderMethodName, finderParams, finderArgs,
2194:                            getSessionFactory());
2195:                }
2196:
2197:                if (result == null) {
2198:                    Session session = null;
2199:
2200:                    try {
2201:                        session = openSession();
2202:
2203:                        StringMaker query = new StringMaker();
2204:
2205:                        query
2206:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2207:
2208:                        query.append("groupId = ?");
2209:
2210:                        query.append(" AND ");
2211:
2212:                        if (articleId == null) {
2213:                            query.append("articleId IS NULL");
2214:                        } else {
2215:                            query.append("articleId = ?");
2216:                        }
2217:
2218:                        query.append(" AND ");
2219:
2220:                        query.append("version = ?");
2221:
2222:                        query.append(" ");
2223:
2224:                        query.append("ORDER BY ");
2225:
2226:                        query.append("articleId ASC, ");
2227:                        query.append("version DESC");
2228:
2229:                        Query q = session.createQuery(query.toString());
2230:
2231:                        int queryPos = 0;
2232:
2233:                        q.setLong(queryPos++, groupId);
2234:
2235:                        if (articleId != null) {
2236:                            q.setString(queryPos++, articleId);
2237:                        }
2238:
2239:                        q.setDouble(queryPos++, version);
2240:
2241:                        List list = q.list();
2242:
2243:                        FinderCache.putResult(finderClassNameCacheEnabled,
2244:                                finderClassName, finderMethodName,
2245:                                finderParams, finderArgs, list);
2246:
2247:                        if (list.size() == 0) {
2248:                            return null;
2249:                        } else {
2250:                            return (JournalArticle) list.get(0);
2251:                        }
2252:                    } catch (Exception e) {
2253:                        throw HibernateUtil.processException(e);
2254:                    } finally {
2255:                        closeSession(session);
2256:                    }
2257:                } else {
2258:                    List list = (List) result;
2259:
2260:                    if (list.size() == 0) {
2261:                        return null;
2262:                    } else {
2263:                        return (JournalArticle) list.get(0);
2264:                    }
2265:                }
2266:            }
2267:
2268:            public List findByG_A_A(long groupId, String articleId,
2269:                    boolean approved) throws SystemException {
2270:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2271:                String finderClassName = JournalArticle.class.getName();
2272:                String finderMethodName = "findByG_A_A";
2273:                String[] finderParams = new String[] { Long.class.getName(),
2274:                        String.class.getName(), Boolean.class.getName() };
2275:                Object[] finderArgs = new Object[] { new Long(groupId),
2276:
2277:                articleId, Boolean.valueOf(approved) };
2278:
2279:                Object result = null;
2280:
2281:                if (finderClassNameCacheEnabled) {
2282:                    result = FinderCache.getResult(finderClassName,
2283:                            finderMethodName, finderParams, finderArgs,
2284:                            getSessionFactory());
2285:                }
2286:
2287:                if (result == null) {
2288:                    Session session = null;
2289:
2290:                    try {
2291:                        session = openSession();
2292:
2293:                        StringMaker query = new StringMaker();
2294:
2295:                        query
2296:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2297:
2298:                        query.append("groupId = ?");
2299:
2300:                        query.append(" AND ");
2301:
2302:                        if (articleId == null) {
2303:                            query.append("articleId IS NULL");
2304:                        } else {
2305:                            query.append("articleId = ?");
2306:                        }
2307:
2308:                        query.append(" AND ");
2309:
2310:                        query.append("approved = ?");
2311:
2312:                        query.append(" ");
2313:
2314:                        query.append("ORDER BY ");
2315:
2316:                        query.append("articleId ASC, ");
2317:                        query.append("version DESC");
2318:
2319:                        Query q = session.createQuery(query.toString());
2320:
2321:                        int queryPos = 0;
2322:
2323:                        q.setLong(queryPos++, groupId);
2324:
2325:                        if (articleId != null) {
2326:                            q.setString(queryPos++, articleId);
2327:                        }
2328:
2329:                        q.setBoolean(queryPos++, approved);
2330:
2331:                        List list = q.list();
2332:
2333:                        FinderCache.putResult(finderClassNameCacheEnabled,
2334:                                finderClassName, finderMethodName,
2335:                                finderParams, finderArgs, list);
2336:
2337:                        return list;
2338:                    } catch (Exception e) {
2339:                        throw HibernateUtil.processException(e);
2340:                    } finally {
2341:                        closeSession(session);
2342:                    }
2343:                } else {
2344:                    return (List) result;
2345:                }
2346:            }
2347:
2348:            public List findByG_A_A(long groupId, String articleId,
2349:                    boolean approved, int begin, int end)
2350:                    throws SystemException {
2351:                return findByG_A_A(groupId, articleId, approved, begin, end,
2352:                        null);
2353:            }
2354:
2355:            public List findByG_A_A(long groupId, String articleId,
2356:                    boolean approved, int begin, int end, OrderByComparator obc)
2357:                    throws SystemException {
2358:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2359:                String finderClassName = JournalArticle.class.getName();
2360:                String finderMethodName = "findByG_A_A";
2361:                String[] finderParams = new String[] { Long.class.getName(),
2362:                        String.class.getName(), Boolean.class.getName(),
2363:
2364:                        "java.lang.Integer", "java.lang.Integer",
2365:                        "com.liferay.portal.kernel.util.OrderByComparator" };
2366:                Object[] finderArgs = new Object[] { new Long(groupId),
2367:
2368:                articleId, Boolean.valueOf(approved),
2369:
2370:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
2371:
2372:                Object result = null;
2373:
2374:                if (finderClassNameCacheEnabled) {
2375:                    result = FinderCache.getResult(finderClassName,
2376:                            finderMethodName, finderParams, finderArgs,
2377:                            getSessionFactory());
2378:                }
2379:
2380:                if (result == null) {
2381:                    Session session = null;
2382:
2383:                    try {
2384:                        session = openSession();
2385:
2386:                        StringMaker query = new StringMaker();
2387:
2388:                        query
2389:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2390:
2391:                        query.append("groupId = ?");
2392:
2393:                        query.append(" AND ");
2394:
2395:                        if (articleId == null) {
2396:                            query.append("articleId IS NULL");
2397:                        } else {
2398:                            query.append("articleId = ?");
2399:                        }
2400:
2401:                        query.append(" AND ");
2402:
2403:                        query.append("approved = ?");
2404:
2405:                        query.append(" ");
2406:
2407:                        if (obc != null) {
2408:                            query.append("ORDER BY ");
2409:                            query.append(obc.getOrderBy());
2410:                        }
2411:
2412:                        else {
2413:                            query.append("ORDER BY ");
2414:
2415:                            query.append("articleId ASC, ");
2416:                            query.append("version DESC");
2417:                        }
2418:
2419:                        Query q = session.createQuery(query.toString());
2420:
2421:                        int queryPos = 0;
2422:
2423:                        q.setLong(queryPos++, groupId);
2424:
2425:                        if (articleId != null) {
2426:                            q.setString(queryPos++, articleId);
2427:                        }
2428:
2429:                        q.setBoolean(queryPos++, approved);
2430:
2431:                        List list = QueryUtil.list(q, getDialect(), begin, end);
2432:
2433:                        FinderCache.putResult(finderClassNameCacheEnabled,
2434:                                finderClassName, finderMethodName,
2435:                                finderParams, finderArgs, list);
2436:
2437:                        return list;
2438:                    } catch (Exception e) {
2439:                        throw HibernateUtil.processException(e);
2440:                    } finally {
2441:                        closeSession(session);
2442:                    }
2443:                } else {
2444:                    return (List) result;
2445:                }
2446:            }
2447:
2448:            public JournalArticle findByG_A_A_First(long groupId,
2449:                    String articleId, boolean approved, OrderByComparator obc)
2450:                    throws NoSuchArticleException, SystemException {
2451:                List list = findByG_A_A(groupId, articleId, approved, 0, 1, obc);
2452:
2453:                if (list.size() == 0) {
2454:                    StringMaker msg = new StringMaker();
2455:
2456:                    msg.append("No JournalArticle exists with the key {");
2457:
2458:                    msg.append("groupId=" + groupId);
2459:
2460:                    msg.append(", ");
2461:                    msg.append("articleId=" + articleId);
2462:
2463:                    msg.append(", ");
2464:                    msg.append("approved=" + approved);
2465:
2466:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2467:
2468:                    throw new NoSuchArticleException(msg.toString());
2469:                } else {
2470:                    return (JournalArticle) list.get(0);
2471:                }
2472:            }
2473:
2474:            public JournalArticle findByG_A_A_Last(long groupId,
2475:                    String articleId, boolean approved, OrderByComparator obc)
2476:                    throws NoSuchArticleException, SystemException {
2477:                int count = countByG_A_A(groupId, articleId, approved);
2478:
2479:                List list = findByG_A_A(groupId, articleId, approved,
2480:                        count - 1, count, obc);
2481:
2482:                if (list.size() == 0) {
2483:                    StringMaker msg = new StringMaker();
2484:
2485:                    msg.append("No JournalArticle exists with the key {");
2486:
2487:                    msg.append("groupId=" + groupId);
2488:
2489:                    msg.append(", ");
2490:                    msg.append("articleId=" + articleId);
2491:
2492:                    msg.append(", ");
2493:                    msg.append("approved=" + approved);
2494:
2495:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2496:
2497:                    throw new NoSuchArticleException(msg.toString());
2498:                } else {
2499:                    return (JournalArticle) list.get(0);
2500:                }
2501:            }
2502:
2503:            public JournalArticle[] findByG_A_A_PrevAndNext(long id,
2504:                    long groupId, String articleId, boolean approved,
2505:                    OrderByComparator obc) throws NoSuchArticleException,
2506:                    SystemException {
2507:                JournalArticle journalArticle = findByPrimaryKey(id);
2508:
2509:                int count = countByG_A_A(groupId, articleId, approved);
2510:
2511:                Session session = null;
2512:
2513:                try {
2514:                    session = openSession();
2515:
2516:                    StringMaker query = new StringMaker();
2517:
2518:                    query
2519:                            .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2520:
2521:                    query.append("groupId = ?");
2522:
2523:                    query.append(" AND ");
2524:
2525:                    if (articleId == null) {
2526:                        query.append("articleId IS NULL");
2527:                    } else {
2528:                        query.append("articleId = ?");
2529:                    }
2530:
2531:                    query.append(" AND ");
2532:
2533:                    query.append("approved = ?");
2534:
2535:                    query.append(" ");
2536:
2537:                    if (obc != null) {
2538:                        query.append("ORDER BY ");
2539:                        query.append(obc.getOrderBy());
2540:                    }
2541:
2542:                    else {
2543:                        query.append("ORDER BY ");
2544:
2545:                        query.append("articleId ASC, ");
2546:                        query.append("version DESC");
2547:                    }
2548:
2549:                    Query q = session.createQuery(query.toString());
2550:
2551:                    int queryPos = 0;
2552:
2553:                    q.setLong(queryPos++, groupId);
2554:
2555:                    if (articleId != null) {
2556:                        q.setString(queryPos++, articleId);
2557:                    }
2558:
2559:                    q.setBoolean(queryPos++, approved);
2560:
2561:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2562:                            journalArticle);
2563:
2564:                    JournalArticle[] array = new JournalArticleImpl[3];
2565:
2566:                    array[0] = (JournalArticle) objArray[0];
2567:                    array[1] = (JournalArticle) objArray[1];
2568:                    array[2] = (JournalArticle) objArray[2];
2569:
2570:                    return array;
2571:                } catch (Exception e) {
2572:                    throw HibernateUtil.processException(e);
2573:                } finally {
2574:                    closeSession(session);
2575:                }
2576:            }
2577:
2578:            public List findWithDynamicQuery(
2579:                    DynamicQueryInitializer queryInitializer)
2580:                    throws SystemException {
2581:                Session session = null;
2582:
2583:                try {
2584:                    session = openSession();
2585:
2586:                    DynamicQuery query = queryInitializer.initialize(session);
2587:
2588:                    return query.list();
2589:                } catch (Exception e) {
2590:                    throw HibernateUtil.processException(e);
2591:                } finally {
2592:                    closeSession(session);
2593:                }
2594:            }
2595:
2596:            public List findWithDynamicQuery(
2597:                    DynamicQueryInitializer queryInitializer, int begin, int end)
2598:                    throws SystemException {
2599:                Session session = null;
2600:
2601:                try {
2602:                    session = openSession();
2603:
2604:                    DynamicQuery query = queryInitializer.initialize(session);
2605:
2606:                    query.setLimit(begin, end);
2607:
2608:                    return query.list();
2609:                } catch (Exception e) {
2610:                    throw HibernateUtil.processException(e);
2611:                } finally {
2612:                    closeSession(session);
2613:                }
2614:            }
2615:
2616:            public List findAll() throws SystemException {
2617:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2618:            }
2619:
2620:            public List findAll(int begin, int end) throws SystemException {
2621:                return findAll(begin, end, null);
2622:            }
2623:
2624:            public List findAll(int begin, int end, OrderByComparator obc)
2625:                    throws SystemException {
2626:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2627:                String finderClassName = JournalArticle.class.getName();
2628:                String finderMethodName = "findAll";
2629:                String[] finderParams = new String[] { "java.lang.Integer",
2630:                        "java.lang.Integer",
2631:                        "com.liferay.portal.kernel.util.OrderByComparator" };
2632:                Object[] finderArgs = new Object[] { String.valueOf(begin),
2633:                        String.valueOf(end), String.valueOf(obc) };
2634:
2635:                Object result = null;
2636:
2637:                if (finderClassNameCacheEnabled) {
2638:                    result = FinderCache.getResult(finderClassName,
2639:                            finderMethodName, finderParams, finderArgs,
2640:                            getSessionFactory());
2641:                }
2642:
2643:                if (result == null) {
2644:                    Session session = null;
2645:
2646:                    try {
2647:                        session = openSession();
2648:
2649:                        StringMaker query = new StringMaker();
2650:
2651:                        query
2652:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle ");
2653:
2654:                        if (obc != null) {
2655:                            query.append("ORDER BY ");
2656:                            query.append(obc.getOrderBy());
2657:                        }
2658:
2659:                        else {
2660:                            query.append("ORDER BY ");
2661:
2662:                            query.append("articleId ASC, ");
2663:                            query.append("version DESC");
2664:                        }
2665:
2666:                        Query q = session.createQuery(query.toString());
2667:
2668:                        List list = QueryUtil.list(q, getDialect(), begin, end);
2669:
2670:                        if (obc == null) {
2671:                            Collections.sort(list);
2672:                        }
2673:
2674:                        FinderCache.putResult(finderClassNameCacheEnabled,
2675:                                finderClassName, finderMethodName,
2676:                                finderParams, finderArgs, list);
2677:
2678:                        return list;
2679:                    } catch (Exception e) {
2680:                        throw HibernateUtil.processException(e);
2681:                    } finally {
2682:                        closeSession(session);
2683:                    }
2684:                } else {
2685:                    return (List) result;
2686:                }
2687:            }
2688:
2689:            public void removeByUuid(String uuid) throws SystemException {
2690:                Iterator itr = findByUuid(uuid).iterator();
2691:
2692:                while (itr.hasNext()) {
2693:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2694:
2695:                    remove(journalArticle);
2696:                }
2697:            }
2698:
2699:            public void removeByUUID_G(String uuid, long groupId)
2700:                    throws NoSuchArticleException, SystemException {
2701:                JournalArticle journalArticle = findByUUID_G(uuid, groupId);
2702:
2703:                remove(journalArticle);
2704:            }
2705:
2706:            public void removeByGroupId(long groupId) throws SystemException {
2707:                Iterator itr = findByGroupId(groupId).iterator();
2708:
2709:                while (itr.hasNext()) {
2710:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2711:
2712:                    remove(journalArticle);
2713:                }
2714:            }
2715:
2716:            public void removeByCompanyId(long companyId)
2717:                    throws SystemException {
2718:                Iterator itr = findByCompanyId(companyId).iterator();
2719:
2720:                while (itr.hasNext()) {
2721:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2722:
2723:                    remove(journalArticle);
2724:                }
2725:            }
2726:
2727:            public void removeBySmallImageId(long smallImageId)
2728:                    throws SystemException {
2729:                Iterator itr = findBySmallImageId(smallImageId).iterator();
2730:
2731:                while (itr.hasNext()) {
2732:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2733:
2734:                    remove(journalArticle);
2735:                }
2736:            }
2737:
2738:            public void removeByG_A(long groupId, String articleId)
2739:                    throws SystemException {
2740:                Iterator itr = findByG_A(groupId, articleId).iterator();
2741:
2742:                while (itr.hasNext()) {
2743:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2744:
2745:                    remove(journalArticle);
2746:                }
2747:            }
2748:
2749:            public void removeByG_S(long groupId, String structureId)
2750:                    throws SystemException {
2751:                Iterator itr = findByG_S(groupId, structureId).iterator();
2752:
2753:                while (itr.hasNext()) {
2754:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2755:
2756:                    remove(journalArticle);
2757:                }
2758:            }
2759:
2760:            public void removeByG_T(long groupId, String templateId)
2761:                    throws SystemException {
2762:                Iterator itr = findByG_T(groupId, templateId).iterator();
2763:
2764:                while (itr.hasNext()) {
2765:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2766:
2767:                    remove(journalArticle);
2768:                }
2769:            }
2770:
2771:            public void removeByG_A_V(long groupId, String articleId,
2772:                    double version) throws NoSuchArticleException,
2773:                    SystemException {
2774:                JournalArticle journalArticle = findByG_A_V(groupId, articleId,
2775:                        version);
2776:
2777:                remove(journalArticle);
2778:            }
2779:
2780:            public void removeByG_A_A(long groupId, String articleId,
2781:                    boolean approved) throws SystemException {
2782:                Iterator itr = findByG_A_A(groupId, articleId, approved)
2783:                        .iterator();
2784:
2785:                while (itr.hasNext()) {
2786:                    JournalArticle journalArticle = (JournalArticle) itr.next();
2787:
2788:                    remove(journalArticle);
2789:                }
2790:            }
2791:
2792:            public void removeAll() throws SystemException {
2793:                Iterator itr = findAll().iterator();
2794:
2795:                while (itr.hasNext()) {
2796:                    remove((JournalArticle) itr.next());
2797:                }
2798:            }
2799:
2800:            public int countByUuid(String uuid) throws SystemException {
2801:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2802:                String finderClassName = JournalArticle.class.getName();
2803:                String finderMethodName = "countByUuid";
2804:                String[] finderParams = new String[] { String.class.getName() };
2805:                Object[] finderArgs = new Object[] { uuid };
2806:
2807:                Object result = null;
2808:
2809:                if (finderClassNameCacheEnabled) {
2810:                    result = FinderCache.getResult(finderClassName,
2811:                            finderMethodName, finderParams, finderArgs,
2812:                            getSessionFactory());
2813:                }
2814:
2815:                if (result == null) {
2816:                    Session session = null;
2817:
2818:                    try {
2819:                        session = openSession();
2820:
2821:                        StringMaker query = new StringMaker();
2822:
2823:                        query.append("SELECT COUNT(*) ");
2824:                        query
2825:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2826:
2827:                        if (uuid == null) {
2828:                            query.append("uuid_ IS NULL");
2829:                        } else {
2830:                            query.append("uuid_ = ?");
2831:                        }
2832:
2833:                        query.append(" ");
2834:
2835:                        Query q = session.createQuery(query.toString());
2836:
2837:                        int queryPos = 0;
2838:
2839:                        if (uuid != null) {
2840:                            q.setString(queryPos++, uuid);
2841:                        }
2842:
2843:                        Long count = null;
2844:
2845:                        Iterator itr = q.list().iterator();
2846:
2847:                        if (itr.hasNext()) {
2848:                            count = (Long) itr.next();
2849:                        }
2850:
2851:                        if (count == null) {
2852:                            count = new Long(0);
2853:                        }
2854:
2855:                        FinderCache.putResult(finderClassNameCacheEnabled,
2856:                                finderClassName, finderMethodName,
2857:                                finderParams, finderArgs, count);
2858:
2859:                        return count.intValue();
2860:                    } catch (Exception e) {
2861:                        throw HibernateUtil.processException(e);
2862:                    } finally {
2863:                        closeSession(session);
2864:                    }
2865:                } else {
2866:                    return ((Long) result).intValue();
2867:                }
2868:            }
2869:
2870:            public int countByUUID_G(String uuid, long groupId)
2871:                    throws SystemException {
2872:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2873:                String finderClassName = JournalArticle.class.getName();
2874:                String finderMethodName = "countByUUID_G";
2875:                String[] finderParams = new String[] { String.class.getName(),
2876:                        Long.class.getName() };
2877:                Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2878:
2879:                Object result = null;
2880:
2881:                if (finderClassNameCacheEnabled) {
2882:                    result = FinderCache.getResult(finderClassName,
2883:                            finderMethodName, finderParams, finderArgs,
2884:                            getSessionFactory());
2885:                }
2886:
2887:                if (result == null) {
2888:                    Session session = null;
2889:
2890:                    try {
2891:                        session = openSession();
2892:
2893:                        StringMaker query = new StringMaker();
2894:
2895:                        query.append("SELECT COUNT(*) ");
2896:                        query
2897:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2898:
2899:                        if (uuid == null) {
2900:                            query.append("uuid_ IS NULL");
2901:                        } else {
2902:                            query.append("uuid_ = ?");
2903:                        }
2904:
2905:                        query.append(" AND ");
2906:
2907:                        query.append("groupId = ?");
2908:
2909:                        query.append(" ");
2910:
2911:                        Query q = session.createQuery(query.toString());
2912:
2913:                        int queryPos = 0;
2914:
2915:                        if (uuid != null) {
2916:                            q.setString(queryPos++, uuid);
2917:                        }
2918:
2919:                        q.setLong(queryPos++, groupId);
2920:
2921:                        Long count = null;
2922:
2923:                        Iterator itr = q.list().iterator();
2924:
2925:                        if (itr.hasNext()) {
2926:                            count = (Long) itr.next();
2927:                        }
2928:
2929:                        if (count == null) {
2930:                            count = new Long(0);
2931:                        }
2932:
2933:                        FinderCache.putResult(finderClassNameCacheEnabled,
2934:                                finderClassName, finderMethodName,
2935:                                finderParams, finderArgs, count);
2936:
2937:                        return count.intValue();
2938:                    } catch (Exception e) {
2939:                        throw HibernateUtil.processException(e);
2940:                    } finally {
2941:                        closeSession(session);
2942:                    }
2943:                } else {
2944:                    return ((Long) result).intValue();
2945:                }
2946:            }
2947:
2948:            public int countByGroupId(long groupId) throws SystemException {
2949:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2950:                String finderClassName = JournalArticle.class.getName();
2951:                String finderMethodName = "countByGroupId";
2952:                String[] finderParams = new String[] { Long.class.getName() };
2953:                Object[] finderArgs = new Object[] { new Long(groupId) };
2954:
2955:                Object result = null;
2956:
2957:                if (finderClassNameCacheEnabled) {
2958:                    result = FinderCache.getResult(finderClassName,
2959:                            finderMethodName, finderParams, finderArgs,
2960:                            getSessionFactory());
2961:                }
2962:
2963:                if (result == null) {
2964:                    Session session = null;
2965:
2966:                    try {
2967:                        session = openSession();
2968:
2969:                        StringMaker query = new StringMaker();
2970:
2971:                        query.append("SELECT COUNT(*) ");
2972:                        query
2973:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2974:
2975:                        query.append("groupId = ?");
2976:
2977:                        query.append(" ");
2978:
2979:                        Query q = session.createQuery(query.toString());
2980:
2981:                        int queryPos = 0;
2982:
2983:                        q.setLong(queryPos++, groupId);
2984:
2985:                        Long count = null;
2986:
2987:                        Iterator itr = q.list().iterator();
2988:
2989:                        if (itr.hasNext()) {
2990:                            count = (Long) itr.next();
2991:                        }
2992:
2993:                        if (count == null) {
2994:                            count = new Long(0);
2995:                        }
2996:
2997:                        FinderCache.putResult(finderClassNameCacheEnabled,
2998:                                finderClassName, finderMethodName,
2999:                                finderParams, finderArgs, count);
3000:
3001:                        return count.intValue();
3002:                    } catch (Exception e) {
3003:                        throw HibernateUtil.processException(e);
3004:                    } finally {
3005:                        closeSession(session);
3006:                    }
3007:                } else {
3008:                    return ((Long) result).intValue();
3009:                }
3010:            }
3011:
3012:            public int countByCompanyId(long companyId) throws SystemException {
3013:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3014:                String finderClassName = JournalArticle.class.getName();
3015:                String finderMethodName = "countByCompanyId";
3016:                String[] finderParams = new String[] { Long.class.getName() };
3017:                Object[] finderArgs = new Object[] { new Long(companyId) };
3018:
3019:                Object result = null;
3020:
3021:                if (finderClassNameCacheEnabled) {
3022:                    result = FinderCache.getResult(finderClassName,
3023:                            finderMethodName, finderParams, finderArgs,
3024:                            getSessionFactory());
3025:                }
3026:
3027:                if (result == null) {
3028:                    Session session = null;
3029:
3030:                    try {
3031:                        session = openSession();
3032:
3033:                        StringMaker query = new StringMaker();
3034:
3035:                        query.append("SELECT COUNT(*) ");
3036:                        query
3037:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3038:
3039:                        query.append("companyId = ?");
3040:
3041:                        query.append(" ");
3042:
3043:                        Query q = session.createQuery(query.toString());
3044:
3045:                        int queryPos = 0;
3046:
3047:                        q.setLong(queryPos++, companyId);
3048:
3049:                        Long count = null;
3050:
3051:                        Iterator itr = q.list().iterator();
3052:
3053:                        if (itr.hasNext()) {
3054:                            count = (Long) itr.next();
3055:                        }
3056:
3057:                        if (count == null) {
3058:                            count = new Long(0);
3059:                        }
3060:
3061:                        FinderCache.putResult(finderClassNameCacheEnabled,
3062:                                finderClassName, finderMethodName,
3063:                                finderParams, finderArgs, count);
3064:
3065:                        return count.intValue();
3066:                    } catch (Exception e) {
3067:                        throw HibernateUtil.processException(e);
3068:                    } finally {
3069:                        closeSession(session);
3070:                    }
3071:                } else {
3072:                    return ((Long) result).intValue();
3073:                }
3074:            }
3075:
3076:            public int countBySmallImageId(long smallImageId)
3077:                    throws SystemException {
3078:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3079:                String finderClassName = JournalArticle.class.getName();
3080:                String finderMethodName = "countBySmallImageId";
3081:                String[] finderParams = new String[] { Long.class.getName() };
3082:                Object[] finderArgs = new Object[] { new Long(smallImageId) };
3083:
3084:                Object result = null;
3085:
3086:                if (finderClassNameCacheEnabled) {
3087:                    result = FinderCache.getResult(finderClassName,
3088:                            finderMethodName, finderParams, finderArgs,
3089:                            getSessionFactory());
3090:                }
3091:
3092:                if (result == null) {
3093:                    Session session = null;
3094:
3095:                    try {
3096:                        session = openSession();
3097:
3098:                        StringMaker query = new StringMaker();
3099:
3100:                        query.append("SELECT COUNT(*) ");
3101:                        query
3102:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3103:
3104:                        query.append("smallImageId = ?");
3105:
3106:                        query.append(" ");
3107:
3108:                        Query q = session.createQuery(query.toString());
3109:
3110:                        int queryPos = 0;
3111:
3112:                        q.setLong(queryPos++, smallImageId);
3113:
3114:                        Long count = null;
3115:
3116:                        Iterator itr = q.list().iterator();
3117:
3118:                        if (itr.hasNext()) {
3119:                            count = (Long) itr.next();
3120:                        }
3121:
3122:                        if (count == null) {
3123:                            count = new Long(0);
3124:                        }
3125:
3126:                        FinderCache.putResult(finderClassNameCacheEnabled,
3127:                                finderClassName, finderMethodName,
3128:                                finderParams, finderArgs, count);
3129:
3130:                        return count.intValue();
3131:                    } catch (Exception e) {
3132:                        throw HibernateUtil.processException(e);
3133:                    } finally {
3134:                        closeSession(session);
3135:                    }
3136:                } else {
3137:                    return ((Long) result).intValue();
3138:                }
3139:            }
3140:
3141:            public int countByG_A(long groupId, String articleId)
3142:                    throws SystemException {
3143:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3144:                String finderClassName = JournalArticle.class.getName();
3145:                String finderMethodName = "countByG_A";
3146:                String[] finderParams = new String[] { Long.class.getName(),
3147:                        String.class.getName() };
3148:                Object[] finderArgs = new Object[] { new Long(groupId),
3149:                        articleId };
3150:
3151:                Object result = null;
3152:
3153:                if (finderClassNameCacheEnabled) {
3154:                    result = FinderCache.getResult(finderClassName,
3155:                            finderMethodName, finderParams, finderArgs,
3156:                            getSessionFactory());
3157:                }
3158:
3159:                if (result == null) {
3160:                    Session session = null;
3161:
3162:                    try {
3163:                        session = openSession();
3164:
3165:                        StringMaker query = new StringMaker();
3166:
3167:                        query.append("SELECT COUNT(*) ");
3168:                        query
3169:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3170:
3171:                        query.append("groupId = ?");
3172:
3173:                        query.append(" AND ");
3174:
3175:                        if (articleId == null) {
3176:                            query.append("articleId IS NULL");
3177:                        } else {
3178:                            query.append("articleId = ?");
3179:                        }
3180:
3181:                        query.append(" ");
3182:
3183:                        Query q = session.createQuery(query.toString());
3184:
3185:                        int queryPos = 0;
3186:
3187:                        q.setLong(queryPos++, groupId);
3188:
3189:                        if (articleId != null) {
3190:                            q.setString(queryPos++, articleId);
3191:                        }
3192:
3193:                        Long count = null;
3194:
3195:                        Iterator itr = q.list().iterator();
3196:
3197:                        if (itr.hasNext()) {
3198:                            count = (Long) itr.next();
3199:                        }
3200:
3201:                        if (count == null) {
3202:                            count = new Long(0);
3203:                        }
3204:
3205:                        FinderCache.putResult(finderClassNameCacheEnabled,
3206:                                finderClassName, finderMethodName,
3207:                                finderParams, finderArgs, count);
3208:
3209:                        return count.intValue();
3210:                    } catch (Exception e) {
3211:                        throw HibernateUtil.processException(e);
3212:                    } finally {
3213:                        closeSession(session);
3214:                    }
3215:                } else {
3216:                    return ((Long) result).intValue();
3217:                }
3218:            }
3219:
3220:            public int countByG_S(long groupId, String structureId)
3221:                    throws SystemException {
3222:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3223:                String finderClassName = JournalArticle.class.getName();
3224:                String finderMethodName = "countByG_S";
3225:                String[] finderParams = new String[] { Long.class.getName(),
3226:                        String.class.getName() };
3227:                Object[] finderArgs = new Object[] { new Long(groupId),
3228:                        structureId };
3229:
3230:                Object result = null;
3231:
3232:                if (finderClassNameCacheEnabled) {
3233:                    result = FinderCache.getResult(finderClassName,
3234:                            finderMethodName, finderParams, finderArgs,
3235:                            getSessionFactory());
3236:                }
3237:
3238:                if (result == null) {
3239:                    Session session = null;
3240:
3241:                    try {
3242:                        session = openSession();
3243:
3244:                        StringMaker query = new StringMaker();
3245:
3246:                        query.append("SELECT COUNT(*) ");
3247:                        query
3248:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3249:
3250:                        query.append("groupId = ?");
3251:
3252:                        query.append(" AND ");
3253:
3254:                        if (structureId == null) {
3255:                            query.append("structureId IS NULL");
3256:                        } else {
3257:                            query.append("structureId = ?");
3258:                        }
3259:
3260:                        query.append(" ");
3261:
3262:                        Query q = session.createQuery(query.toString());
3263:
3264:                        int queryPos = 0;
3265:
3266:                        q.setLong(queryPos++, groupId);
3267:
3268:                        if (structureId != null) {
3269:                            q.setString(queryPos++, structureId);
3270:                        }
3271:
3272:                        Long count = null;
3273:
3274:                        Iterator itr = q.list().iterator();
3275:
3276:                        if (itr.hasNext()) {
3277:                            count = (Long) itr.next();
3278:                        }
3279:
3280:                        if (count == null) {
3281:                            count = new Long(0);
3282:                        }
3283:
3284:                        FinderCache.putResult(finderClassNameCacheEnabled,
3285:                                finderClassName, finderMethodName,
3286:                                finderParams, finderArgs, count);
3287:
3288:                        return count.intValue();
3289:                    } catch (Exception e) {
3290:                        throw HibernateUtil.processException(e);
3291:                    } finally {
3292:                        closeSession(session);
3293:                    }
3294:                } else {
3295:                    return ((Long) result).intValue();
3296:                }
3297:            }
3298:
3299:            public int countByG_T(long groupId, String templateId)
3300:                    throws SystemException {
3301:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3302:                String finderClassName = JournalArticle.class.getName();
3303:                String finderMethodName = "countByG_T";
3304:                String[] finderParams = new String[] { Long.class.getName(),
3305:                        String.class.getName() };
3306:                Object[] finderArgs = new Object[] { new Long(groupId),
3307:                        templateId };
3308:
3309:                Object result = null;
3310:
3311:                if (finderClassNameCacheEnabled) {
3312:                    result = FinderCache.getResult(finderClassName,
3313:                            finderMethodName, finderParams, finderArgs,
3314:                            getSessionFactory());
3315:                }
3316:
3317:                if (result == null) {
3318:                    Session session = null;
3319:
3320:                    try {
3321:                        session = openSession();
3322:
3323:                        StringMaker query = new StringMaker();
3324:
3325:                        query.append("SELECT COUNT(*) ");
3326:                        query
3327:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3328:
3329:                        query.append("groupId = ?");
3330:
3331:                        query.append(" AND ");
3332:
3333:                        if (templateId == null) {
3334:                            query.append("templateId IS NULL");
3335:                        } else {
3336:                            query.append("templateId = ?");
3337:                        }
3338:
3339:                        query.append(" ");
3340:
3341:                        Query q = session.createQuery(query.toString());
3342:
3343:                        int queryPos = 0;
3344:
3345:                        q.setLong(queryPos++, groupId);
3346:
3347:                        if (templateId != null) {
3348:                            q.setString(queryPos++, templateId);
3349:                        }
3350:
3351:                        Long count = null;
3352:
3353:                        Iterator itr = q.list().iterator();
3354:
3355:                        if (itr.hasNext()) {
3356:                            count = (Long) itr.next();
3357:                        }
3358:
3359:                        if (count == null) {
3360:                            count = new Long(0);
3361:                        }
3362:
3363:                        FinderCache.putResult(finderClassNameCacheEnabled,
3364:                                finderClassName, finderMethodName,
3365:                                finderParams, finderArgs, count);
3366:
3367:                        return count.intValue();
3368:                    } catch (Exception e) {
3369:                        throw HibernateUtil.processException(e);
3370:                    } finally {
3371:                        closeSession(session);
3372:                    }
3373:                } else {
3374:                    return ((Long) result).intValue();
3375:                }
3376:            }
3377:
3378:            public int countByG_A_V(long groupId, String articleId,
3379:                    double version) throws SystemException {
3380:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3381:                String finderClassName = JournalArticle.class.getName();
3382:                String finderMethodName = "countByG_A_V";
3383:                String[] finderParams = new String[] { Long.class.getName(),
3384:                        String.class.getName(), Double.class.getName() };
3385:                Object[] finderArgs = new Object[] { new Long(groupId),
3386:
3387:                articleId, new Double(version) };
3388:
3389:                Object result = null;
3390:
3391:                if (finderClassNameCacheEnabled) {
3392:                    result = FinderCache.getResult(finderClassName,
3393:                            finderMethodName, finderParams, finderArgs,
3394:                            getSessionFactory());
3395:                }
3396:
3397:                if (result == null) {
3398:                    Session session = null;
3399:
3400:                    try {
3401:                        session = openSession();
3402:
3403:                        StringMaker query = new StringMaker();
3404:
3405:                        query.append("SELECT COUNT(*) ");
3406:                        query
3407:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3408:
3409:                        query.append("groupId = ?");
3410:
3411:                        query.append(" AND ");
3412:
3413:                        if (articleId == null) {
3414:                            query.append("articleId IS NULL");
3415:                        } else {
3416:                            query.append("articleId = ?");
3417:                        }
3418:
3419:                        query.append(" AND ");
3420:
3421:                        query.append("version = ?");
3422:
3423:                        query.append(" ");
3424:
3425:                        Query q = session.createQuery(query.toString());
3426:
3427:                        int queryPos = 0;
3428:
3429:                        q.setLong(queryPos++, groupId);
3430:
3431:                        if (articleId != null) {
3432:                            q.setString(queryPos++, articleId);
3433:                        }
3434:
3435:                        q.setDouble(queryPos++, version);
3436:
3437:                        Long count = null;
3438:
3439:                        Iterator itr = q.list().iterator();
3440:
3441:                        if (itr.hasNext()) {
3442:                            count = (Long) itr.next();
3443:                        }
3444:
3445:                        if (count == null) {
3446:                            count = new Long(0);
3447:                        }
3448:
3449:                        FinderCache.putResult(finderClassNameCacheEnabled,
3450:                                finderClassName, finderMethodName,
3451:                                finderParams, finderArgs, count);
3452:
3453:                        return count.intValue();
3454:                    } catch (Exception e) {
3455:                        throw HibernateUtil.processException(e);
3456:                    } finally {
3457:                        closeSession(session);
3458:                    }
3459:                } else {
3460:                    return ((Long) result).intValue();
3461:                }
3462:            }
3463:
3464:            public int countByG_A_A(long groupId, String articleId,
3465:                    boolean approved) throws SystemException {
3466:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3467:                String finderClassName = JournalArticle.class.getName();
3468:                String finderMethodName = "countByG_A_A";
3469:                String[] finderParams = new String[] { Long.class.getName(),
3470:                        String.class.getName(), Boolean.class.getName() };
3471:                Object[] finderArgs = new Object[] { new Long(groupId),
3472:
3473:                articleId, Boolean.valueOf(approved) };
3474:
3475:                Object result = null;
3476:
3477:                if (finderClassNameCacheEnabled) {
3478:                    result = FinderCache.getResult(finderClassName,
3479:                            finderMethodName, finderParams, finderArgs,
3480:                            getSessionFactory());
3481:                }
3482:
3483:                if (result == null) {
3484:                    Session session = null;
3485:
3486:                    try {
3487:                        session = openSession();
3488:
3489:                        StringMaker query = new StringMaker();
3490:
3491:                        query.append("SELECT COUNT(*) ");
3492:                        query
3493:                                .append("FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3494:
3495:                        query.append("groupId = ?");
3496:
3497:                        query.append(" AND ");
3498:
3499:                        if (articleId == null) {
3500:                            query.append("articleId IS NULL");
3501:                        } else {
3502:                            query.append("articleId = ?");
3503:                        }
3504:
3505:                        query.append(" AND ");
3506:
3507:                        query.append("approved = ?");
3508:
3509:                        query.append(" ");
3510:
3511:                        Query q = session.createQuery(query.toString());
3512:
3513:                        int queryPos = 0;
3514:
3515:                        q.setLong(queryPos++, groupId);
3516:
3517:                        if (articleId != null) {
3518:                            q.setString(queryPos++, articleId);
3519:                        }
3520:
3521:                        q.setBoolean(queryPos++, approved);
3522:
3523:                        Long count = null;
3524:
3525:                        Iterator itr = q.list().iterator();
3526:
3527:                        if (itr.hasNext()) {
3528:                            count = (Long) itr.next();
3529:                        }
3530:
3531:                        if (count == null) {
3532:                            count = new Long(0);
3533:                        }
3534:
3535:                        FinderCache.putResult(finderClassNameCacheEnabled,
3536:                                finderClassName, finderMethodName,
3537:                                finderParams, finderArgs, count);
3538:
3539:                        return count.intValue();
3540:                    } catch (Exception e) {
3541:                        throw HibernateUtil.processException(e);
3542:                    } finally {
3543:                        closeSession(session);
3544:                    }
3545:                } else {
3546:                    return ((Long) result).intValue();
3547:                }
3548:            }
3549:
3550:            public int countAll() throws SystemException {
3551:                boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3552:                String finderClassName = JournalArticle.class.getName();
3553:                String finderMethodName = "countAll";
3554:                String[] finderParams = new String[] {};
3555:                Object[] finderArgs = new Object[] {};
3556:
3557:                Object result = null;
3558:
3559:                if (finderClassNameCacheEnabled) {
3560:                    result = FinderCache.getResult(finderClassName,
3561:                            finderMethodName, finderParams, finderArgs,
3562:                            getSessionFactory());
3563:                }
3564:
3565:                if (result == null) {
3566:                    Session session = null;
3567:
3568:                    try {
3569:                        session = openSession();
3570:
3571:                        Query q = session
3572:                                .createQuery("SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalArticle");
3573:
3574:                        Long count = null;
3575:
3576:                        Iterator itr = q.list().iterator();
3577:
3578:                        if (itr.hasNext()) {
3579:                            count = (Long) itr.next();
3580:                        }
3581:
3582:                        if (count == null) {
3583:                            count = new Long(0);
3584:                        }
3585:
3586:                        FinderCache.putResult(finderClassNameCacheEnabled,
3587:                                finderClassName, finderMethodName,
3588:                                finderParams, finderArgs, count);
3589:
3590:                        return count.intValue();
3591:                    } catch (Exception e) {
3592:                        throw HibernateUtil.processException(e);
3593:                    } finally {
3594:                        closeSession(session);
3595:                    }
3596:                } else {
3597:                    return ((Long) result).intValue();
3598:                }
3599:            }
3600:
3601:            protected void initDao() {
3602:            }
3603:
3604:            private static ModelListener _getListener() {
3605:                if (Validator.isNotNull(_LISTENER)) {
3606:                    try {
3607:                        return (ModelListener) Class.forName(_LISTENER)
3608:                                .newInstance();
3609:                    } catch (Exception e) {
3610:                        _log.error(e);
3611:                    }
3612:                }
3613:
3614:                return null;
3615:            }
3616:
3617:            private static final String _LISTENER = GetterUtil
3618:                    .getString(PropsUtil
3619:                            .get("value.object.listener.com.liferay.portlet.journal.model.JournalArticle"));
3620:            private static Log _log = LogFactory
3621:                    .getLog(JournalArticlePersistenceImpl.class);
3622:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.