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