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