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