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