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