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