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