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