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

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


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