Source Code Cross Referenced for IGFolderPersistenceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portlet » imagegallery » service » persistence » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » com.liferay.portlet.imagegallery.service.persistence 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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