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


001:        /**
002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020:         * SOFTWARE.
021:         */package com.liferay.portal.service.persistence;
022:
023:        import com.liferay.portal.NoSuchPasswordTrackerException;
024:        import com.liferay.portal.SystemException;
025:        import com.liferay.portal.kernel.dao.DynamicQuery;
026:        import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
027:        import com.liferay.portal.kernel.util.GetterUtil;
028:        import com.liferay.portal.kernel.util.OrderByComparator;
029:        import com.liferay.portal.kernel.util.StringMaker;
030:        import com.liferay.portal.kernel.util.StringPool;
031:        import com.liferay.portal.kernel.util.Validator;
032:        import com.liferay.portal.model.ModelListener;
033:        import com.liferay.portal.model.PasswordTracker;
034:        import com.liferay.portal.model.impl.PasswordTrackerImpl;
035:        import com.liferay.portal.model.impl.PasswordTrackerModelImpl;
036:        import com.liferay.portal.spring.hibernate.FinderCache;
037:        import com.liferay.portal.spring.hibernate.HibernateUtil;
038:        import com.liferay.portal.util.PropsUtil;
039:
040:        import com.liferay.util.dao.hibernate.QueryUtil;
041:
042:        import org.apache.commons.logging.Log;
043:        import org.apache.commons.logging.LogFactory;
044:
045:        import org.hibernate.Query;
046:        import org.hibernate.Session;
047:
048:        import java.util.Collections;
049:        import java.util.Iterator;
050:        import java.util.List;
051:
052:        /**
053:         * <a href="PasswordTrackerPersistenceImpl.java.html"><b><i>View Source</i></b></a>
054:         *
055:         * @author Brian Wing Shun Chan
056:         *
057:         */
058:        public class PasswordTrackerPersistenceImpl extends BasePersistence
059:                implements  PasswordTrackerPersistence {
060:            public PasswordTracker create(long passwordTrackerId) {
061:                PasswordTracker passwordTracker = new PasswordTrackerImpl();
062:
063:                passwordTracker.setNew(true);
064:                passwordTracker.setPrimaryKey(passwordTrackerId);
065:
066:                return passwordTracker;
067:            }
068:
069:            public PasswordTracker remove(long passwordTrackerId)
070:                    throws NoSuchPasswordTrackerException, SystemException {
071:                Session session = null;
072:
073:                try {
074:                    session = openSession();
075:
076:                    PasswordTracker passwordTracker = (PasswordTracker) session
077:                            .get(PasswordTrackerImpl.class, new Long(
078:                                    passwordTrackerId));
079:
080:                    if (passwordTracker == null) {
081:                        if (_log.isWarnEnabled()) {
082:                            _log
083:                                    .warn("No PasswordTracker exists with the primary key "
084:                                            + passwordTrackerId);
085:                        }
086:
087:                        throw new NoSuchPasswordTrackerException(
088:                                "No PasswordTracker exists with the primary key "
089:                                        + passwordTrackerId);
090:                    }
091:
092:                    return remove(passwordTracker);
093:                } catch (NoSuchPasswordTrackerException nsee) {
094:                    throw nsee;
095:                } catch (Exception e) {
096:                    throw HibernateUtil.processException(e);
097:                } finally {
098:                    closeSession(session);
099:                }
100:            }
101:
102:            public PasswordTracker remove(PasswordTracker passwordTracker)
103:                    throws SystemException {
104:                ModelListener listener = _getListener();
105:
106:                if (listener != null) {
107:                    listener.onBeforeRemove(passwordTracker);
108:                }
109:
110:                passwordTracker = removeImpl(passwordTracker);
111:
112:                if (listener != null) {
113:                    listener.onAfterRemove(passwordTracker);
114:                }
115:
116:                return passwordTracker;
117:            }
118:
119:            protected PasswordTracker removeImpl(PasswordTracker passwordTracker)
120:                    throws SystemException {
121:                Session session = null;
122:
123:                try {
124:                    session = openSession();
125:
126:                    session.delete(passwordTracker);
127:
128:                    session.flush();
129:
130:                    return passwordTracker;
131:                } catch (Exception e) {
132:                    throw HibernateUtil.processException(e);
133:                } finally {
134:                    closeSession(session);
135:
136:                    FinderCache.clearCache(PasswordTracker.class.getName());
137:                }
138:            }
139:
140:            public PasswordTracker update(PasswordTracker passwordTracker)
141:                    throws SystemException {
142:                return update(passwordTracker, false);
143:            }
144:
145:            public PasswordTracker update(PasswordTracker passwordTracker,
146:                    boolean merge) throws SystemException {
147:                ModelListener listener = _getListener();
148:
149:                boolean isNew = passwordTracker.isNew();
150:
151:                if (listener != null) {
152:                    if (isNew) {
153:                        listener.onBeforeCreate(passwordTracker);
154:                    } else {
155:                        listener.onBeforeUpdate(passwordTracker);
156:                    }
157:                }
158:
159:                passwordTracker = updateImpl(passwordTracker, merge);
160:
161:                if (listener != null) {
162:                    if (isNew) {
163:                        listener.onAfterCreate(passwordTracker);
164:                    } else {
165:                        listener.onAfterUpdate(passwordTracker);
166:                    }
167:                }
168:
169:                return passwordTracker;
170:            }
171:
172:            public PasswordTracker updateImpl(
173:                    com.liferay.portal.model.PasswordTracker passwordTracker,
174:                    boolean merge) throws SystemException {
175:                Session session = null;
176:
177:                try {
178:                    session = openSession();
179:
180:                    if (merge) {
181:                        session.merge(passwordTracker);
182:                    } else {
183:                        if (passwordTracker.isNew()) {
184:                            session.save(passwordTracker);
185:                        }
186:                    }
187:
188:                    session.flush();
189:
190:                    passwordTracker.setNew(false);
191:
192:                    return passwordTracker;
193:                } catch (Exception e) {
194:                    throw HibernateUtil.processException(e);
195:                } finally {
196:                    closeSession(session);
197:
198:                    FinderCache.clearCache(PasswordTracker.class.getName());
199:                }
200:            }
201:
202:            public PasswordTracker findByPrimaryKey(long passwordTrackerId)
203:                    throws NoSuchPasswordTrackerException, SystemException {
204:                PasswordTracker passwordTracker = fetchByPrimaryKey(passwordTrackerId);
205:
206:                if (passwordTracker == null) {
207:                    if (_log.isWarnEnabled()) {
208:                        _log
209:                                .warn("No PasswordTracker exists with the primary key "
210:                                        + passwordTrackerId);
211:                    }
212:
213:                    throw new NoSuchPasswordTrackerException(
214:                            "No PasswordTracker exists with the primary key "
215:                                    + passwordTrackerId);
216:                }
217:
218:                return passwordTracker;
219:            }
220:
221:            public PasswordTracker fetchByPrimaryKey(long passwordTrackerId)
222:                    throws SystemException {
223:                Session session = null;
224:
225:                try {
226:                    session = openSession();
227:
228:                    return (PasswordTracker) session.get(
229:                            PasswordTrackerImpl.class, new Long(
230:                                    passwordTrackerId));
231:                } catch (Exception e) {
232:                    throw HibernateUtil.processException(e);
233:                } finally {
234:                    closeSession(session);
235:                }
236:            }
237:
238:            public List findByUserId(long userId) throws SystemException {
239:                boolean finderClassNameCacheEnabled = PasswordTrackerModelImpl.CACHE_ENABLED;
240:                String finderClassName = PasswordTracker.class.getName();
241:                String finderMethodName = "findByUserId";
242:                String[] finderParams = new String[] { Long.class.getName() };
243:                Object[] finderArgs = new Object[] { new Long(userId) };
244:
245:                Object result = null;
246:
247:                if (finderClassNameCacheEnabled) {
248:                    result = FinderCache.getResult(finderClassName,
249:                            finderMethodName, finderParams, finderArgs,
250:                            getSessionFactory());
251:                }
252:
253:                if (result == null) {
254:                    Session session = null;
255:
256:                    try {
257:                        session = openSession();
258:
259:                        StringMaker query = new StringMaker();
260:
261:                        query
262:                                .append("FROM com.liferay.portal.model.PasswordTracker WHERE ");
263:
264:                        query.append("userId = ?");
265:
266:                        query.append(" ");
267:
268:                        query.append("ORDER BY ");
269:
270:                        query.append("userId DESC, ");
271:                        query.append("createDate DESC");
272:
273:                        Query q = session.createQuery(query.toString());
274:
275:                        int queryPos = 0;
276:
277:                        q.setLong(queryPos++, userId);
278:
279:                        List list = q.list();
280:
281:                        FinderCache.putResult(finderClassNameCacheEnabled,
282:                                finderClassName, finderMethodName,
283:                                finderParams, finderArgs, list);
284:
285:                        return list;
286:                    } catch (Exception e) {
287:                        throw HibernateUtil.processException(e);
288:                    } finally {
289:                        closeSession(session);
290:                    }
291:                } else {
292:                    return (List) result;
293:                }
294:            }
295:
296:            public List findByUserId(long userId, int begin, int end)
297:                    throws SystemException {
298:                return findByUserId(userId, begin, end, null);
299:            }
300:
301:            public List findByUserId(long userId, int begin, int end,
302:                    OrderByComparator obc) throws SystemException {
303:                boolean finderClassNameCacheEnabled = PasswordTrackerModelImpl.CACHE_ENABLED;
304:                String finderClassName = PasswordTracker.class.getName();
305:                String finderMethodName = "findByUserId";
306:                String[] finderParams = new String[] { Long.class.getName(),
307:
308:                "java.lang.Integer", "java.lang.Integer",
309:                        "com.liferay.portal.kernel.util.OrderByComparator" };
310:                Object[] finderArgs = new Object[] { new Long(userId),
311:
312:                String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
313:
314:                Object result = null;
315:
316:                if (finderClassNameCacheEnabled) {
317:                    result = FinderCache.getResult(finderClassName,
318:                            finderMethodName, finderParams, finderArgs,
319:                            getSessionFactory());
320:                }
321:
322:                if (result == null) {
323:                    Session session = null;
324:
325:                    try {
326:                        session = openSession();
327:
328:                        StringMaker query = new StringMaker();
329:
330:                        query
331:                                .append("FROM com.liferay.portal.model.PasswordTracker WHERE ");
332:
333:                        query.append("userId = ?");
334:
335:                        query.append(" ");
336:
337:                        if (obc != null) {
338:                            query.append("ORDER BY ");
339:                            query.append(obc.getOrderBy());
340:                        }
341:
342:                        else {
343:                            query.append("ORDER BY ");
344:
345:                            query.append("userId DESC, ");
346:                            query.append("createDate DESC");
347:                        }
348:
349:                        Query q = session.createQuery(query.toString());
350:
351:                        int queryPos = 0;
352:
353:                        q.setLong(queryPos++, userId);
354:
355:                        List list = QueryUtil.list(q, getDialect(), begin, end);
356:
357:                        FinderCache.putResult(finderClassNameCacheEnabled,
358:                                finderClassName, finderMethodName,
359:                                finderParams, finderArgs, list);
360:
361:                        return list;
362:                    } catch (Exception e) {
363:                        throw HibernateUtil.processException(e);
364:                    } finally {
365:                        closeSession(session);
366:                    }
367:                } else {
368:                    return (List) result;
369:                }
370:            }
371:
372:            public PasswordTracker findByUserId_First(long userId,
373:                    OrderByComparator obc)
374:                    throws NoSuchPasswordTrackerException, SystemException {
375:                List list = findByUserId(userId, 0, 1, obc);
376:
377:                if (list.size() == 0) {
378:                    StringMaker msg = new StringMaker();
379:
380:                    msg.append("No PasswordTracker exists with the key {");
381:
382:                    msg.append("userId=" + userId);
383:
384:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
385:
386:                    throw new NoSuchPasswordTrackerException(msg.toString());
387:                } else {
388:                    return (PasswordTracker) list.get(0);
389:                }
390:            }
391:
392:            public PasswordTracker findByUserId_Last(long userId,
393:                    OrderByComparator obc)
394:                    throws NoSuchPasswordTrackerException, SystemException {
395:                int count = countByUserId(userId);
396:
397:                List list = findByUserId(userId, count - 1, count, obc);
398:
399:                if (list.size() == 0) {
400:                    StringMaker msg = new StringMaker();
401:
402:                    msg.append("No PasswordTracker exists with the key {");
403:
404:                    msg.append("userId=" + userId);
405:
406:                    msg.append(StringPool.CLOSE_CURLY_BRACE);
407:
408:                    throw new NoSuchPasswordTrackerException(msg.toString());
409:                } else {
410:                    return (PasswordTracker) list.get(0);
411:                }
412:            }
413:
414:            public PasswordTracker[] findByUserId_PrevAndNext(
415:                    long passwordTrackerId, long userId, OrderByComparator obc)
416:                    throws NoSuchPasswordTrackerException, SystemException {
417:                PasswordTracker passwordTracker = findByPrimaryKey(passwordTrackerId);
418:
419:                int count = countByUserId(userId);
420:
421:                Session session = null;
422:
423:                try {
424:                    session = openSession();
425:
426:                    StringMaker query = new StringMaker();
427:
428:                    query
429:                            .append("FROM com.liferay.portal.model.PasswordTracker WHERE ");
430:
431:                    query.append("userId = ?");
432:
433:                    query.append(" ");
434:
435:                    if (obc != null) {
436:                        query.append("ORDER BY ");
437:                        query.append(obc.getOrderBy());
438:                    }
439:
440:                    else {
441:                        query.append("ORDER BY ");
442:
443:                        query.append("userId DESC, ");
444:                        query.append("createDate DESC");
445:                    }
446:
447:                    Query q = session.createQuery(query.toString());
448:
449:                    int queryPos = 0;
450:
451:                    q.setLong(queryPos++, userId);
452:
453:                    Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
454:                            passwordTracker);
455:
456:                    PasswordTracker[] array = new PasswordTrackerImpl[3];
457:
458:                    array[0] = (PasswordTracker) objArray[0];
459:                    array[1] = (PasswordTracker) objArray[1];
460:                    array[2] = (PasswordTracker) objArray[2];
461:
462:                    return array;
463:                } catch (Exception e) {
464:                    throw HibernateUtil.processException(e);
465:                } finally {
466:                    closeSession(session);
467:                }
468:            }
469:
470:            public List findWithDynamicQuery(
471:                    DynamicQueryInitializer queryInitializer)
472:                    throws SystemException {
473:                Session session = null;
474:
475:                try {
476:                    session = openSession();
477:
478:                    DynamicQuery query = queryInitializer.initialize(session);
479:
480:                    return query.list();
481:                } catch (Exception e) {
482:                    throw HibernateUtil.processException(e);
483:                } finally {
484:                    closeSession(session);
485:                }
486:            }
487:
488:            public List findWithDynamicQuery(
489:                    DynamicQueryInitializer queryInitializer, int begin, int end)
490:                    throws SystemException {
491:                Session session = null;
492:
493:                try {
494:                    session = openSession();
495:
496:                    DynamicQuery query = queryInitializer.initialize(session);
497:
498:                    query.setLimit(begin, end);
499:
500:                    return query.list();
501:                } catch (Exception e) {
502:                    throw HibernateUtil.processException(e);
503:                } finally {
504:                    closeSession(session);
505:                }
506:            }
507:
508:            public List findAll() throws SystemException {
509:                return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
510:            }
511:
512:            public List findAll(int begin, int end) throws SystemException {
513:                return findAll(begin, end, null);
514:            }
515:
516:            public List findAll(int begin, int end, OrderByComparator obc)
517:                    throws SystemException {
518:                boolean finderClassNameCacheEnabled = PasswordTrackerModelImpl.CACHE_ENABLED;
519:                String finderClassName = PasswordTracker.class.getName();
520:                String finderMethodName = "findAll";
521:                String[] finderParams = new String[] { "java.lang.Integer",
522:                        "java.lang.Integer",
523:                        "com.liferay.portal.kernel.util.OrderByComparator" };
524:                Object[] finderArgs = new Object[] { String.valueOf(begin),
525:                        String.valueOf(end), String.valueOf(obc) };
526:
527:                Object result = null;
528:
529:                if (finderClassNameCacheEnabled) {
530:                    result = FinderCache.getResult(finderClassName,
531:                            finderMethodName, finderParams, finderArgs,
532:                            getSessionFactory());
533:                }
534:
535:                if (result == null) {
536:                    Session session = null;
537:
538:                    try {
539:                        session = openSession();
540:
541:                        StringMaker query = new StringMaker();
542:
543:                        query
544:                                .append("FROM com.liferay.portal.model.PasswordTracker ");
545:
546:                        if (obc != null) {
547:                            query.append("ORDER BY ");
548:                            query.append(obc.getOrderBy());
549:                        }
550:
551:                        else {
552:                            query.append("ORDER BY ");
553:
554:                            query.append("userId DESC, ");
555:                            query.append("createDate DESC");
556:                        }
557:
558:                        Query q = session.createQuery(query.toString());
559:
560:                        List list = QueryUtil.list(q, getDialect(), begin, end);
561:
562:                        if (obc == null) {
563:                            Collections.sort(list);
564:                        }
565:
566:                        FinderCache.putResult(finderClassNameCacheEnabled,
567:                                finderClassName, finderMethodName,
568:                                finderParams, finderArgs, list);
569:
570:                        return list;
571:                    } catch (Exception e) {
572:                        throw HibernateUtil.processException(e);
573:                    } finally {
574:                        closeSession(session);
575:                    }
576:                } else {
577:                    return (List) result;
578:                }
579:            }
580:
581:            public void removeByUserId(long userId) throws SystemException {
582:                Iterator itr = findByUserId(userId).iterator();
583:
584:                while (itr.hasNext()) {
585:                    PasswordTracker passwordTracker = (PasswordTracker) itr
586:                            .next();
587:
588:                    remove(passwordTracker);
589:                }
590:            }
591:
592:            public void removeAll() throws SystemException {
593:                Iterator itr = findAll().iterator();
594:
595:                while (itr.hasNext()) {
596:                    remove((PasswordTracker) itr.next());
597:                }
598:            }
599:
600:            public int countByUserId(long userId) throws SystemException {
601:                boolean finderClassNameCacheEnabled = PasswordTrackerModelImpl.CACHE_ENABLED;
602:                String finderClassName = PasswordTracker.class.getName();
603:                String finderMethodName = "countByUserId";
604:                String[] finderParams = new String[] { Long.class.getName() };
605:                Object[] finderArgs = new Object[] { new Long(userId) };
606:
607:                Object result = null;
608:
609:                if (finderClassNameCacheEnabled) {
610:                    result = FinderCache.getResult(finderClassName,
611:                            finderMethodName, finderParams, finderArgs,
612:                            getSessionFactory());
613:                }
614:
615:                if (result == null) {
616:                    Session session = null;
617:
618:                    try {
619:                        session = openSession();
620:
621:                        StringMaker query = new StringMaker();
622:
623:                        query.append("SELECT COUNT(*) ");
624:                        query
625:                                .append("FROM com.liferay.portal.model.PasswordTracker WHERE ");
626:
627:                        query.append("userId = ?");
628:
629:                        query.append(" ");
630:
631:                        Query q = session.createQuery(query.toString());
632:
633:                        int queryPos = 0;
634:
635:                        q.setLong(queryPos++, userId);
636:
637:                        Long count = null;
638:
639:                        Iterator itr = q.list().iterator();
640:
641:                        if (itr.hasNext()) {
642:                            count = (Long) itr.next();
643:                        }
644:
645:                        if (count == null) {
646:                            count = new Long(0);
647:                        }
648:
649:                        FinderCache.putResult(finderClassNameCacheEnabled,
650:                                finderClassName, finderMethodName,
651:                                finderParams, finderArgs, count);
652:
653:                        return count.intValue();
654:                    } catch (Exception e) {
655:                        throw HibernateUtil.processException(e);
656:                    } finally {
657:                        closeSession(session);
658:                    }
659:                } else {
660:                    return ((Long) result).intValue();
661:                }
662:            }
663:
664:            public int countAll() throws SystemException {
665:                boolean finderClassNameCacheEnabled = PasswordTrackerModelImpl.CACHE_ENABLED;
666:                String finderClassName = PasswordTracker.class.getName();
667:                String finderMethodName = "countAll";
668:                String[] finderParams = new String[] {};
669:                Object[] finderArgs = new Object[] {};
670:
671:                Object result = null;
672:
673:                if (finderClassNameCacheEnabled) {
674:                    result = FinderCache.getResult(finderClassName,
675:                            finderMethodName, finderParams, finderArgs,
676:                            getSessionFactory());
677:                }
678:
679:                if (result == null) {
680:                    Session session = null;
681:
682:                    try {
683:                        session = openSession();
684:
685:                        Query q = session
686:                                .createQuery("SELECT COUNT(*) FROM com.liferay.portal.model.PasswordTracker");
687:
688:                        Long count = null;
689:
690:                        Iterator itr = q.list().iterator();
691:
692:                        if (itr.hasNext()) {
693:                            count = (Long) itr.next();
694:                        }
695:
696:                        if (count == null) {
697:                            count = new Long(0);
698:                        }
699:
700:                        FinderCache.putResult(finderClassNameCacheEnabled,
701:                                finderClassName, finderMethodName,
702:                                finderParams, finderArgs, count);
703:
704:                        return count.intValue();
705:                    } catch (Exception e) {
706:                        throw HibernateUtil.processException(e);
707:                    } finally {
708:                        closeSession(session);
709:                    }
710:                } else {
711:                    return ((Long) result).intValue();
712:                }
713:            }
714:
715:            protected void initDao() {
716:            }
717:
718:            private static ModelListener _getListener() {
719:                if (Validator.isNotNull(_LISTENER)) {
720:                    try {
721:                        return (ModelListener) Class.forName(_LISTENER)
722:                                .newInstance();
723:                    } catch (Exception e) {
724:                        _log.error(e);
725:                    }
726:                }
727:
728:                return null;
729:            }
730:
731:            private static final String _LISTENER = GetterUtil
732:                    .getString(PropsUtil
733:                            .get("value.object.listener.com.liferay.portal.model.PasswordTracker"));
734:            private static Log _log = LogFactory
735:                    .getLog(PasswordTrackerPersistenceImpl.class);
736:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.