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