Source Code Cross Referenced for JournalStructurePersistenceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portlet » journal » service » persistence » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » com.liferay.portlet.journal.service.persistence 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
0003:         *
0004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
0005:         * of this software and associated documentation files (the "Software"), to deal
0006:         * in the Software without restriction, including without limitation the rights
0007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0008:         * copies of the Software, and to permit persons to whom the Software is
0009:         * furnished to do so, subject to the following conditions:
0010:         *
0011:         * The above copyright notice and this permission notice shall be included in
0012:         * all copies or substantial portions of the Software.
0013:         *
0014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0020:         * SOFTWARE.
0021:         */package com.liferay.portlet.journal.service.persistence;
0022:
0023:        import com.liferay.portal.SystemException;
0024:        import com.liferay.portal.kernel.dao.DynamicQuery;
0025:        import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
0026:        import com.liferay.portal.kernel.util.GetterUtil;
0027:        import com.liferay.portal.kernel.util.OrderByComparator;
0028:        import com.liferay.portal.kernel.util.StringMaker;
0029:        import com.liferay.portal.kernel.util.StringPool;
0030:        import com.liferay.portal.kernel.util.Validator;
0031:        import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
0032:        import com.liferay.portal.model.ModelListener;
0033:        import com.liferay.portal.service.persistence.BasePersistence;
0034:        import com.liferay.portal.spring.hibernate.FinderCache;
0035:        import com.liferay.portal.spring.hibernate.HibernateUtil;
0036:        import com.liferay.portal.util.PropsUtil;
0037:
0038:        import com.liferay.portlet.journal.NoSuchStructureException;
0039:        import com.liferay.portlet.journal.model.JournalStructure;
0040:        import com.liferay.portlet.journal.model.impl.JournalStructureImpl;
0041:        import com.liferay.portlet.journal.model.impl.JournalStructureModelImpl;
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="JournalStructurePersistenceImpl.java.html"><b><i>View Source</i></b></a>
0057:         *
0058:         * @author Brian Wing Shun Chan
0059:         *
0060:         */
0061:        public class JournalStructurePersistenceImpl extends BasePersistence
0062:                implements  JournalStructurePersistence {
0063:            public JournalStructure create(long id) {
0064:                JournalStructure journalStructure = new JournalStructureImpl();
0065:
0066:                journalStructure.setNew(true);
0067:                journalStructure.setPrimaryKey(id);
0068:
0069:                String uuid = PortalUUIDUtil.generate();
0070:
0071:                journalStructure.setUuid(uuid);
0072:
0073:                return journalStructure;
0074:            }
0075:
0076:            public JournalStructure remove(long id)
0077:                    throws NoSuchStructureException, SystemException {
0078:                Session session = null;
0079:
0080:                try {
0081:                    session = openSession();
0082:
0083:                    JournalStructure journalStructure = (JournalStructure) session
0084:                            .get(JournalStructureImpl.class, new Long(id));
0085:
0086:                    if (journalStructure == null) {
0087:                        if (_log.isWarnEnabled()) {
0088:                            _log
0089:                                    .warn("No JournalStructure exists with the primary key "
0090:                                            + id);
0091:                        }
0092:
0093:                        throw new NoSuchStructureException(
0094:                                "No JournalStructure exists with the primary key "
0095:                                        + id);
0096:                    }
0097:
0098:                    return remove(journalStructure);
0099:                } catch (NoSuchStructureException nsee) {
0100:                    throw nsee;
0101:                } catch (Exception e) {
0102:                    throw HibernateUtil.processException(e);
0103:                } finally {
0104:                    closeSession(session);
0105:                }
0106:            }
0107:
0108:            public JournalStructure remove(JournalStructure journalStructure)
0109:                    throws SystemException {
0110:                ModelListener listener = _getListener();
0111:
0112:                if (listener != null) {
0113:                    listener.onBeforeRemove(journalStructure);
0114:                }
0115:
0116:                journalStructure = removeImpl(journalStructure);
0117:
0118:                if (listener != null) {
0119:                    listener.onAfterRemove(journalStructure);
0120:                }
0121:
0122:                return journalStructure;
0123:            }
0124:
0125:            protected JournalStructure removeImpl(
0126:                    JournalStructure journalStructure) throws SystemException {
0127:                Session session = null;
0128:
0129:                try {
0130:                    session = openSession();
0131:
0132:                    session.delete(journalStructure);
0133:
0134:                    session.flush();
0135:
0136:                    return journalStructure;
0137:                } catch (Exception e) {
0138:                    throw HibernateUtil.processException(e);
0139:                } finally {
0140:                    closeSession(session);
0141:
0142:                    FinderCache.clearCache(JournalStructure.class.getName());
0143:                }
0144:            }
0145:
0146:            public JournalStructure update(JournalStructure journalStructure)
0147:                    throws SystemException {
0148:                return update(journalStructure, false);
0149:            }
0150:
0151:            public JournalStructure update(JournalStructure journalStructure,
0152:                    boolean merge) throws SystemException {
0153:                ModelListener listener = _getListener();
0154:
0155:                boolean isNew = journalStructure.isNew();
0156:
0157:                if (listener != null) {
0158:                    if (isNew) {
0159:                        listener.onBeforeCreate(journalStructure);
0160:                    } else {
0161:                        listener.onBeforeUpdate(journalStructure);
0162:                    }
0163:                }
0164:
0165:                journalStructure = updateImpl(journalStructure, merge);
0166:
0167:                if (listener != null) {
0168:                    if (isNew) {
0169:                        listener.onAfterCreate(journalStructure);
0170:                    } else {
0171:                        listener.onAfterUpdate(journalStructure);
0172:                    }
0173:                }
0174:
0175:                return journalStructure;
0176:            }
0177:
0178:            public JournalStructure updateImpl(
0179:                    com.liferay.portlet.journal.model.JournalStructure journalStructure,
0180:                    boolean merge) throws SystemException {
0181:                if (Validator.isNull(journalStructure.getUuid())) {
0182:                    String uuid = PortalUUIDUtil.generate();
0183:
0184:                    journalStructure.setUuid(uuid);
0185:                }
0186:
0187:                Session session = null;
0188:
0189:                try {
0190:                    session = openSession();
0191:
0192:                    if (merge) {
0193:                        session.merge(journalStructure);
0194:                    } else {
0195:                        if (journalStructure.isNew()) {
0196:                            session.save(journalStructure);
0197:                        }
0198:                    }
0199:
0200:                    session.flush();
0201:
0202:                    journalStructure.setNew(false);
0203:
0204:                    return journalStructure;
0205:                } catch (Exception e) {
0206:                    throw HibernateUtil.processException(e);
0207:                } finally {
0208:                    closeSession(session);
0209:
0210:                    FinderCache.clearCache(JournalStructure.class.getName());
0211:                }
0212:            }
0213:
0214:            public JournalStructure findByPrimaryKey(long id)
0215:                    throws NoSuchStructureException, SystemException {
0216:                JournalStructure journalStructure = fetchByPrimaryKey(id);
0217:
0218:                if (journalStructure == null) {
0219:                    if (_log.isWarnEnabled()) {
0220:                        _log
0221:                                .warn("No JournalStructure exists with the primary key "
0222:                                        + id);
0223:                    }
0224:
0225:                    throw new NoSuchStructureException(
0226:                            "No JournalStructure exists with the primary key "
0227:                                    + id);
0228:                }
0229:
0230:                return journalStructure;
0231:            }
0232:
0233:            public JournalStructure fetchByPrimaryKey(long id)
0234:                    throws SystemException {
0235:                Session session = null;
0236:
0237:                try {
0238:                    session = openSession();
0239:
0240:                    return (JournalStructure) session.get(
0241:                            JournalStructureImpl.class, new Long(id));
0242:                } catch (Exception e) {
0243:                    throw HibernateUtil.processException(e);
0244:                } finally {
0245:                    closeSession(session);
0246:                }
0247:            }
0248:
0249:            public List findByUuid(String uuid) throws SystemException {
0250:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
0251:                String finderClassName = JournalStructure.class.getName();
0252:                String finderMethodName = "findByUuid";
0253:                String[] finderParams = new String[] { String.class.getName() };
0254:                Object[] finderArgs = new Object[] { uuid };
0255:
0256:                Object result = null;
0257:
0258:                if (finderClassNameCacheEnabled) {
0259:                    result = FinderCache.getResult(finderClassName,
0260:                            finderMethodName, finderParams, finderArgs,
0261:                            getSessionFactory());
0262:                }
0263:
0264:                if (result == null) {
0265:                    Session session = null;
0266:
0267:                    try {
0268:                        session = openSession();
0269:
0270:                        StringMaker query = new StringMaker();
0271:
0272:                        query
0273:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0274:
0275:                        if (uuid == null) {
0276:                            query.append("uuid_ IS NULL");
0277:                        } else {
0278:                            query.append("uuid_ = ?");
0279:                        }
0280:
0281:                        query.append(" ");
0282:
0283:                        query.append("ORDER BY ");
0284:
0285:                        query.append("structureId ASC");
0286:
0287:                        Query q = session.createQuery(query.toString());
0288:
0289:                        int queryPos = 0;
0290:
0291:                        if (uuid != null) {
0292:                            q.setString(queryPos++, uuid);
0293:                        }
0294:
0295:                        List list = q.list();
0296:
0297:                        FinderCache.putResult(finderClassNameCacheEnabled,
0298:                                finderClassName, finderMethodName,
0299:                                finderParams, finderArgs, list);
0300:
0301:                        return list;
0302:                    } catch (Exception e) {
0303:                        throw HibernateUtil.processException(e);
0304:                    } finally {
0305:                        closeSession(session);
0306:                    }
0307:                } else {
0308:                    return (List) result;
0309:                }
0310:            }
0311:
0312:            public List findByUuid(String uuid, int begin, int end)
0313:                    throws SystemException {
0314:                return findByUuid(uuid, begin, end, null);
0315:            }
0316:
0317:            public List findByUuid(String uuid, int begin, int end,
0318:                    OrderByComparator obc) throws SystemException {
0319:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
0320:                String finderClassName = JournalStructure.class.getName();
0321:                String finderMethodName = "findByUuid";
0322:                String[] finderParams = new String[] { String.class.getName(),
0323:
0324:                "java.lang.Integer", "java.lang.Integer",
0325:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0326:                Object[] finderArgs = new Object[] { uuid,
0327:
0328:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0329:
0330:                Object result = null;
0331:
0332:                if (finderClassNameCacheEnabled) {
0333:                    result = FinderCache.getResult(finderClassName,
0334:                            finderMethodName, finderParams, finderArgs,
0335:                            getSessionFactory());
0336:                }
0337:
0338:                if (result == null) {
0339:                    Session session = null;
0340:
0341:                    try {
0342:                        session = openSession();
0343:
0344:                        StringMaker query = new StringMaker();
0345:
0346:                        query
0347:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0348:
0349:                        if (uuid == null) {
0350:                            query.append("uuid_ IS NULL");
0351:                        } else {
0352:                            query.append("uuid_ = ?");
0353:                        }
0354:
0355:                        query.append(" ");
0356:
0357:                        if (obc != null) {
0358:                            query.append("ORDER BY ");
0359:                            query.append(obc.getOrderBy());
0360:                        }
0361:
0362:                        else {
0363:                            query.append("ORDER BY ");
0364:
0365:                            query.append("structureId 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 JournalStructure findByUuid_First(String uuid,
0394:                    OrderByComparator obc) throws NoSuchStructureException,
0395:                    SystemException {
0396:                List list = findByUuid(uuid, 0, 1, obc);
0397:
0398:                if (list.size() == 0) {
0399:                    StringMaker msg = new StringMaker();
0400:
0401:                    msg.append("No JournalStructure exists with the key {");
0402:
0403:                    msg.append("uuid=" + uuid);
0404:
0405:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0406:
0407:                    throw new NoSuchStructureException(msg.toString());
0408:                } else {
0409:                    return (JournalStructure) list.get(0);
0410:                }
0411:            }
0412:
0413:            public JournalStructure findByUuid_Last(String uuid,
0414:                    OrderByComparator obc) throws NoSuchStructureException,
0415:                    SystemException {
0416:                int count = countByUuid(uuid);
0417:
0418:                List list = findByUuid(uuid, count - 1, count, obc);
0419:
0420:                if (list.size() == 0) {
0421:                    StringMaker msg = new StringMaker();
0422:
0423:                    msg.append("No JournalStructure exists with the key {");
0424:
0425:                    msg.append("uuid=" + uuid);
0426:
0427:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0428:
0429:                    throw new NoSuchStructureException(msg.toString());
0430:                } else {
0431:                    return (JournalStructure) list.get(0);
0432:                }
0433:            }
0434:
0435:            public JournalStructure[] findByUuid_PrevAndNext(long id,
0436:                    String uuid, OrderByComparator obc)
0437:                    throws NoSuchStructureException, SystemException {
0438:                JournalStructure journalStructure = findByPrimaryKey(id);
0439:
0440:                int count = countByUuid(uuid);
0441:
0442:                Session session = null;
0443:
0444:                try {
0445:                    session = openSession();
0446:
0447:                    StringMaker query = new StringMaker();
0448:
0449:                    query
0450:                            .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0451:
0452:                    if (uuid == null) {
0453:                        query.append("uuid_ IS NULL");
0454:                    } else {
0455:                        query.append("uuid_ = ?");
0456:                    }
0457:
0458:                    query.append(" ");
0459:
0460:                    if (obc != null) {
0461:                        query.append("ORDER BY ");
0462:                        query.append(obc.getOrderBy());
0463:                    }
0464:
0465:                    else {
0466:                        query.append("ORDER BY ");
0467:
0468:                        query.append("structureId 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:                            journalStructure);
0481:
0482:                    JournalStructure[] array = new JournalStructureImpl[3];
0483:
0484:                    array[0] = (JournalStructure) objArray[0];
0485:                    array[1] = (JournalStructure) objArray[1];
0486:                    array[2] = (JournalStructure) 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 JournalStructure findByUUID_G(String uuid, long groupId)
0497:                    throws NoSuchStructureException, SystemException {
0498:                JournalStructure journalStructure = fetchByUUID_G(uuid, groupId);
0499:
0500:                if (journalStructure == null) {
0501:                    StringMaker msg = new StringMaker();
0502:
0503:                    msg.append("No JournalStructure exists with the key {");
0504:
0505:                    msg.append("uuid=" + uuid);
0506:
0507:                    msg.append(", ");
0508:                    msg.append("groupId=" + groupId);
0509:
0510:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0511:
0512:                    if (_log.isWarnEnabled()) {
0513:                        _log.warn(msg.toString());
0514:                    }
0515:
0516:                    throw new NoSuchStructureException(msg.toString());
0517:                }
0518:
0519:                return journalStructure;
0520:            }
0521:
0522:            public JournalStructure fetchByUUID_G(String uuid, long groupId)
0523:                    throws SystemException {
0524:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
0525:                String finderClassName = JournalStructure.class.getName();
0526:                String finderMethodName = "fetchByUUID_G";
0527:                String[] finderParams = new String[] { String.class.getName(),
0528:                        Long.class.getName() };
0529:                Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
0530:
0531:                Object result = null;
0532:
0533:                if (finderClassNameCacheEnabled) {
0534:                    result = FinderCache.getResult(finderClassName,
0535:                            finderMethodName, finderParams, finderArgs,
0536:                            getSessionFactory());
0537:                }
0538:
0539:                if (result == null) {
0540:                    Session session = null;
0541:
0542:                    try {
0543:                        session = openSession();
0544:
0545:                        StringMaker query = new StringMaker();
0546:
0547:                        query
0548:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0549:
0550:                        if (uuid == null) {
0551:                            query.append("uuid_ IS NULL");
0552:                        } else {
0553:                            query.append("uuid_ = ?");
0554:                        }
0555:
0556:                        query.append(" AND ");
0557:
0558:                        query.append("groupId = ?");
0559:
0560:                        query.append(" ");
0561:
0562:                        query.append("ORDER BY ");
0563:
0564:                        query.append("structureId ASC");
0565:
0566:                        Query q = session.createQuery(query.toString());
0567:
0568:                        int queryPos = 0;
0569:
0570:                        if (uuid != null) {
0571:                            q.setString(queryPos++, uuid);
0572:                        }
0573:
0574:                        q.setLong(queryPos++, groupId);
0575:
0576:                        List list = q.list();
0577:
0578:                        FinderCache.putResult(finderClassNameCacheEnabled,
0579:                                finderClassName, finderMethodName,
0580:                                finderParams, finderArgs, list);
0581:
0582:                        if (list.size() == 0) {
0583:                            return null;
0584:                        } else {
0585:                            return (JournalStructure) list.get(0);
0586:                        }
0587:                    } catch (Exception e) {
0588:                        throw HibernateUtil.processException(e);
0589:                    } finally {
0590:                        closeSession(session);
0591:                    }
0592:                } else {
0593:                    List list = (List) result;
0594:
0595:                    if (list.size() == 0) {
0596:                        return null;
0597:                    } else {
0598:                        return (JournalStructure) list.get(0);
0599:                    }
0600:                }
0601:            }
0602:
0603:            public List findByGroupId(long groupId) throws SystemException {
0604:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
0605:                String finderClassName = JournalStructure.class.getName();
0606:                String finderMethodName = "findByGroupId";
0607:                String[] finderParams = new String[] { Long.class.getName() };
0608:                Object[] finderArgs = new Object[] { new Long(groupId) };
0609:
0610:                Object result = null;
0611:
0612:                if (finderClassNameCacheEnabled) {
0613:                    result = FinderCache.getResult(finderClassName,
0614:                            finderMethodName, finderParams, finderArgs,
0615:                            getSessionFactory());
0616:                }
0617:
0618:                if (result == null) {
0619:                    Session session = null;
0620:
0621:                    try {
0622:                        session = openSession();
0623:
0624:                        StringMaker query = new StringMaker();
0625:
0626:                        query
0627:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0628:
0629:                        query.append("groupId = ?");
0630:
0631:                        query.append(" ");
0632:
0633:                        query.append("ORDER BY ");
0634:
0635:                        query.append("structureId ASC");
0636:
0637:                        Query q = session.createQuery(query.toString());
0638:
0639:                        int queryPos = 0;
0640:
0641:                        q.setLong(queryPos++, groupId);
0642:
0643:                        List list = q.list();
0644:
0645:                        FinderCache.putResult(finderClassNameCacheEnabled,
0646:                                finderClassName, finderMethodName,
0647:                                finderParams, finderArgs, list);
0648:
0649:                        return list;
0650:                    } catch (Exception e) {
0651:                        throw HibernateUtil.processException(e);
0652:                    } finally {
0653:                        closeSession(session);
0654:                    }
0655:                } else {
0656:                    return (List) result;
0657:                }
0658:            }
0659:
0660:            public List findByGroupId(long groupId, int begin, int end)
0661:                    throws SystemException {
0662:                return findByGroupId(groupId, begin, end, null);
0663:            }
0664:
0665:            public List findByGroupId(long groupId, int begin, int end,
0666:                    OrderByComparator obc) throws SystemException {
0667:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
0668:                String finderClassName = JournalStructure.class.getName();
0669:                String finderMethodName = "findByGroupId";
0670:                String[] finderParams = new String[] { Long.class.getName(),
0671:
0672:                "java.lang.Integer", "java.lang.Integer",
0673:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0674:                Object[] finderArgs = new Object[] { new Long(groupId),
0675:
0676:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0677:
0678:                Object result = null;
0679:
0680:                if (finderClassNameCacheEnabled) {
0681:                    result = FinderCache.getResult(finderClassName,
0682:                            finderMethodName, finderParams, finderArgs,
0683:                            getSessionFactory());
0684:                }
0685:
0686:                if (result == null) {
0687:                    Session session = null;
0688:
0689:                    try {
0690:                        session = openSession();
0691:
0692:                        StringMaker query = new StringMaker();
0693:
0694:                        query
0695:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0696:
0697:                        query.append("groupId = ?");
0698:
0699:                        query.append(" ");
0700:
0701:                        if (obc != null) {
0702:                            query.append("ORDER BY ");
0703:                            query.append(obc.getOrderBy());
0704:                        }
0705:
0706:                        else {
0707:                            query.append("ORDER BY ");
0708:
0709:                            query.append("structureId ASC");
0710:                        }
0711:
0712:                        Query q = session.createQuery(query.toString());
0713:
0714:                        int queryPos = 0;
0715:
0716:                        q.setLong(queryPos++, groupId);
0717:
0718:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0719:
0720:                        FinderCache.putResult(finderClassNameCacheEnabled,
0721:                                finderClassName, finderMethodName,
0722:                                finderParams, finderArgs, list);
0723:
0724:                        return list;
0725:                    } catch (Exception e) {
0726:                        throw HibernateUtil.processException(e);
0727:                    } finally {
0728:                        closeSession(session);
0729:                    }
0730:                } else {
0731:                    return (List) result;
0732:                }
0733:            }
0734:
0735:            public JournalStructure findByGroupId_First(long groupId,
0736:                    OrderByComparator obc) throws NoSuchStructureException,
0737:                    SystemException {
0738:                List list = findByGroupId(groupId, 0, 1, obc);
0739:
0740:                if (list.size() == 0) {
0741:                    StringMaker msg = new StringMaker();
0742:
0743:                    msg.append("No JournalStructure exists with the key {");
0744:
0745:                    msg.append("groupId=" + groupId);
0746:
0747:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0748:
0749:                    throw new NoSuchStructureException(msg.toString());
0750:                } else {
0751:                    return (JournalStructure) list.get(0);
0752:                }
0753:            }
0754:
0755:            public JournalStructure findByGroupId_Last(long groupId,
0756:                    OrderByComparator obc) throws NoSuchStructureException,
0757:                    SystemException {
0758:                int count = countByGroupId(groupId);
0759:
0760:                List list = findByGroupId(groupId, count - 1, count, obc);
0761:
0762:                if (list.size() == 0) {
0763:                    StringMaker msg = new StringMaker();
0764:
0765:                    msg.append("No JournalStructure exists with the key {");
0766:
0767:                    msg.append("groupId=" + groupId);
0768:
0769:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0770:
0771:                    throw new NoSuchStructureException(msg.toString());
0772:                } else {
0773:                    return (JournalStructure) list.get(0);
0774:                }
0775:            }
0776:
0777:            public JournalStructure[] findByGroupId_PrevAndNext(long id,
0778:                    long groupId, OrderByComparator obc)
0779:                    throws NoSuchStructureException, SystemException {
0780:                JournalStructure journalStructure = findByPrimaryKey(id);
0781:
0782:                int count = countByGroupId(groupId);
0783:
0784:                Session session = null;
0785:
0786:                try {
0787:                    session = openSession();
0788:
0789:                    StringMaker query = new StringMaker();
0790:
0791:                    query
0792:                            .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0793:
0794:                    query.append("groupId = ?");
0795:
0796:                    query.append(" ");
0797:
0798:                    if (obc != null) {
0799:                        query.append("ORDER BY ");
0800:                        query.append(obc.getOrderBy());
0801:                    }
0802:
0803:                    else {
0804:                        query.append("ORDER BY ");
0805:
0806:                        query.append("structureId ASC");
0807:                    }
0808:
0809:                    Query q = session.createQuery(query.toString());
0810:
0811:                    int queryPos = 0;
0812:
0813:                    q.setLong(queryPos++, groupId);
0814:
0815:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0816:                            journalStructure);
0817:
0818:                    JournalStructure[] array = new JournalStructureImpl[3];
0819:
0820:                    array[0] = (JournalStructure) objArray[0];
0821:                    array[1] = (JournalStructure) objArray[1];
0822:                    array[2] = (JournalStructure) objArray[2];
0823:
0824:                    return array;
0825:                } catch (Exception e) {
0826:                    throw HibernateUtil.processException(e);
0827:                } finally {
0828:                    closeSession(session);
0829:                }
0830:            }
0831:
0832:            public List findByStructureId(String structureId)
0833:                    throws SystemException {
0834:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
0835:                String finderClassName = JournalStructure.class.getName();
0836:                String finderMethodName = "findByStructureId";
0837:                String[] finderParams = new String[] { String.class.getName() };
0838:                Object[] finderArgs = new Object[] { structureId };
0839:
0840:                Object result = null;
0841:
0842:                if (finderClassNameCacheEnabled) {
0843:                    result = FinderCache.getResult(finderClassName,
0844:                            finderMethodName, finderParams, finderArgs,
0845:                            getSessionFactory());
0846:                }
0847:
0848:                if (result == null) {
0849:                    Session session = null;
0850:
0851:                    try {
0852:                        session = openSession();
0853:
0854:                        StringMaker query = new StringMaker();
0855:
0856:                        query
0857:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0858:
0859:                        if (structureId == null) {
0860:                            query.append("structureId IS NULL");
0861:                        } else {
0862:                            query.append("structureId = ?");
0863:                        }
0864:
0865:                        query.append(" ");
0866:
0867:                        query.append("ORDER BY ");
0868:
0869:                        query.append("structureId ASC");
0870:
0871:                        Query q = session.createQuery(query.toString());
0872:
0873:                        int queryPos = 0;
0874:
0875:                        if (structureId != null) {
0876:                            q.setString(queryPos++, structureId);
0877:                        }
0878:
0879:                        List list = q.list();
0880:
0881:                        FinderCache.putResult(finderClassNameCacheEnabled,
0882:                                finderClassName, finderMethodName,
0883:                                finderParams, finderArgs, list);
0884:
0885:                        return list;
0886:                    } catch (Exception e) {
0887:                        throw HibernateUtil.processException(e);
0888:                    } finally {
0889:                        closeSession(session);
0890:                    }
0891:                } else {
0892:                    return (List) result;
0893:                }
0894:            }
0895:
0896:            public List findByStructureId(String structureId, int begin, int end)
0897:                    throws SystemException {
0898:                return findByStructureId(structureId, begin, end, null);
0899:            }
0900:
0901:            public List findByStructureId(String structureId, int begin,
0902:                    int end, OrderByComparator obc) throws SystemException {
0903:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
0904:                String finderClassName = JournalStructure.class.getName();
0905:                String finderMethodName = "findByStructureId";
0906:                String[] finderParams = new String[] { String.class.getName(),
0907:
0908:                "java.lang.Integer", "java.lang.Integer",
0909:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0910:                Object[] finderArgs = new Object[] { structureId,
0911:
0912:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0913:
0914:                Object result = null;
0915:
0916:                if (finderClassNameCacheEnabled) {
0917:                    result = FinderCache.getResult(finderClassName,
0918:                            finderMethodName, finderParams, finderArgs,
0919:                            getSessionFactory());
0920:                }
0921:
0922:                if (result == null) {
0923:                    Session session = null;
0924:
0925:                    try {
0926:                        session = openSession();
0927:
0928:                        StringMaker query = new StringMaker();
0929:
0930:                        query
0931:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
0932:
0933:                        if (structureId == null) {
0934:                            query.append("structureId IS NULL");
0935:                        } else {
0936:                            query.append("structureId = ?");
0937:                        }
0938:
0939:                        query.append(" ");
0940:
0941:                        if (obc != null) {
0942:                            query.append("ORDER BY ");
0943:                            query.append(obc.getOrderBy());
0944:                        }
0945:
0946:                        else {
0947:                            query.append("ORDER BY ");
0948:
0949:                            query.append("structureId ASC");
0950:                        }
0951:
0952:                        Query q = session.createQuery(query.toString());
0953:
0954:                        int queryPos = 0;
0955:
0956:                        if (structureId != null) {
0957:                            q.setString(queryPos++, structureId);
0958:                        }
0959:
0960:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0961:
0962:                        FinderCache.putResult(finderClassNameCacheEnabled,
0963:                                finderClassName, finderMethodName,
0964:                                finderParams, finderArgs, list);
0965:
0966:                        return list;
0967:                    } catch (Exception e) {
0968:                        throw HibernateUtil.processException(e);
0969:                    } finally {
0970:                        closeSession(session);
0971:                    }
0972:                } else {
0973:                    return (List) result;
0974:                }
0975:            }
0976:
0977:            public JournalStructure findByStructureId_First(String structureId,
0978:                    OrderByComparator obc) throws NoSuchStructureException,
0979:                    SystemException {
0980:                List list = findByStructureId(structureId, 0, 1, obc);
0981:
0982:                if (list.size() == 0) {
0983:                    StringMaker msg = new StringMaker();
0984:
0985:                    msg.append("No JournalStructure exists with the key {");
0986:
0987:                    msg.append("structureId=" + structureId);
0988:
0989:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0990:
0991:                    throw new NoSuchStructureException(msg.toString());
0992:                } else {
0993:                    return (JournalStructure) list.get(0);
0994:                }
0995:            }
0996:
0997:            public JournalStructure findByStructureId_Last(String structureId,
0998:                    OrderByComparator obc) throws NoSuchStructureException,
0999:                    SystemException {
1000:                int count = countByStructureId(structureId);
1001:
1002:                List list = findByStructureId(structureId, count - 1, count,
1003:                        obc);
1004:
1005:                if (list.size() == 0) {
1006:                    StringMaker msg = new StringMaker();
1007:
1008:                    msg.append("No JournalStructure exists with the key {");
1009:
1010:                    msg.append("structureId=" + structureId);
1011:
1012:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1013:
1014:                    throw new NoSuchStructureException(msg.toString());
1015:                } else {
1016:                    return (JournalStructure) list.get(0);
1017:                }
1018:            }
1019:
1020:            public JournalStructure[] findByStructureId_PrevAndNext(long id,
1021:                    String structureId, OrderByComparator obc)
1022:                    throws NoSuchStructureException, SystemException {
1023:                JournalStructure journalStructure = findByPrimaryKey(id);
1024:
1025:                int count = countByStructureId(structureId);
1026:
1027:                Session session = null;
1028:
1029:                try {
1030:                    session = openSession();
1031:
1032:                    StringMaker query = new StringMaker();
1033:
1034:                    query
1035:                            .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1036:
1037:                    if (structureId == null) {
1038:                        query.append("structureId IS NULL");
1039:                    } else {
1040:                        query.append("structureId = ?");
1041:                    }
1042:
1043:                    query.append(" ");
1044:
1045:                    if (obc != null) {
1046:                        query.append("ORDER BY ");
1047:                        query.append(obc.getOrderBy());
1048:                    }
1049:
1050:                    else {
1051:                        query.append("ORDER BY ");
1052:
1053:                        query.append("structureId ASC");
1054:                    }
1055:
1056:                    Query q = session.createQuery(query.toString());
1057:
1058:                    int queryPos = 0;
1059:
1060:                    if (structureId != null) {
1061:                        q.setString(queryPos++, structureId);
1062:                    }
1063:
1064:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1065:                            journalStructure);
1066:
1067:                    JournalStructure[] array = new JournalStructureImpl[3];
1068:
1069:                    array[0] = (JournalStructure) objArray[0];
1070:                    array[1] = (JournalStructure) objArray[1];
1071:                    array[2] = (JournalStructure) objArray[2];
1072:
1073:                    return array;
1074:                } catch (Exception e) {
1075:                    throw HibernateUtil.processException(e);
1076:                } finally {
1077:                    closeSession(session);
1078:                }
1079:            }
1080:
1081:            public JournalStructure findByG_S(long groupId, String structureId)
1082:                    throws NoSuchStructureException, SystemException {
1083:                JournalStructure journalStructure = fetchByG_S(groupId,
1084:                        structureId);
1085:
1086:                if (journalStructure == null) {
1087:                    StringMaker msg = new StringMaker();
1088:
1089:                    msg.append("No JournalStructure exists with the key {");
1090:
1091:                    msg.append("groupId=" + groupId);
1092:
1093:                    msg.append(", ");
1094:                    msg.append("structureId=" + structureId);
1095:
1096:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1097:
1098:                    if (_log.isWarnEnabled()) {
1099:                        _log.warn(msg.toString());
1100:                    }
1101:
1102:                    throw new NoSuchStructureException(msg.toString());
1103:                }
1104:
1105:                return journalStructure;
1106:            }
1107:
1108:            public JournalStructure fetchByG_S(long groupId, String structureId)
1109:                    throws SystemException {
1110:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1111:                String finderClassName = JournalStructure.class.getName();
1112:                String finderMethodName = "fetchByG_S";
1113:                String[] finderParams = new String[] { Long.class.getName(),
1114:                        String.class.getName() };
1115:                Object[] finderArgs = new Object[] { new Long(groupId),
1116:                        structureId };
1117:
1118:                Object result = null;
1119:
1120:                if (finderClassNameCacheEnabled) {
1121:                    result = FinderCache.getResult(finderClassName,
1122:                            finderMethodName, finderParams, finderArgs,
1123:                            getSessionFactory());
1124:                }
1125:
1126:                if (result == null) {
1127:                    Session session = null;
1128:
1129:                    try {
1130:                        session = openSession();
1131:
1132:                        StringMaker query = new StringMaker();
1133:
1134:                        query
1135:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1136:
1137:                        query.append("groupId = ?");
1138:
1139:                        query.append(" AND ");
1140:
1141:                        if (structureId == null) {
1142:                            query.append("structureId IS NULL");
1143:                        } else {
1144:                            query.append("structureId = ?");
1145:                        }
1146:
1147:                        query.append(" ");
1148:
1149:                        query.append("ORDER BY ");
1150:
1151:                        query.append("structureId ASC");
1152:
1153:                        Query q = session.createQuery(query.toString());
1154:
1155:                        int queryPos = 0;
1156:
1157:                        q.setLong(queryPos++, groupId);
1158:
1159:                        if (structureId != null) {
1160:                            q.setString(queryPos++, structureId);
1161:                        }
1162:
1163:                        List list = q.list();
1164:
1165:                        FinderCache.putResult(finderClassNameCacheEnabled,
1166:                                finderClassName, finderMethodName,
1167:                                finderParams, finderArgs, list);
1168:
1169:                        if (list.size() == 0) {
1170:                            return null;
1171:                        } else {
1172:                            return (JournalStructure) list.get(0);
1173:                        }
1174:                    } catch (Exception e) {
1175:                        throw HibernateUtil.processException(e);
1176:                    } finally {
1177:                        closeSession(session);
1178:                    }
1179:                } else {
1180:                    List list = (List) result;
1181:
1182:                    if (list.size() == 0) {
1183:                        return null;
1184:                    } else {
1185:                        return (JournalStructure) list.get(0);
1186:                    }
1187:                }
1188:            }
1189:
1190:            public List findWithDynamicQuery(
1191:                    DynamicQueryInitializer queryInitializer)
1192:                    throws SystemException {
1193:                Session session = null;
1194:
1195:                try {
1196:                    session = openSession();
1197:
1198:                    DynamicQuery query = queryInitializer.initialize(session);
1199:
1200:                    return query.list();
1201:                } catch (Exception e) {
1202:                    throw HibernateUtil.processException(e);
1203:                } finally {
1204:                    closeSession(session);
1205:                }
1206:            }
1207:
1208:            public List findWithDynamicQuery(
1209:                    DynamicQueryInitializer queryInitializer, int begin, int end)
1210:                    throws SystemException {
1211:                Session session = null;
1212:
1213:                try {
1214:                    session = openSession();
1215:
1216:                    DynamicQuery query = queryInitializer.initialize(session);
1217:
1218:                    query.setLimit(begin, end);
1219:
1220:                    return query.list();
1221:                } catch (Exception e) {
1222:                    throw HibernateUtil.processException(e);
1223:                } finally {
1224:                    closeSession(session);
1225:                }
1226:            }
1227:
1228:            public List findAll() throws SystemException {
1229:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1230:            }
1231:
1232:            public List findAll(int begin, int end) throws SystemException {
1233:                return findAll(begin, end, null);
1234:            }
1235:
1236:            public List findAll(int begin, int end, OrderByComparator obc)
1237:                    throws SystemException {
1238:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1239:                String finderClassName = JournalStructure.class.getName();
1240:                String finderMethodName = "findAll";
1241:                String[] finderParams = new String[] { "java.lang.Integer",
1242:                        "java.lang.Integer",
1243:                        "com.liferay.portal.kernel.util.OrderByComparator" };
1244:                Object[] finderArgs = new Object[] { String.valueOf(begin),
1245:                        String.valueOf(end), String.valueOf(obc) };
1246:
1247:                Object result = null;
1248:
1249:                if (finderClassNameCacheEnabled) {
1250:                    result = FinderCache.getResult(finderClassName,
1251:                            finderMethodName, finderParams, finderArgs,
1252:                            getSessionFactory());
1253:                }
1254:
1255:                if (result == null) {
1256:                    Session session = null;
1257:
1258:                    try {
1259:                        session = openSession();
1260:
1261:                        StringMaker query = new StringMaker();
1262:
1263:                        query
1264:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure ");
1265:
1266:                        if (obc != null) {
1267:                            query.append("ORDER BY ");
1268:                            query.append(obc.getOrderBy());
1269:                        }
1270:
1271:                        else {
1272:                            query.append("ORDER BY ");
1273:
1274:                            query.append("structureId ASC");
1275:                        }
1276:
1277:                        Query q = session.createQuery(query.toString());
1278:
1279:                        List list = QueryUtil.list(q, getDialect(), begin, end);
1280:
1281:                        if (obc == null) {
1282:                            Collections.sort(list);
1283:                        }
1284:
1285:                        FinderCache.putResult(finderClassNameCacheEnabled,
1286:                                finderClassName, finderMethodName,
1287:                                finderParams, finderArgs, list);
1288:
1289:                        return list;
1290:                    } catch (Exception e) {
1291:                        throw HibernateUtil.processException(e);
1292:                    } finally {
1293:                        closeSession(session);
1294:                    }
1295:                } else {
1296:                    return (List) result;
1297:                }
1298:            }
1299:
1300:            public void removeByUuid(String uuid) throws SystemException {
1301:                Iterator itr = findByUuid(uuid).iterator();
1302:
1303:                while (itr.hasNext()) {
1304:                    JournalStructure journalStructure = (JournalStructure) itr
1305:                            .next();
1306:
1307:                    remove(journalStructure);
1308:                }
1309:            }
1310:
1311:            public void removeByUUID_G(String uuid, long groupId)
1312:                    throws NoSuchStructureException, SystemException {
1313:                JournalStructure journalStructure = findByUUID_G(uuid, groupId);
1314:
1315:                remove(journalStructure);
1316:            }
1317:
1318:            public void removeByGroupId(long groupId) throws SystemException {
1319:                Iterator itr = findByGroupId(groupId).iterator();
1320:
1321:                while (itr.hasNext()) {
1322:                    JournalStructure journalStructure = (JournalStructure) itr
1323:                            .next();
1324:
1325:                    remove(journalStructure);
1326:                }
1327:            }
1328:
1329:            public void removeByStructureId(String structureId)
1330:                    throws SystemException {
1331:                Iterator itr = findByStructureId(structureId).iterator();
1332:
1333:                while (itr.hasNext()) {
1334:                    JournalStructure journalStructure = (JournalStructure) itr
1335:                            .next();
1336:
1337:                    remove(journalStructure);
1338:                }
1339:            }
1340:
1341:            public void removeByG_S(long groupId, String structureId)
1342:                    throws NoSuchStructureException, SystemException {
1343:                JournalStructure journalStructure = findByG_S(groupId,
1344:                        structureId);
1345:
1346:                remove(journalStructure);
1347:            }
1348:
1349:            public void removeAll() throws SystemException {
1350:                Iterator itr = findAll().iterator();
1351:
1352:                while (itr.hasNext()) {
1353:                    remove((JournalStructure) itr.next());
1354:                }
1355:            }
1356:
1357:            public int countByUuid(String uuid) throws SystemException {
1358:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1359:                String finderClassName = JournalStructure.class.getName();
1360:                String finderMethodName = "countByUuid";
1361:                String[] finderParams = new String[] { String.class.getName() };
1362:                Object[] finderArgs = new Object[] { uuid };
1363:
1364:                Object result = null;
1365:
1366:                if (finderClassNameCacheEnabled) {
1367:                    result = FinderCache.getResult(finderClassName,
1368:                            finderMethodName, finderParams, finderArgs,
1369:                            getSessionFactory());
1370:                }
1371:
1372:                if (result == null) {
1373:                    Session session = null;
1374:
1375:                    try {
1376:                        session = openSession();
1377:
1378:                        StringMaker query = new StringMaker();
1379:
1380:                        query.append("SELECT COUNT(*) ");
1381:                        query
1382:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1383:
1384:                        if (uuid == null) {
1385:                            query.append("uuid_ IS NULL");
1386:                        } else {
1387:                            query.append("uuid_ = ?");
1388:                        }
1389:
1390:                        query.append(" ");
1391:
1392:                        Query q = session.createQuery(query.toString());
1393:
1394:                        int queryPos = 0;
1395:
1396:                        if (uuid != null) {
1397:                            q.setString(queryPos++, uuid);
1398:                        }
1399:
1400:                        Long count = null;
1401:
1402:                        Iterator itr = q.list().iterator();
1403:
1404:                        if (itr.hasNext()) {
1405:                            count = (Long) itr.next();
1406:                        }
1407:
1408:                        if (count == null) {
1409:                            count = new Long(0);
1410:                        }
1411:
1412:                        FinderCache.putResult(finderClassNameCacheEnabled,
1413:                                finderClassName, finderMethodName,
1414:                                finderParams, finderArgs, count);
1415:
1416:                        return count.intValue();
1417:                    } catch (Exception e) {
1418:                        throw HibernateUtil.processException(e);
1419:                    } finally {
1420:                        closeSession(session);
1421:                    }
1422:                } else {
1423:                    return ((Long) result).intValue();
1424:                }
1425:            }
1426:
1427:            public int countByUUID_G(String uuid, long groupId)
1428:                    throws SystemException {
1429:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1430:                String finderClassName = JournalStructure.class.getName();
1431:                String finderMethodName = "countByUUID_G";
1432:                String[] finderParams = new String[] { String.class.getName(),
1433:                        Long.class.getName() };
1434:                Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1435:
1436:                Object result = null;
1437:
1438:                if (finderClassNameCacheEnabled) {
1439:                    result = FinderCache.getResult(finderClassName,
1440:                            finderMethodName, finderParams, finderArgs,
1441:                            getSessionFactory());
1442:                }
1443:
1444:                if (result == null) {
1445:                    Session session = null;
1446:
1447:                    try {
1448:                        session = openSession();
1449:
1450:                        StringMaker query = new StringMaker();
1451:
1452:                        query.append("SELECT COUNT(*) ");
1453:                        query
1454:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1455:
1456:                        if (uuid == null) {
1457:                            query.append("uuid_ IS NULL");
1458:                        } else {
1459:                            query.append("uuid_ = ?");
1460:                        }
1461:
1462:                        query.append(" AND ");
1463:
1464:                        query.append("groupId = ?");
1465:
1466:                        query.append(" ");
1467:
1468:                        Query q = session.createQuery(query.toString());
1469:
1470:                        int queryPos = 0;
1471:
1472:                        if (uuid != null) {
1473:                            q.setString(queryPos++, uuid);
1474:                        }
1475:
1476:                        q.setLong(queryPos++, groupId);
1477:
1478:                        Long count = null;
1479:
1480:                        Iterator itr = q.list().iterator();
1481:
1482:                        if (itr.hasNext()) {
1483:                            count = (Long) itr.next();
1484:                        }
1485:
1486:                        if (count == null) {
1487:                            count = new Long(0);
1488:                        }
1489:
1490:                        FinderCache.putResult(finderClassNameCacheEnabled,
1491:                                finderClassName, finderMethodName,
1492:                                finderParams, finderArgs, count);
1493:
1494:                        return count.intValue();
1495:                    } catch (Exception e) {
1496:                        throw HibernateUtil.processException(e);
1497:                    } finally {
1498:                        closeSession(session);
1499:                    }
1500:                } else {
1501:                    return ((Long) result).intValue();
1502:                }
1503:            }
1504:
1505:            public int countByGroupId(long groupId) throws SystemException {
1506:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1507:                String finderClassName = JournalStructure.class.getName();
1508:                String finderMethodName = "countByGroupId";
1509:                String[] finderParams = new String[] { Long.class.getName() };
1510:                Object[] finderArgs = new Object[] { new Long(groupId) };
1511:
1512:                Object result = null;
1513:
1514:                if (finderClassNameCacheEnabled) {
1515:                    result = FinderCache.getResult(finderClassName,
1516:                            finderMethodName, finderParams, finderArgs,
1517:                            getSessionFactory());
1518:                }
1519:
1520:                if (result == null) {
1521:                    Session session = null;
1522:
1523:                    try {
1524:                        session = openSession();
1525:
1526:                        StringMaker query = new StringMaker();
1527:
1528:                        query.append("SELECT COUNT(*) ");
1529:                        query
1530:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1531:
1532:                        query.append("groupId = ?");
1533:
1534:                        query.append(" ");
1535:
1536:                        Query q = session.createQuery(query.toString());
1537:
1538:                        int queryPos = 0;
1539:
1540:                        q.setLong(queryPos++, groupId);
1541:
1542:                        Long count = null;
1543:
1544:                        Iterator itr = q.list().iterator();
1545:
1546:                        if (itr.hasNext()) {
1547:                            count = (Long) itr.next();
1548:                        }
1549:
1550:                        if (count == null) {
1551:                            count = new Long(0);
1552:                        }
1553:
1554:                        FinderCache.putResult(finderClassNameCacheEnabled,
1555:                                finderClassName, finderMethodName,
1556:                                finderParams, finderArgs, count);
1557:
1558:                        return count.intValue();
1559:                    } catch (Exception e) {
1560:                        throw HibernateUtil.processException(e);
1561:                    } finally {
1562:                        closeSession(session);
1563:                    }
1564:                } else {
1565:                    return ((Long) result).intValue();
1566:                }
1567:            }
1568:
1569:            public int countByStructureId(String structureId)
1570:                    throws SystemException {
1571:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1572:                String finderClassName = JournalStructure.class.getName();
1573:                String finderMethodName = "countByStructureId";
1574:                String[] finderParams = new String[] { String.class.getName() };
1575:                Object[] finderArgs = new Object[] { structureId };
1576:
1577:                Object result = null;
1578:
1579:                if (finderClassNameCacheEnabled) {
1580:                    result = FinderCache.getResult(finderClassName,
1581:                            finderMethodName, finderParams, finderArgs,
1582:                            getSessionFactory());
1583:                }
1584:
1585:                if (result == null) {
1586:                    Session session = null;
1587:
1588:                    try {
1589:                        session = openSession();
1590:
1591:                        StringMaker query = new StringMaker();
1592:
1593:                        query.append("SELECT COUNT(*) ");
1594:                        query
1595:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1596:
1597:                        if (structureId == null) {
1598:                            query.append("structureId IS NULL");
1599:                        } else {
1600:                            query.append("structureId = ?");
1601:                        }
1602:
1603:                        query.append(" ");
1604:
1605:                        Query q = session.createQuery(query.toString());
1606:
1607:                        int queryPos = 0;
1608:
1609:                        if (structureId != null) {
1610:                            q.setString(queryPos++, structureId);
1611:                        }
1612:
1613:                        Long count = null;
1614:
1615:                        Iterator itr = q.list().iterator();
1616:
1617:                        if (itr.hasNext()) {
1618:                            count = (Long) itr.next();
1619:                        }
1620:
1621:                        if (count == null) {
1622:                            count = new Long(0);
1623:                        }
1624:
1625:                        FinderCache.putResult(finderClassNameCacheEnabled,
1626:                                finderClassName, finderMethodName,
1627:                                finderParams, finderArgs, count);
1628:
1629:                        return count.intValue();
1630:                    } catch (Exception e) {
1631:                        throw HibernateUtil.processException(e);
1632:                    } finally {
1633:                        closeSession(session);
1634:                    }
1635:                } else {
1636:                    return ((Long) result).intValue();
1637:                }
1638:            }
1639:
1640:            public int countByG_S(long groupId, String structureId)
1641:                    throws SystemException {
1642:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1643:                String finderClassName = JournalStructure.class.getName();
1644:                String finderMethodName = "countByG_S";
1645:                String[] finderParams = new String[] { Long.class.getName(),
1646:                        String.class.getName() };
1647:                Object[] finderArgs = new Object[] { new Long(groupId),
1648:                        structureId };
1649:
1650:                Object result = null;
1651:
1652:                if (finderClassNameCacheEnabled) {
1653:                    result = FinderCache.getResult(finderClassName,
1654:                            finderMethodName, finderParams, finderArgs,
1655:                            getSessionFactory());
1656:                }
1657:
1658:                if (result == null) {
1659:                    Session session = null;
1660:
1661:                    try {
1662:                        session = openSession();
1663:
1664:                        StringMaker query = new StringMaker();
1665:
1666:                        query.append("SELECT COUNT(*) ");
1667:                        query
1668:                                .append("FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1669:
1670:                        query.append("groupId = ?");
1671:
1672:                        query.append(" AND ");
1673:
1674:                        if (structureId == null) {
1675:                            query.append("structureId IS NULL");
1676:                        } else {
1677:                            query.append("structureId = ?");
1678:                        }
1679:
1680:                        query.append(" ");
1681:
1682:                        Query q = session.createQuery(query.toString());
1683:
1684:                        int queryPos = 0;
1685:
1686:                        q.setLong(queryPos++, groupId);
1687:
1688:                        if (structureId != null) {
1689:                            q.setString(queryPos++, structureId);
1690:                        }
1691:
1692:                        Long count = null;
1693:
1694:                        Iterator itr = q.list().iterator();
1695:
1696:                        if (itr.hasNext()) {
1697:                            count = (Long) itr.next();
1698:                        }
1699:
1700:                        if (count == null) {
1701:                            count = new Long(0);
1702:                        }
1703:
1704:                        FinderCache.putResult(finderClassNameCacheEnabled,
1705:                                finderClassName, finderMethodName,
1706:                                finderParams, finderArgs, count);
1707:
1708:                        return count.intValue();
1709:                    } catch (Exception e) {
1710:                        throw HibernateUtil.processException(e);
1711:                    } finally {
1712:                        closeSession(session);
1713:                    }
1714:                } else {
1715:                    return ((Long) result).intValue();
1716:                }
1717:            }
1718:
1719:            public int countAll() throws SystemException {
1720:                boolean finderClassNameCacheEnabled = JournalStructureModelImpl.CACHE_ENABLED;
1721:                String finderClassName = JournalStructure.class.getName();
1722:                String finderMethodName = "countAll";
1723:                String[] finderParams = new String[] {};
1724:                Object[] finderArgs = new Object[] {};
1725:
1726:                Object result = null;
1727:
1728:                if (finderClassNameCacheEnabled) {
1729:                    result = FinderCache.getResult(finderClassName,
1730:                            finderMethodName, finderParams, finderArgs,
1731:                            getSessionFactory());
1732:                }
1733:
1734:                if (result == null) {
1735:                    Session session = null;
1736:
1737:                    try {
1738:                        session = openSession();
1739:
1740:                        Query q = session
1741:                                .createQuery("SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalStructure");
1742:
1743:                        Long count = null;
1744:
1745:                        Iterator itr = q.list().iterator();
1746:
1747:                        if (itr.hasNext()) {
1748:                            count = (Long) itr.next();
1749:                        }
1750:
1751:                        if (count == null) {
1752:                            count = new Long(0);
1753:                        }
1754:
1755:                        FinderCache.putResult(finderClassNameCacheEnabled,
1756:                                finderClassName, finderMethodName,
1757:                                finderParams, finderArgs, count);
1758:
1759:                        return count.intValue();
1760:                    } catch (Exception e) {
1761:                        throw HibernateUtil.processException(e);
1762:                    } finally {
1763:                        closeSession(session);
1764:                    }
1765:                } else {
1766:                    return ((Long) result).intValue();
1767:                }
1768:            }
1769:
1770:            protected void initDao() {
1771:            }
1772:
1773:            private static ModelListener _getListener() {
1774:                if (Validator.isNotNull(_LISTENER)) {
1775:                    try {
1776:                        return (ModelListener) Class.forName(_LISTENER)
1777:                                .newInstance();
1778:                    } catch (Exception e) {
1779:                        _log.error(e);
1780:                    }
1781:                }
1782:
1783:                return null;
1784:            }
1785:
1786:            private static final String _LISTENER = GetterUtil
1787:                    .getString(PropsUtil
1788:                            .get("value.object.listener.com.liferay.portlet.journal.model.JournalStructure"));
1789:            private static Log _log = LogFactory
1790:                    .getLog(JournalStructurePersistenceImpl.class);
1791:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.