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