Source Code Cross Referenced for TagsPropertyPersistenceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portlet » tags » service » persistence » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » com.liferay.portlet.tags.service.persistence 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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