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.NoSuchOrgGroupPermissionException;
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.OrgGroupPermission;
0034: import com.liferay.portal.model.impl.OrgGroupPermissionImpl;
0035: import com.liferay.portal.model.impl.OrgGroupPermissionModelImpl;
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="OrgGroupPermissionPersistenceImpl.java.html"><b><i>View Source</i></b></a>
0054: *
0055: * @author Brian Wing Shun Chan
0056: *
0057: */
0058: public class OrgGroupPermissionPersistenceImpl extends BasePersistence
0059: implements OrgGroupPermissionPersistence {
0060: public OrgGroupPermission create(
0061: OrgGroupPermissionPK orgGroupPermissionPK) {
0062: OrgGroupPermission orgGroupPermission = new OrgGroupPermissionImpl();
0063:
0064: orgGroupPermission.setNew(true);
0065: orgGroupPermission.setPrimaryKey(orgGroupPermissionPK);
0066:
0067: return orgGroupPermission;
0068: }
0069:
0070: public OrgGroupPermission remove(
0071: OrgGroupPermissionPK orgGroupPermissionPK)
0072: throws NoSuchOrgGroupPermissionException, SystemException {
0073: Session session = null;
0074:
0075: try {
0076: session = openSession();
0077:
0078: OrgGroupPermission orgGroupPermission = (OrgGroupPermission) session
0079: .get(OrgGroupPermissionImpl.class,
0080: orgGroupPermissionPK);
0081:
0082: if (orgGroupPermission == null) {
0083: if (_log.isWarnEnabled()) {
0084: _log
0085: .warn("No OrgGroupPermission exists with the primary key "
0086: + orgGroupPermissionPK);
0087: }
0088:
0089: throw new NoSuchOrgGroupPermissionException(
0090: "No OrgGroupPermission exists with the primary key "
0091: + orgGroupPermissionPK);
0092: }
0093:
0094: return remove(orgGroupPermission);
0095: } catch (NoSuchOrgGroupPermissionException nsee) {
0096: throw nsee;
0097: } catch (Exception e) {
0098: throw HibernateUtil.processException(e);
0099: } finally {
0100: closeSession(session);
0101: }
0102: }
0103:
0104: public OrgGroupPermission remove(
0105: OrgGroupPermission orgGroupPermission)
0106: throws SystemException {
0107: ModelListener listener = _getListener();
0108:
0109: if (listener != null) {
0110: listener.onBeforeRemove(orgGroupPermission);
0111: }
0112:
0113: orgGroupPermission = removeImpl(orgGroupPermission);
0114:
0115: if (listener != null) {
0116: listener.onAfterRemove(orgGroupPermission);
0117: }
0118:
0119: return orgGroupPermission;
0120: }
0121:
0122: protected OrgGroupPermission removeImpl(
0123: OrgGroupPermission orgGroupPermission)
0124: throws SystemException {
0125: Session session = null;
0126:
0127: try {
0128: session = openSession();
0129:
0130: session.delete(orgGroupPermission);
0131:
0132: session.flush();
0133:
0134: return orgGroupPermission;
0135: } catch (Exception e) {
0136: throw HibernateUtil.processException(e);
0137: } finally {
0138: closeSession(session);
0139:
0140: FinderCache.clearCache(OrgGroupPermission.class.getName());
0141: }
0142: }
0143:
0144: public OrgGroupPermission update(
0145: OrgGroupPermission orgGroupPermission)
0146: throws SystemException {
0147: return update(orgGroupPermission, false);
0148: }
0149:
0150: public OrgGroupPermission update(
0151: OrgGroupPermission orgGroupPermission, boolean merge)
0152: throws SystemException {
0153: ModelListener listener = _getListener();
0154:
0155: boolean isNew = orgGroupPermission.isNew();
0156:
0157: if (listener != null) {
0158: if (isNew) {
0159: listener.onBeforeCreate(orgGroupPermission);
0160: } else {
0161: listener.onBeforeUpdate(orgGroupPermission);
0162: }
0163: }
0164:
0165: orgGroupPermission = updateImpl(orgGroupPermission, merge);
0166:
0167: if (listener != null) {
0168: if (isNew) {
0169: listener.onAfterCreate(orgGroupPermission);
0170: } else {
0171: listener.onAfterUpdate(orgGroupPermission);
0172: }
0173: }
0174:
0175: return orgGroupPermission;
0176: }
0177:
0178: public OrgGroupPermission updateImpl(
0179: com.liferay.portal.model.OrgGroupPermission orgGroupPermission,
0180: boolean merge) throws SystemException {
0181: Session session = null;
0182:
0183: try {
0184: session = openSession();
0185:
0186: if (merge) {
0187: session.merge(orgGroupPermission);
0188: } else {
0189: if (orgGroupPermission.isNew()) {
0190: session.save(orgGroupPermission);
0191: }
0192: }
0193:
0194: session.flush();
0195:
0196: orgGroupPermission.setNew(false);
0197:
0198: return orgGroupPermission;
0199: } catch (Exception e) {
0200: throw HibernateUtil.processException(e);
0201: } finally {
0202: closeSession(session);
0203:
0204: FinderCache.clearCache(OrgGroupPermission.class.getName());
0205: }
0206: }
0207:
0208: public OrgGroupPermission findByPrimaryKey(
0209: OrgGroupPermissionPK orgGroupPermissionPK)
0210: throws NoSuchOrgGroupPermissionException, SystemException {
0211: OrgGroupPermission orgGroupPermission = fetchByPrimaryKey(orgGroupPermissionPK);
0212:
0213: if (orgGroupPermission == null) {
0214: if (_log.isWarnEnabled()) {
0215: _log
0216: .warn("No OrgGroupPermission exists with the primary key "
0217: + orgGroupPermissionPK);
0218: }
0219:
0220: throw new NoSuchOrgGroupPermissionException(
0221: "No OrgGroupPermission exists with the primary key "
0222: + orgGroupPermissionPK);
0223: }
0224:
0225: return orgGroupPermission;
0226: }
0227:
0228: public OrgGroupPermission fetchByPrimaryKey(
0229: OrgGroupPermissionPK orgGroupPermissionPK)
0230: throws SystemException {
0231: Session session = null;
0232:
0233: try {
0234: session = openSession();
0235:
0236: return (OrgGroupPermission) session.get(
0237: OrgGroupPermissionImpl.class, orgGroupPermissionPK);
0238: } catch (Exception e) {
0239: throw HibernateUtil.processException(e);
0240: } finally {
0241: closeSession(session);
0242: }
0243: }
0244:
0245: public List findByGroupId(long groupId) throws SystemException {
0246: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0247: String finderClassName = OrgGroupPermission.class.getName();
0248: String finderMethodName = "findByGroupId";
0249: String[] finderParams = new String[] { Long.class.getName() };
0250: Object[] finderArgs = new Object[] { new Long(groupId) };
0251:
0252: Object result = null;
0253:
0254: if (finderClassNameCacheEnabled) {
0255: result = FinderCache.getResult(finderClassName,
0256: finderMethodName, finderParams, finderArgs,
0257: getSessionFactory());
0258: }
0259:
0260: if (result == null) {
0261: Session session = null;
0262:
0263: try {
0264: session = openSession();
0265:
0266: StringMaker query = new StringMaker();
0267:
0268: query
0269: .append("FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
0270:
0271: query.append("groupId = ?");
0272:
0273: query.append(" ");
0274:
0275: Query q = session.createQuery(query.toString());
0276:
0277: int queryPos = 0;
0278:
0279: q.setLong(queryPos++, groupId);
0280:
0281: List list = q.list();
0282:
0283: FinderCache.putResult(finderClassNameCacheEnabled,
0284: finderClassName, finderMethodName,
0285: finderParams, finderArgs, list);
0286:
0287: return list;
0288: } catch (Exception e) {
0289: throw HibernateUtil.processException(e);
0290: } finally {
0291: closeSession(session);
0292: }
0293: } else {
0294: return (List) result;
0295: }
0296: }
0297:
0298: public List findByGroupId(long groupId, int begin, int end)
0299: throws SystemException {
0300: return findByGroupId(groupId, begin, end, null);
0301: }
0302:
0303: public List findByGroupId(long groupId, int begin, int end,
0304: OrderByComparator obc) throws SystemException {
0305: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0306: String finderClassName = OrgGroupPermission.class.getName();
0307: String finderMethodName = "findByGroupId";
0308: String[] finderParams = new String[] { Long.class.getName(),
0309:
0310: "java.lang.Integer", "java.lang.Integer",
0311: "com.liferay.portal.kernel.util.OrderByComparator" };
0312: Object[] finderArgs = new Object[] { new Long(groupId),
0313:
0314: String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0315:
0316: Object result = null;
0317:
0318: if (finderClassNameCacheEnabled) {
0319: result = FinderCache.getResult(finderClassName,
0320: finderMethodName, finderParams, finderArgs,
0321: getSessionFactory());
0322: }
0323:
0324: if (result == null) {
0325: Session session = null;
0326:
0327: try {
0328: session = openSession();
0329:
0330: StringMaker query = new StringMaker();
0331:
0332: query
0333: .append("FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
0334:
0335: query.append("groupId = ?");
0336:
0337: query.append(" ");
0338:
0339: if (obc != null) {
0340: query.append("ORDER BY ");
0341: query.append(obc.getOrderBy());
0342: }
0343:
0344: Query q = session.createQuery(query.toString());
0345:
0346: int queryPos = 0;
0347:
0348: q.setLong(queryPos++, groupId);
0349:
0350: List list = QueryUtil.list(q, getDialect(), begin, end);
0351:
0352: FinderCache.putResult(finderClassNameCacheEnabled,
0353: finderClassName, finderMethodName,
0354: finderParams, finderArgs, list);
0355:
0356: return list;
0357: } catch (Exception e) {
0358: throw HibernateUtil.processException(e);
0359: } finally {
0360: closeSession(session);
0361: }
0362: } else {
0363: return (List) result;
0364: }
0365: }
0366:
0367: public OrgGroupPermission findByGroupId_First(long groupId,
0368: OrderByComparator obc)
0369: throws NoSuchOrgGroupPermissionException, SystemException {
0370: List list = findByGroupId(groupId, 0, 1, obc);
0371:
0372: if (list.size() == 0) {
0373: StringMaker msg = new StringMaker();
0374:
0375: msg.append("No OrgGroupPermission exists with the key {");
0376:
0377: msg.append("groupId=" + groupId);
0378:
0379: msg.append(StringPool.CLOSE_CURLY_BRACE);
0380:
0381: throw new NoSuchOrgGroupPermissionException(msg.toString());
0382: } else {
0383: return (OrgGroupPermission) list.get(0);
0384: }
0385: }
0386:
0387: public OrgGroupPermission findByGroupId_Last(long groupId,
0388: OrderByComparator obc)
0389: throws NoSuchOrgGroupPermissionException, SystemException {
0390: int count = countByGroupId(groupId);
0391:
0392: List list = findByGroupId(groupId, count - 1, count, obc);
0393:
0394: if (list.size() == 0) {
0395: StringMaker msg = new StringMaker();
0396:
0397: msg.append("No OrgGroupPermission exists with the key {");
0398:
0399: msg.append("groupId=" + groupId);
0400:
0401: msg.append(StringPool.CLOSE_CURLY_BRACE);
0402:
0403: throw new NoSuchOrgGroupPermissionException(msg.toString());
0404: } else {
0405: return (OrgGroupPermission) list.get(0);
0406: }
0407: }
0408:
0409: public OrgGroupPermission[] findByGroupId_PrevAndNext(
0410: OrgGroupPermissionPK orgGroupPermissionPK, long groupId,
0411: OrderByComparator obc)
0412: throws NoSuchOrgGroupPermissionException, SystemException {
0413: OrgGroupPermission orgGroupPermission = findByPrimaryKey(orgGroupPermissionPK);
0414:
0415: int count = countByGroupId(groupId);
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.OrgGroupPermission WHERE ");
0426:
0427: query.append("groupId = ?");
0428:
0429: query.append(" ");
0430:
0431: if (obc != null) {
0432: query.append("ORDER BY ");
0433: query.append(obc.getOrderBy());
0434: }
0435:
0436: Query q = session.createQuery(query.toString());
0437:
0438: int queryPos = 0;
0439:
0440: q.setLong(queryPos++, groupId);
0441:
0442: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0443: orgGroupPermission);
0444:
0445: OrgGroupPermission[] array = new OrgGroupPermissionImpl[3];
0446:
0447: array[0] = (OrgGroupPermission) objArray[0];
0448: array[1] = (OrgGroupPermission) objArray[1];
0449: array[2] = (OrgGroupPermission) objArray[2];
0450:
0451: return array;
0452: } catch (Exception e) {
0453: throw HibernateUtil.processException(e);
0454: } finally {
0455: closeSession(session);
0456: }
0457: }
0458:
0459: public List findByPermissionId(long permissionId)
0460: throws SystemException {
0461: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0462: String finderClassName = OrgGroupPermission.class.getName();
0463: String finderMethodName = "findByPermissionId";
0464: String[] finderParams = new String[] { Long.class.getName() };
0465: Object[] finderArgs = new Object[] { new Long(permissionId) };
0466:
0467: Object result = null;
0468:
0469: if (finderClassNameCacheEnabled) {
0470: result = FinderCache.getResult(finderClassName,
0471: finderMethodName, finderParams, finderArgs,
0472: getSessionFactory());
0473: }
0474:
0475: if (result == null) {
0476: Session session = null;
0477:
0478: try {
0479: session = openSession();
0480:
0481: StringMaker query = new StringMaker();
0482:
0483: query
0484: .append("FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
0485:
0486: query.append("permissionId = ?");
0487:
0488: query.append(" ");
0489:
0490: Query q = session.createQuery(query.toString());
0491:
0492: int queryPos = 0;
0493:
0494: q.setLong(queryPos++, permissionId);
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 findByPermissionId(long permissionId, int begin, int end)
0514: throws SystemException {
0515: return findByPermissionId(permissionId, begin, end, null);
0516: }
0517:
0518: public List findByPermissionId(long permissionId, int begin,
0519: int end, OrderByComparator obc) throws SystemException {
0520: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0521: String finderClassName = OrgGroupPermission.class.getName();
0522: String finderMethodName = "findByPermissionId";
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(permissionId),
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.OrgGroupPermission WHERE ");
0549:
0550: query.append("permissionId = ?");
0551:
0552: query.append(" ");
0553:
0554: if (obc != null) {
0555: query.append("ORDER BY ");
0556: query.append(obc.getOrderBy());
0557: }
0558:
0559: Query q = session.createQuery(query.toString());
0560:
0561: int queryPos = 0;
0562:
0563: q.setLong(queryPos++, permissionId);
0564:
0565: List list = QueryUtil.list(q, getDialect(), begin, end);
0566:
0567: FinderCache.putResult(finderClassNameCacheEnabled,
0568: finderClassName, finderMethodName,
0569: finderParams, finderArgs, list);
0570:
0571: return list;
0572: } catch (Exception e) {
0573: throw HibernateUtil.processException(e);
0574: } finally {
0575: closeSession(session);
0576: }
0577: } else {
0578: return (List) result;
0579: }
0580: }
0581:
0582: public OrgGroupPermission findByPermissionId_First(
0583: long permissionId, OrderByComparator obc)
0584: throws NoSuchOrgGroupPermissionException, SystemException {
0585: List list = findByPermissionId(permissionId, 0, 1, obc);
0586:
0587: if (list.size() == 0) {
0588: StringMaker msg = new StringMaker();
0589:
0590: msg.append("No OrgGroupPermission exists with the key {");
0591:
0592: msg.append("permissionId=" + permissionId);
0593:
0594: msg.append(StringPool.CLOSE_CURLY_BRACE);
0595:
0596: throw new NoSuchOrgGroupPermissionException(msg.toString());
0597: } else {
0598: return (OrgGroupPermission) list.get(0);
0599: }
0600: }
0601:
0602: public OrgGroupPermission findByPermissionId_Last(
0603: long permissionId, OrderByComparator obc)
0604: throws NoSuchOrgGroupPermissionException, SystemException {
0605: int count = countByPermissionId(permissionId);
0606:
0607: List list = findByPermissionId(permissionId, count - 1, count,
0608: obc);
0609:
0610: if (list.size() == 0) {
0611: StringMaker msg = new StringMaker();
0612:
0613: msg.append("No OrgGroupPermission exists with the key {");
0614:
0615: msg.append("permissionId=" + permissionId);
0616:
0617: msg.append(StringPool.CLOSE_CURLY_BRACE);
0618:
0619: throw new NoSuchOrgGroupPermissionException(msg.toString());
0620: } else {
0621: return (OrgGroupPermission) list.get(0);
0622: }
0623: }
0624:
0625: public OrgGroupPermission[] findByPermissionId_PrevAndNext(
0626: OrgGroupPermissionPK orgGroupPermissionPK,
0627: long permissionId, OrderByComparator obc)
0628: throws NoSuchOrgGroupPermissionException, SystemException {
0629: OrgGroupPermission orgGroupPermission = findByPrimaryKey(orgGroupPermissionPK);
0630:
0631: int count = countByPermissionId(permissionId);
0632:
0633: Session session = null;
0634:
0635: try {
0636: session = openSession();
0637:
0638: StringMaker query = new StringMaker();
0639:
0640: query
0641: .append("FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
0642:
0643: query.append("permissionId = ?");
0644:
0645: query.append(" ");
0646:
0647: if (obc != null) {
0648: query.append("ORDER BY ");
0649: query.append(obc.getOrderBy());
0650: }
0651:
0652: Query q = session.createQuery(query.toString());
0653:
0654: int queryPos = 0;
0655:
0656: q.setLong(queryPos++, permissionId);
0657:
0658: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0659: orgGroupPermission);
0660:
0661: OrgGroupPermission[] array = new OrgGroupPermissionImpl[3];
0662:
0663: array[0] = (OrgGroupPermission) objArray[0];
0664: array[1] = (OrgGroupPermission) objArray[1];
0665: array[2] = (OrgGroupPermission) objArray[2];
0666:
0667: return array;
0668: } catch (Exception e) {
0669: throw HibernateUtil.processException(e);
0670: } finally {
0671: closeSession(session);
0672: }
0673: }
0674:
0675: public List findWithDynamicQuery(
0676: DynamicQueryInitializer queryInitializer)
0677: throws SystemException {
0678: Session session = null;
0679:
0680: try {
0681: session = openSession();
0682:
0683: DynamicQuery query = queryInitializer.initialize(session);
0684:
0685: return query.list();
0686: } catch (Exception e) {
0687: throw HibernateUtil.processException(e);
0688: } finally {
0689: closeSession(session);
0690: }
0691: }
0692:
0693: public List findWithDynamicQuery(
0694: DynamicQueryInitializer queryInitializer, int begin, int end)
0695: throws SystemException {
0696: Session session = null;
0697:
0698: try {
0699: session = openSession();
0700:
0701: DynamicQuery query = queryInitializer.initialize(session);
0702:
0703: query.setLimit(begin, end);
0704:
0705: return query.list();
0706: } catch (Exception e) {
0707: throw HibernateUtil.processException(e);
0708: } finally {
0709: closeSession(session);
0710: }
0711: }
0712:
0713: public List findAll() throws SystemException {
0714: return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
0715: }
0716:
0717: public List findAll(int begin, int end) throws SystemException {
0718: return findAll(begin, end, null);
0719: }
0720:
0721: public List findAll(int begin, int end, OrderByComparator obc)
0722: throws SystemException {
0723: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0724: String finderClassName = OrgGroupPermission.class.getName();
0725: String finderMethodName = "findAll";
0726: String[] finderParams = new String[] { "java.lang.Integer",
0727: "java.lang.Integer",
0728: "com.liferay.portal.kernel.util.OrderByComparator" };
0729: Object[] finderArgs = new Object[] { String.valueOf(begin),
0730: String.valueOf(end), String.valueOf(obc) };
0731:
0732: Object result = null;
0733:
0734: if (finderClassNameCacheEnabled) {
0735: result = FinderCache.getResult(finderClassName,
0736: finderMethodName, finderParams, finderArgs,
0737: getSessionFactory());
0738: }
0739:
0740: if (result == null) {
0741: Session session = null;
0742:
0743: try {
0744: session = openSession();
0745:
0746: StringMaker query = new StringMaker();
0747:
0748: query
0749: .append("FROM com.liferay.portal.model.OrgGroupPermission ");
0750:
0751: if (obc != null) {
0752: query.append("ORDER BY ");
0753: query.append(obc.getOrderBy());
0754: }
0755:
0756: Query q = session.createQuery(query.toString());
0757:
0758: List list = QueryUtil.list(q, getDialect(), begin, end);
0759:
0760: if (obc == null) {
0761: Collections.sort(list);
0762: }
0763:
0764: FinderCache.putResult(finderClassNameCacheEnabled,
0765: finderClassName, finderMethodName,
0766: finderParams, finderArgs, list);
0767:
0768: return list;
0769: } catch (Exception e) {
0770: throw HibernateUtil.processException(e);
0771: } finally {
0772: closeSession(session);
0773: }
0774: } else {
0775: return (List) result;
0776: }
0777: }
0778:
0779: public void removeByGroupId(long groupId) throws SystemException {
0780: Iterator itr = findByGroupId(groupId).iterator();
0781:
0782: while (itr.hasNext()) {
0783: OrgGroupPermission orgGroupPermission = (OrgGroupPermission) itr
0784: .next();
0785:
0786: remove(orgGroupPermission);
0787: }
0788: }
0789:
0790: public void removeByPermissionId(long permissionId)
0791: throws SystemException {
0792: Iterator itr = findByPermissionId(permissionId).iterator();
0793:
0794: while (itr.hasNext()) {
0795: OrgGroupPermission orgGroupPermission = (OrgGroupPermission) itr
0796: .next();
0797:
0798: remove(orgGroupPermission);
0799: }
0800: }
0801:
0802: public void removeAll() throws SystemException {
0803: Iterator itr = findAll().iterator();
0804:
0805: while (itr.hasNext()) {
0806: remove((OrgGroupPermission) itr.next());
0807: }
0808: }
0809:
0810: public int countByGroupId(long groupId) throws SystemException {
0811: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0812: String finderClassName = OrgGroupPermission.class.getName();
0813: String finderMethodName = "countByGroupId";
0814: String[] finderParams = new String[] { Long.class.getName() };
0815: Object[] finderArgs = new Object[] { new Long(groupId) };
0816:
0817: Object result = null;
0818:
0819: if (finderClassNameCacheEnabled) {
0820: result = FinderCache.getResult(finderClassName,
0821: finderMethodName, finderParams, finderArgs,
0822: getSessionFactory());
0823: }
0824:
0825: if (result == null) {
0826: Session session = null;
0827:
0828: try {
0829: session = openSession();
0830:
0831: StringMaker query = new StringMaker();
0832:
0833: query.append("SELECT COUNT(*) ");
0834: query
0835: .append("FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
0836:
0837: query.append("groupId = ?");
0838:
0839: query.append(" ");
0840:
0841: Query q = session.createQuery(query.toString());
0842:
0843: int queryPos = 0;
0844:
0845: q.setLong(queryPos++, groupId);
0846:
0847: Long count = null;
0848:
0849: Iterator itr = q.list().iterator();
0850:
0851: if (itr.hasNext()) {
0852: count = (Long) itr.next();
0853: }
0854:
0855: if (count == null) {
0856: count = new Long(0);
0857: }
0858:
0859: FinderCache.putResult(finderClassNameCacheEnabled,
0860: finderClassName, finderMethodName,
0861: finderParams, finderArgs, count);
0862:
0863: return count.intValue();
0864: } catch (Exception e) {
0865: throw HibernateUtil.processException(e);
0866: } finally {
0867: closeSession(session);
0868: }
0869: } else {
0870: return ((Long) result).intValue();
0871: }
0872: }
0873:
0874: public int countByPermissionId(long permissionId)
0875: throws SystemException {
0876: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0877: String finderClassName = OrgGroupPermission.class.getName();
0878: String finderMethodName = "countByPermissionId";
0879: String[] finderParams = new String[] { Long.class.getName() };
0880: Object[] finderArgs = new Object[] { new Long(permissionId) };
0881:
0882: Object result = null;
0883:
0884: if (finderClassNameCacheEnabled) {
0885: result = FinderCache.getResult(finderClassName,
0886: finderMethodName, finderParams, finderArgs,
0887: getSessionFactory());
0888: }
0889:
0890: if (result == null) {
0891: Session session = null;
0892:
0893: try {
0894: session = openSession();
0895:
0896: StringMaker query = new StringMaker();
0897:
0898: query.append("SELECT COUNT(*) ");
0899: query
0900: .append("FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
0901:
0902: query.append("permissionId = ?");
0903:
0904: query.append(" ");
0905:
0906: Query q = session.createQuery(query.toString());
0907:
0908: int queryPos = 0;
0909:
0910: q.setLong(queryPos++, permissionId);
0911:
0912: Long count = null;
0913:
0914: Iterator itr = q.list().iterator();
0915:
0916: if (itr.hasNext()) {
0917: count = (Long) itr.next();
0918: }
0919:
0920: if (count == null) {
0921: count = new Long(0);
0922: }
0923:
0924: FinderCache.putResult(finderClassNameCacheEnabled,
0925: finderClassName, finderMethodName,
0926: finderParams, finderArgs, count);
0927:
0928: return count.intValue();
0929: } catch (Exception e) {
0930: throw HibernateUtil.processException(e);
0931: } finally {
0932: closeSession(session);
0933: }
0934: } else {
0935: return ((Long) result).intValue();
0936: }
0937: }
0938:
0939: public int countAll() throws SystemException {
0940: boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
0941: String finderClassName = OrgGroupPermission.class.getName();
0942: String finderMethodName = "countAll";
0943: String[] finderParams = new String[] {};
0944: Object[] finderArgs = new Object[] {};
0945:
0946: Object result = null;
0947:
0948: if (finderClassNameCacheEnabled) {
0949: result = FinderCache.getResult(finderClassName,
0950: finderMethodName, finderParams, finderArgs,
0951: getSessionFactory());
0952: }
0953:
0954: if (result == null) {
0955: Session session = null;
0956:
0957: try {
0958: session = openSession();
0959:
0960: Query q = session
0961: .createQuery("SELECT COUNT(*) FROM com.liferay.portal.model.OrgGroupPermission");
0962:
0963: Long count = null;
0964:
0965: Iterator itr = q.list().iterator();
0966:
0967: if (itr.hasNext()) {
0968: count = (Long) itr.next();
0969: }
0970:
0971: if (count == null) {
0972: count = new Long(0);
0973: }
0974:
0975: FinderCache.putResult(finderClassNameCacheEnabled,
0976: finderClassName, finderMethodName,
0977: finderParams, finderArgs, count);
0978:
0979: return count.intValue();
0980: } catch (Exception e) {
0981: throw HibernateUtil.processException(e);
0982: } finally {
0983: closeSession(session);
0984: }
0985: } else {
0986: return ((Long) result).intValue();
0987: }
0988: }
0989:
0990: protected void initDao() {
0991: }
0992:
0993: private static ModelListener _getListener() {
0994: if (Validator.isNotNull(_LISTENER)) {
0995: try {
0996: return (ModelListener) Class.forName(_LISTENER)
0997: .newInstance();
0998: } catch (Exception e) {
0999: _log.error(e);
1000: }
1001: }
1002:
1003: return null;
1004: }
1005:
1006: private static final String _LISTENER = GetterUtil
1007: .getString(PropsUtil
1008: .get("value.object.listener.com.liferay.portal.model.OrgGroupPermission"));
1009: private static Log _log = LogFactory
1010: .getLog(OrgGroupPermissionPersistenceImpl.class);
1011: }
|