Source Code Cross Referenced for ReportsEntryPersistenceImpl.java in  » Portal » liferay-portal-4.4.2 » com » ext » portlet » reports » 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.ext.portlet.reports.service.persistence 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package com.ext.portlet.reports.service.persistence;
0002:
0003:        import com.ext.portlet.reports.NoSuchEntryException;
0004:        import com.ext.portlet.reports.model.ReportsEntry;
0005:        import com.ext.portlet.reports.model.impl.ReportsEntryImpl;
0006:        import com.ext.portlet.reports.model.impl.ReportsEntryModelImpl;
0007:
0008:        import com.liferay.portal.SystemException;
0009:        import com.liferay.portal.kernel.dao.DynamicQuery;
0010:        import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
0011:        import com.liferay.portal.kernel.util.GetterUtil;
0012:        import com.liferay.portal.kernel.util.OrderByComparator;
0013:        import com.liferay.portal.kernel.util.StringMaker;
0014:        import com.liferay.portal.kernel.util.StringPool;
0015:        import com.liferay.portal.kernel.util.Validator;
0016:        import com.liferay.portal.model.ModelListener;
0017:        import com.liferay.portal.service.persistence.BasePersistence;
0018:        import com.liferay.portal.spring.hibernate.FinderCache;
0019:        import com.liferay.portal.spring.hibernate.HibernateUtil;
0020:        import com.liferay.portal.util.PropsUtil;
0021:
0022:        import com.liferay.util.dao.hibernate.QueryUtil;
0023:
0024:        import org.apache.commons.logging.Log;
0025:        import org.apache.commons.logging.LogFactory;
0026:
0027:        import org.hibernate.Query;
0028:        import org.hibernate.Session;
0029:
0030:        import java.util.Collections;
0031:        import java.util.Iterator;
0032:        import java.util.List;
0033:
0034:        public class ReportsEntryPersistenceImpl extends BasePersistence
0035:                implements  ReportsEntryPersistence {
0036:            private static final String _LISTENER = GetterUtil
0037:                    .getString(PropsUtil
0038:                            .get("value.object.listener.com.ext.portlet.reports.model.ReportsEntry"));
0039:            private static Log _log = LogFactory
0040:                    .getLog(ReportsEntryPersistenceImpl.class);
0041:
0042:            public ReportsEntry create(String entryId) {
0043:                ReportsEntry reportsEntry = new ReportsEntryImpl();
0044:
0045:                reportsEntry.setNew(true);
0046:                reportsEntry.setPrimaryKey(entryId);
0047:
0048:                return reportsEntry;
0049:            }
0050:
0051:            public ReportsEntry remove(String entryId)
0052:                    throws NoSuchEntryException, SystemException {
0053:                Session session = null;
0054:
0055:                try {
0056:                    session = openSession();
0057:
0058:                    ReportsEntry reportsEntry = (ReportsEntry) session.get(
0059:                            ReportsEntryImpl.class, entryId);
0060:
0061:                    if (reportsEntry == null) {
0062:                        if (_log.isWarnEnabled()) {
0063:                            _log
0064:                                    .warn("No ReportsEntry exists with the primary key "
0065:                                            + entryId);
0066:                        }
0067:
0068:                        throw new NoSuchEntryException(
0069:                                "No ReportsEntry exists with the primary key "
0070:                                        + entryId);
0071:                    }
0072:
0073:                    return remove(reportsEntry);
0074:                } catch (NoSuchEntryException nsee) {
0075:                    throw nsee;
0076:                } catch (Exception e) {
0077:                    throw HibernateUtil.processException(e);
0078:                } finally {
0079:                    closeSession(session);
0080:                }
0081:            }
0082:
0083:            public ReportsEntry remove(ReportsEntry reportsEntry)
0084:                    throws SystemException {
0085:                ModelListener listener = _getListener();
0086:
0087:                if (listener != null) {
0088:                    listener.onBeforeRemove(reportsEntry);
0089:                }
0090:
0091:                reportsEntry = removeImpl(reportsEntry);
0092:
0093:                if (listener != null) {
0094:                    listener.onAfterRemove(reportsEntry);
0095:                }
0096:
0097:                return reportsEntry;
0098:            }
0099:
0100:            protected ReportsEntry removeImpl(ReportsEntry reportsEntry)
0101:                    throws SystemException {
0102:                Session session = null;
0103:
0104:                try {
0105:                    session = openSession();
0106:
0107:                    session.delete(reportsEntry);
0108:
0109:                    session.flush();
0110:
0111:                    return reportsEntry;
0112:                } catch (Exception e) {
0113:                    throw HibernateUtil.processException(e);
0114:                } finally {
0115:                    closeSession(session);
0116:
0117:                    FinderCache.clearCache(ReportsEntry.class.getName());
0118:                }
0119:            }
0120:
0121:            public ReportsEntry update(ReportsEntry reportsEntry)
0122:                    throws SystemException {
0123:                return update(reportsEntry, false);
0124:            }
0125:
0126:            public ReportsEntry update(ReportsEntry reportsEntry, boolean merge)
0127:                    throws SystemException {
0128:                ModelListener listener = _getListener();
0129:
0130:                boolean isNew = reportsEntry.isNew();
0131:
0132:                if (listener != null) {
0133:                    if (isNew) {
0134:                        listener.onBeforeCreate(reportsEntry);
0135:                    } else {
0136:                        listener.onBeforeUpdate(reportsEntry);
0137:                    }
0138:                }
0139:
0140:                reportsEntry = updateImpl(reportsEntry, merge);
0141:
0142:                if (listener != null) {
0143:                    if (isNew) {
0144:                        listener.onAfterCreate(reportsEntry);
0145:                    } else {
0146:                        listener.onAfterUpdate(reportsEntry);
0147:                    }
0148:                }
0149:
0150:                return reportsEntry;
0151:            }
0152:
0153:            public ReportsEntry updateImpl(
0154:                    com.ext.portlet.reports.model.ReportsEntry reportsEntry,
0155:                    boolean merge) throws SystemException {
0156:                Session session = null;
0157:
0158:                try {
0159:                    session = openSession();
0160:
0161:                    if (merge) {
0162:                        session.merge(reportsEntry);
0163:                    } else {
0164:                        if (reportsEntry.isNew()) {
0165:                            session.save(reportsEntry);
0166:                        }
0167:                    }
0168:
0169:                    session.flush();
0170:
0171:                    reportsEntry.setNew(false);
0172:
0173:                    return reportsEntry;
0174:                } catch (Exception e) {
0175:                    throw HibernateUtil.processException(e);
0176:                } finally {
0177:                    closeSession(session);
0178:
0179:                    FinderCache.clearCache(ReportsEntry.class.getName());
0180:                }
0181:            }
0182:
0183:            public ReportsEntry findByPrimaryKey(String entryId)
0184:                    throws NoSuchEntryException, SystemException {
0185:                ReportsEntry reportsEntry = fetchByPrimaryKey(entryId);
0186:
0187:                if (reportsEntry == null) {
0188:                    if (_log.isWarnEnabled()) {
0189:                        _log
0190:                                .warn("No ReportsEntry exists with the primary key "
0191:                                        + entryId);
0192:                    }
0193:
0194:                    throw new NoSuchEntryException(
0195:                            "No ReportsEntry exists with the primary key "
0196:                                    + entryId);
0197:                }
0198:
0199:                return reportsEntry;
0200:            }
0201:
0202:            public ReportsEntry fetchByPrimaryKey(String entryId)
0203:                    throws SystemException {
0204:                Session session = null;
0205:
0206:                try {
0207:                    session = openSession();
0208:
0209:                    return (ReportsEntry) session.get(ReportsEntryImpl.class,
0210:                            entryId);
0211:                } catch (Exception e) {
0212:                    throw HibernateUtil.processException(e);
0213:                } finally {
0214:                    closeSession(session);
0215:                }
0216:            }
0217:
0218:            public List findByCompanyId(String companyId)
0219:                    throws SystemException {
0220:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0221:                String finderClassName = ReportsEntry.class.getName();
0222:                String finderMethodName = "findByCompanyId";
0223:                String[] finderParams = new String[] { String.class.getName() };
0224:                Object[] finderArgs = new Object[] { companyId };
0225:
0226:                Object result = null;
0227:
0228:                if (finderClassNameCacheEnabled) {
0229:                    result = FinderCache.getResult(finderClassName,
0230:                            finderMethodName, finderParams, finderArgs,
0231:                            getSessionFactory());
0232:                }
0233:
0234:                if (result == null) {
0235:                    Session session = null;
0236:
0237:                    try {
0238:                        session = openSession();
0239:
0240:                        StringMaker query = new StringMaker();
0241:
0242:                        query
0243:                                .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0244:
0245:                        if (companyId == null) {
0246:                            query.append("companyId IS NULL");
0247:                        } else {
0248:                            query.append("companyId = ?");
0249:                        }
0250:
0251:                        query.append(" ");
0252:
0253:                        query.append("ORDER BY ");
0254:
0255:                        query.append("name ASC");
0256:
0257:                        Query q = session.createQuery(query.toString());
0258:
0259:                        int queryPos = 0;
0260:
0261:                        if (companyId != null) {
0262:                            q.setString(queryPos++, companyId);
0263:                        }
0264:
0265:                        List list = q.list();
0266:
0267:                        FinderCache.putResult(finderClassNameCacheEnabled,
0268:                                finderClassName, finderMethodName,
0269:                                finderParams, finderArgs, list);
0270:
0271:                        return list;
0272:                    } catch (Exception e) {
0273:                        throw HibernateUtil.processException(e);
0274:                    } finally {
0275:                        closeSession(session);
0276:                    }
0277:                } else {
0278:                    return (List) result;
0279:                }
0280:            }
0281:
0282:            public List findByCompanyId(String companyId, int begin, int end)
0283:                    throws SystemException {
0284:                return findByCompanyId(companyId, begin, end, null);
0285:            }
0286:
0287:            public List findByCompanyId(String companyId, int begin, int end,
0288:                    OrderByComparator obc) throws SystemException {
0289:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0290:                String finderClassName = ReportsEntry.class.getName();
0291:                String finderMethodName = "findByCompanyId";
0292:                String[] finderParams = new String[] { String.class.getName(),
0293:
0294:                "java.lang.Integer", "java.lang.Integer",
0295:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0296:                Object[] finderArgs = new Object[] { companyId,
0297:
0298:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0299:
0300:                Object result = null;
0301:
0302:                if (finderClassNameCacheEnabled) {
0303:                    result = FinderCache.getResult(finderClassName,
0304:                            finderMethodName, finderParams, finderArgs,
0305:                            getSessionFactory());
0306:                }
0307:
0308:                if (result == null) {
0309:                    Session session = null;
0310:
0311:                    try {
0312:                        session = openSession();
0313:
0314:                        StringMaker query = new StringMaker();
0315:
0316:                        query
0317:                                .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0318:
0319:                        if (companyId == null) {
0320:                            query.append("companyId IS NULL");
0321:                        } else {
0322:                            query.append("companyId = ?");
0323:                        }
0324:
0325:                        query.append(" ");
0326:
0327:                        if (obc != null) {
0328:                            query.append("ORDER BY ");
0329:                            query.append(obc.getOrderBy());
0330:                        } else {
0331:                            query.append("ORDER BY ");
0332:
0333:                            query.append("name ASC");
0334:                        }
0335:
0336:                        Query q = session.createQuery(query.toString());
0337:
0338:                        int queryPos = 0;
0339:
0340:                        if (companyId != null) {
0341:                            q.setString(queryPos++, companyId);
0342:                        }
0343:
0344:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0345:
0346:                        FinderCache.putResult(finderClassNameCacheEnabled,
0347:                                finderClassName, finderMethodName,
0348:                                finderParams, finderArgs, list);
0349:
0350:                        return list;
0351:                    } catch (Exception e) {
0352:                        throw HibernateUtil.processException(e);
0353:                    } finally {
0354:                        closeSession(session);
0355:                    }
0356:                } else {
0357:                    return (List) result;
0358:                }
0359:            }
0360:
0361:            public ReportsEntry findByCompanyId_First(String companyId,
0362:                    OrderByComparator obc) throws NoSuchEntryException,
0363:                    SystemException {
0364:                List list = findByCompanyId(companyId, 0, 1, obc);
0365:
0366:                if (list.size() == 0) {
0367:                    StringMaker msg = new StringMaker();
0368:
0369:                    msg.append("No ReportsEntry exists with the key {");
0370:
0371:                    msg.append("companyId=" + companyId);
0372:
0373:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0374:
0375:                    throw new NoSuchEntryException(msg.toString());
0376:                } else {
0377:                    return (ReportsEntry) list.get(0);
0378:                }
0379:            }
0380:
0381:            public ReportsEntry findByCompanyId_Last(String companyId,
0382:                    OrderByComparator obc) throws NoSuchEntryException,
0383:                    SystemException {
0384:                int count = countByCompanyId(companyId);
0385:
0386:                List list = findByCompanyId(companyId, count - 1, count, obc);
0387:
0388:                if (list.size() == 0) {
0389:                    StringMaker msg = new StringMaker();
0390:
0391:                    msg.append("No ReportsEntry exists with the key {");
0392:
0393:                    msg.append("companyId=" + companyId);
0394:
0395:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0396:
0397:                    throw new NoSuchEntryException(msg.toString());
0398:                } else {
0399:                    return (ReportsEntry) list.get(0);
0400:                }
0401:            }
0402:
0403:            public ReportsEntry[] findByCompanyId_PrevAndNext(String entryId,
0404:                    String companyId, OrderByComparator obc)
0405:                    throws NoSuchEntryException, SystemException {
0406:                ReportsEntry reportsEntry = findByPrimaryKey(entryId);
0407:
0408:                int count = countByCompanyId(companyId);
0409:
0410:                Session session = null;
0411:
0412:                try {
0413:                    session = openSession();
0414:
0415:                    StringMaker query = new StringMaker();
0416:
0417:                    query
0418:                            .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0419:
0420:                    if (companyId == null) {
0421:                        query.append("companyId IS NULL");
0422:                    } else {
0423:                        query.append("companyId = ?");
0424:                    }
0425:
0426:                    query.append(" ");
0427:
0428:                    if (obc != null) {
0429:                        query.append("ORDER BY ");
0430:                        query.append(obc.getOrderBy());
0431:                    } else {
0432:                        query.append("ORDER BY ");
0433:
0434:                        query.append("name ASC");
0435:                    }
0436:
0437:                    Query q = session.createQuery(query.toString());
0438:
0439:                    int queryPos = 0;
0440:
0441:                    if (companyId != null) {
0442:                        q.setString(queryPos++, companyId);
0443:                    }
0444:
0445:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0446:                            reportsEntry);
0447:
0448:                    ReportsEntry[] array = new ReportsEntryImpl[3];
0449:
0450:                    array[0] = (ReportsEntry) objArray[0];
0451:                    array[1] = (ReportsEntry) objArray[1];
0452:                    array[2] = (ReportsEntry) objArray[2];
0453:
0454:                    return array;
0455:                } catch (Exception e) {
0456:                    throw HibernateUtil.processException(e);
0457:                } finally {
0458:                    closeSession(session);
0459:                }
0460:            }
0461:
0462:            public List findByUserId(String userId) throws SystemException {
0463:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0464:                String finderClassName = ReportsEntry.class.getName();
0465:                String finderMethodName = "findByUserId";
0466:                String[] finderParams = new String[] { String.class.getName() };
0467:                Object[] finderArgs = new Object[] { userId };
0468:
0469:                Object result = null;
0470:
0471:                if (finderClassNameCacheEnabled) {
0472:                    result = FinderCache.getResult(finderClassName,
0473:                            finderMethodName, finderParams, finderArgs,
0474:                            getSessionFactory());
0475:                }
0476:
0477:                if (result == null) {
0478:                    Session session = null;
0479:
0480:                    try {
0481:                        session = openSession();
0482:
0483:                        StringMaker query = new StringMaker();
0484:
0485:                        query
0486:                                .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0487:
0488:                        if (userId == null) {
0489:                            query.append("userId IS NULL");
0490:                        } else {
0491:                            query.append("userId = ?");
0492:                        }
0493:
0494:                        query.append(" ");
0495:
0496:                        query.append("ORDER BY ");
0497:
0498:                        query.append("name ASC");
0499:
0500:                        Query q = session.createQuery(query.toString());
0501:
0502:                        int queryPos = 0;
0503:
0504:                        if (userId != null) {
0505:                            q.setString(queryPos++, userId);
0506:                        }
0507:
0508:                        List list = q.list();
0509:
0510:                        FinderCache.putResult(finderClassNameCacheEnabled,
0511:                                finderClassName, finderMethodName,
0512:                                finderParams, finderArgs, list);
0513:
0514:                        return list;
0515:                    } catch (Exception e) {
0516:                        throw HibernateUtil.processException(e);
0517:                    } finally {
0518:                        closeSession(session);
0519:                    }
0520:                } else {
0521:                    return (List) result;
0522:                }
0523:            }
0524:
0525:            public List findByUserId(String userId, int begin, int end)
0526:                    throws SystemException {
0527:                return findByUserId(userId, begin, end, null);
0528:            }
0529:
0530:            public List findByUserId(String userId, int begin, int end,
0531:                    OrderByComparator obc) throws SystemException {
0532:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0533:                String finderClassName = ReportsEntry.class.getName();
0534:                String finderMethodName = "findByUserId";
0535:                String[] finderParams = new String[] { String.class.getName(),
0536:
0537:                "java.lang.Integer", "java.lang.Integer",
0538:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0539:                Object[] finderArgs = new Object[] { userId,
0540:
0541:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0542:
0543:                Object result = null;
0544:
0545:                if (finderClassNameCacheEnabled) {
0546:                    result = FinderCache.getResult(finderClassName,
0547:                            finderMethodName, finderParams, finderArgs,
0548:                            getSessionFactory());
0549:                }
0550:
0551:                if (result == null) {
0552:                    Session session = null;
0553:
0554:                    try {
0555:                        session = openSession();
0556:
0557:                        StringMaker query = new StringMaker();
0558:
0559:                        query
0560:                                .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0561:
0562:                        if (userId == null) {
0563:                            query.append("userId IS NULL");
0564:                        } else {
0565:                            query.append("userId = ?");
0566:                        }
0567:
0568:                        query.append(" ");
0569:
0570:                        if (obc != null) {
0571:                            query.append("ORDER BY ");
0572:                            query.append(obc.getOrderBy());
0573:                        } else {
0574:                            query.append("ORDER BY ");
0575:
0576:                            query.append("name ASC");
0577:                        }
0578:
0579:                        Query q = session.createQuery(query.toString());
0580:
0581:                        int queryPos = 0;
0582:
0583:                        if (userId != null) {
0584:                            q.setString(queryPos++, userId);
0585:                        }
0586:
0587:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0588:
0589:                        FinderCache.putResult(finderClassNameCacheEnabled,
0590:                                finderClassName, finderMethodName,
0591:                                finderParams, finderArgs, list);
0592:
0593:                        return list;
0594:                    } catch (Exception e) {
0595:                        throw HibernateUtil.processException(e);
0596:                    } finally {
0597:                        closeSession(session);
0598:                    }
0599:                } else {
0600:                    return (List) result;
0601:                }
0602:            }
0603:
0604:            public ReportsEntry findByUserId_First(String userId,
0605:                    OrderByComparator obc) throws NoSuchEntryException,
0606:                    SystemException {
0607:                List list = findByUserId(userId, 0, 1, obc);
0608:
0609:                if (list.size() == 0) {
0610:                    StringMaker msg = new StringMaker();
0611:
0612:                    msg.append("No ReportsEntry exists with the key {");
0613:
0614:                    msg.append("userId=" + userId);
0615:
0616:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0617:
0618:                    throw new NoSuchEntryException(msg.toString());
0619:                } else {
0620:                    return (ReportsEntry) list.get(0);
0621:                }
0622:            }
0623:
0624:            public ReportsEntry findByUserId_Last(String userId,
0625:                    OrderByComparator obc) throws NoSuchEntryException,
0626:                    SystemException {
0627:                int count = countByUserId(userId);
0628:
0629:                List list = findByUserId(userId, count - 1, count, obc);
0630:
0631:                if (list.size() == 0) {
0632:                    StringMaker msg = new StringMaker();
0633:
0634:                    msg.append("No ReportsEntry exists with the key {");
0635:
0636:                    msg.append("userId=" + userId);
0637:
0638:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
0639:
0640:                    throw new NoSuchEntryException(msg.toString());
0641:                } else {
0642:                    return (ReportsEntry) list.get(0);
0643:                }
0644:            }
0645:
0646:            public ReportsEntry[] findByUserId_PrevAndNext(String entryId,
0647:                    String userId, OrderByComparator obc)
0648:                    throws NoSuchEntryException, SystemException {
0649:                ReportsEntry reportsEntry = findByPrimaryKey(entryId);
0650:
0651:                int count = countByUserId(userId);
0652:
0653:                Session session = null;
0654:
0655:                try {
0656:                    session = openSession();
0657:
0658:                    StringMaker query = new StringMaker();
0659:
0660:                    query
0661:                            .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0662:
0663:                    if (userId == null) {
0664:                        query.append("userId IS NULL");
0665:                    } else {
0666:                        query.append("userId = ?");
0667:                    }
0668:
0669:                    query.append(" ");
0670:
0671:                    if (obc != null) {
0672:                        query.append("ORDER BY ");
0673:                        query.append(obc.getOrderBy());
0674:                    } else {
0675:                        query.append("ORDER BY ");
0676:
0677:                        query.append("name ASC");
0678:                    }
0679:
0680:                    Query q = session.createQuery(query.toString());
0681:
0682:                    int queryPos = 0;
0683:
0684:                    if (userId != null) {
0685:                        q.setString(queryPos++, userId);
0686:                    }
0687:
0688:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0689:                            reportsEntry);
0690:
0691:                    ReportsEntry[] array = new ReportsEntryImpl[3];
0692:
0693:                    array[0] = (ReportsEntry) objArray[0];
0694:                    array[1] = (ReportsEntry) objArray[1];
0695:                    array[2] = (ReportsEntry) objArray[2];
0696:
0697:                    return array;
0698:                } catch (Exception e) {
0699:                    throw HibernateUtil.processException(e);
0700:                } finally {
0701:                    closeSession(session);
0702:                }
0703:            }
0704:
0705:            public List findWithDynamicQuery(
0706:                    DynamicQueryInitializer queryInitializer)
0707:                    throws SystemException {
0708:                Session session = null;
0709:
0710:                try {
0711:                    session = openSession();
0712:
0713:                    DynamicQuery query = queryInitializer.initialize(session);
0714:
0715:                    return query.list();
0716:                } catch (Exception e) {
0717:                    throw HibernateUtil.processException(e);
0718:                } finally {
0719:                    closeSession(session);
0720:                }
0721:            }
0722:
0723:            public List findWithDynamicQuery(
0724:                    DynamicQueryInitializer queryInitializer, int begin, int end)
0725:                    throws SystemException {
0726:                Session session = null;
0727:
0728:                try {
0729:                    session = openSession();
0730:
0731:                    DynamicQuery query = queryInitializer.initialize(session);
0732:
0733:                    query.setLimit(begin, end);
0734:
0735:                    return query.list();
0736:                } catch (Exception e) {
0737:                    throw HibernateUtil.processException(e);
0738:                } finally {
0739:                    closeSession(session);
0740:                }
0741:            }
0742:
0743:            public List findAll() throws SystemException {
0744:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
0745:            }
0746:
0747:            public List findAll(int begin, int end) throws SystemException {
0748:                return findAll(begin, end, null);
0749:            }
0750:
0751:            public List findAll(int begin, int end, OrderByComparator obc)
0752:                    throws SystemException {
0753:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0754:                String finderClassName = ReportsEntry.class.getName();
0755:                String finderMethodName = "findAll";
0756:                String[] finderParams = new String[] { "java.lang.Integer",
0757:                        "java.lang.Integer",
0758:                        "com.liferay.portal.kernel.util.OrderByComparator" };
0759:                Object[] finderArgs = new Object[] { String.valueOf(begin),
0760:                        String.valueOf(end), String.valueOf(obc) };
0761:
0762:                Object result = null;
0763:
0764:                if (finderClassNameCacheEnabled) {
0765:                    result = FinderCache.getResult(finderClassName,
0766:                            finderMethodName, finderParams, finderArgs,
0767:                            getSessionFactory());
0768:                }
0769:
0770:                if (result == null) {
0771:                    Session session = null;
0772:
0773:                    try {
0774:                        session = openSession();
0775:
0776:                        StringMaker query = new StringMaker();
0777:
0778:                        query
0779:                                .append("FROM com.ext.portlet.reports.model.ReportsEntry ");
0780:
0781:                        if (obc != null) {
0782:                            query.append("ORDER BY ");
0783:                            query.append(obc.getOrderBy());
0784:                        } else {
0785:                            query.append("ORDER BY ");
0786:
0787:                            query.append("name ASC");
0788:                        }
0789:
0790:                        Query q = session.createQuery(query.toString());
0791:
0792:                        List list = QueryUtil.list(q, getDialect(), begin, end);
0793:
0794:                        if (obc == null) {
0795:                            Collections.sort(list);
0796:                        }
0797:
0798:                        FinderCache.putResult(finderClassNameCacheEnabled,
0799:                                finderClassName, finderMethodName,
0800:                                finderParams, finderArgs, list);
0801:
0802:                        return list;
0803:                    } catch (Exception e) {
0804:                        throw HibernateUtil.processException(e);
0805:                    } finally {
0806:                        closeSession(session);
0807:                    }
0808:                } else {
0809:                    return (List) result;
0810:                }
0811:            }
0812:
0813:            public void removeByCompanyId(String companyId)
0814:                    throws SystemException {
0815:                Iterator itr = findByCompanyId(companyId).iterator();
0816:
0817:                while (itr.hasNext()) {
0818:                    ReportsEntry reportsEntry = (ReportsEntry) itr.next();
0819:
0820:                    remove(reportsEntry);
0821:                }
0822:            }
0823:
0824:            public void removeByUserId(String userId) throws SystemException {
0825:                Iterator itr = findByUserId(userId).iterator();
0826:
0827:                while (itr.hasNext()) {
0828:                    ReportsEntry reportsEntry = (ReportsEntry) itr.next();
0829:
0830:                    remove(reportsEntry);
0831:                }
0832:            }
0833:
0834:            public void removeAll() throws SystemException {
0835:                Iterator itr = findAll().iterator();
0836:
0837:                while (itr.hasNext()) {
0838:                    remove((ReportsEntry) itr.next());
0839:                }
0840:            }
0841:
0842:            public int countByCompanyId(String companyId)
0843:                    throws SystemException {
0844:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0845:                String finderClassName = ReportsEntry.class.getName();
0846:                String finderMethodName = "countByCompanyId";
0847:                String[] finderParams = new String[] { String.class.getName() };
0848:                Object[] finderArgs = new Object[] { companyId };
0849:
0850:                Object result = null;
0851:
0852:                if (finderClassNameCacheEnabled) {
0853:                    result = FinderCache.getResult(finderClassName,
0854:                            finderMethodName, finderParams, finderArgs,
0855:                            getSessionFactory());
0856:                }
0857:
0858:                if (result == null) {
0859:                    Session session = null;
0860:
0861:                    try {
0862:                        session = openSession();
0863:
0864:                        StringMaker query = new StringMaker();
0865:
0866:                        query.append("SELECT COUNT(*) ");
0867:                        query
0868:                                .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0869:
0870:                        if (companyId == null) {
0871:                            query.append("companyId IS NULL");
0872:                        } else {
0873:                            query.append("companyId = ?");
0874:                        }
0875:
0876:                        query.append(" ");
0877:
0878:                        Query q = session.createQuery(query.toString());
0879:
0880:                        int queryPos = 0;
0881:
0882:                        if (companyId != null) {
0883:                            q.setString(queryPos++, companyId);
0884:                        }
0885:
0886:                        Long count = null;
0887:
0888:                        Iterator itr = q.list().iterator();
0889:
0890:                        if (itr.hasNext()) {
0891:                            count = (Long) itr.next();
0892:                        }
0893:
0894:                        if (count == null) {
0895:                            count = new Long(0);
0896:                        }
0897:
0898:                        FinderCache.putResult(finderClassNameCacheEnabled,
0899:                                finderClassName, finderMethodName,
0900:                                finderParams, finderArgs, count);
0901:
0902:                        return count.intValue();
0903:                    } catch (Exception e) {
0904:                        throw HibernateUtil.processException(e);
0905:                    } finally {
0906:                        closeSession(session);
0907:                    }
0908:                } else {
0909:                    return ((Long) result).intValue();
0910:                }
0911:            }
0912:
0913:            public int countByUserId(String userId) throws SystemException {
0914:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0915:                String finderClassName = ReportsEntry.class.getName();
0916:                String finderMethodName = "countByUserId";
0917:                String[] finderParams = new String[] { String.class.getName() };
0918:                Object[] finderArgs = new Object[] { userId };
0919:
0920:                Object result = null;
0921:
0922:                if (finderClassNameCacheEnabled) {
0923:                    result = FinderCache.getResult(finderClassName,
0924:                            finderMethodName, finderParams, finderArgs,
0925:                            getSessionFactory());
0926:                }
0927:
0928:                if (result == null) {
0929:                    Session session = null;
0930:
0931:                    try {
0932:                        session = openSession();
0933:
0934:                        StringMaker query = new StringMaker();
0935:
0936:                        query.append("SELECT COUNT(*) ");
0937:                        query
0938:                                .append("FROM com.ext.portlet.reports.model.ReportsEntry WHERE ");
0939:
0940:                        if (userId == null) {
0941:                            query.append("userId IS NULL");
0942:                        } else {
0943:                            query.append("userId = ?");
0944:                        }
0945:
0946:                        query.append(" ");
0947:
0948:                        Query q = session.createQuery(query.toString());
0949:
0950:                        int queryPos = 0;
0951:
0952:                        if (userId != null) {
0953:                            q.setString(queryPos++, userId);
0954:                        }
0955:
0956:                        Long count = null;
0957:
0958:                        Iterator itr = q.list().iterator();
0959:
0960:                        if (itr.hasNext()) {
0961:                            count = (Long) itr.next();
0962:                        }
0963:
0964:                        if (count == null) {
0965:                            count = new Long(0);
0966:                        }
0967:
0968:                        FinderCache.putResult(finderClassNameCacheEnabled,
0969:                                finderClassName, finderMethodName,
0970:                                finderParams, finderArgs, count);
0971:
0972:                        return count.intValue();
0973:                    } catch (Exception e) {
0974:                        throw HibernateUtil.processException(e);
0975:                    } finally {
0976:                        closeSession(session);
0977:                    }
0978:                } else {
0979:                    return ((Long) result).intValue();
0980:                }
0981:            }
0982:
0983:            public int countAll() throws SystemException {
0984:                boolean finderClassNameCacheEnabled = ReportsEntryModelImpl.CACHE_ENABLED;
0985:                String finderClassName = ReportsEntry.class.getName();
0986:                String finderMethodName = "countAll";
0987:                String[] finderParams = new String[] {};
0988:                Object[] finderArgs = new Object[] {};
0989:
0990:                Object result = null;
0991:
0992:                if (finderClassNameCacheEnabled) {
0993:                    result = FinderCache.getResult(finderClassName,
0994:                            finderMethodName, finderParams, finderArgs,
0995:                            getSessionFactory());
0996:                }
0997:
0998:                if (result == null) {
0999:                    Session session = null;
1000:
1001:                    try {
1002:                        session = openSession();
1003:
1004:                        Query q = session
1005:                                .createQuery("SELECT COUNT(*) FROM com.ext.portlet.reports.model.ReportsEntry");
1006:
1007:                        Long count = null;
1008:
1009:                        Iterator itr = q.list().iterator();
1010:
1011:                        if (itr.hasNext()) {
1012:                            count = (Long) itr.next();
1013:                        }
1014:
1015:                        if (count == null) {
1016:                            count = new Long(0);
1017:                        }
1018:
1019:                        FinderCache.putResult(finderClassNameCacheEnabled,
1020:                                finderClassName, finderMethodName,
1021:                                finderParams, finderArgs, count);
1022:
1023:                        return count.intValue();
1024:                    } catch (Exception e) {
1025:                        throw HibernateUtil.processException(e);
1026:                    } finally {
1027:                        closeSession(session);
1028:                    }
1029:                } else {
1030:                    return ((Long) result).intValue();
1031:                }
1032:            }
1033:
1034:            protected void initDao() {
1035:            }
1036:
1037:            private static ModelListener _getListener() {
1038:                if (Validator.isNotNull(_LISTENER)) {
1039:                    try {
1040:                        return (ModelListener) Class.forName(_LISTENER)
1041:                                .newInstance();
1042:                    } catch (Exception e) {
1043:                        _log.error(e);
1044:                    }
1045:                }
1046:
1047:                return null;
1048:            }
1049:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.