Source Code Cross Referenced for PortletPreferencesPersistenceImpl.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) 


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