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