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