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