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