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