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