List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftProductReadDelegate.java
/** * @return// ww w . j a va 2 s .c o m * @throws NamingException * @throws HibernateException */ public static List getMicrosoftProducts() throws HibernateException, NamingException { List microsoftProducts = null; Session session = getHibernateSession(); microsoftProducts = session.getNamedQuery("getMicrosoftProducts").list(); return microsoftProducts; }
From source file:com.ibm.tap.misld.delegate.microsoftPriceList.MicrosoftProductReadDelegate.java
/** * @param microsoftProductId/*from w w w. j a v a 2 s.com*/ * @return * @throws NamingException * @throws HibernateException */ public static MicrosoftProduct getFullMicrosoftProduct(Long microsoftProductId) throws HibernateException, NamingException { Session session = getHibernateSession(); MicrosoftProduct microsoftProduct = (MicrosoftProduct) session.getNamedQuery("getMicrosoftProductByLong") .setLong("microsoftProductId", microsoftProductId.longValue()).uniqueResult(); session.close(); return microsoftProduct; }
From source file:com.ibm.tap.misld.delegate.purchaseOrderReport.PurchaseOrderReportReadDelegate.java
/** * @param remoteUser//from w w w . j av a 2 s. c o m * @return * @throws HibernateException * @throws NamingException */ public static List getPoReport(String licenseAgreementTypeName, String remoteUser) throws HibernateException, NamingException { List poReport = null; Session session = getHibernateSession(); poReport = session.getNamedQuery("getPurchaseOrderReport") .setString("licenseAgreementTypeName", licenseAgreementTypeName).list(); Vector poReportVector = new Vector(); if (poReport != null) { Iterator j = poReport.iterator(); while (j.hasNext()) { PurchaseOrderReport purchaseOrderReport = (PurchaseOrderReport) j.next(); Vector tempList = new Vector(); tempList.add(purchaseOrderReport.getCustomer().getPod().getPodName()); tempList.add(purchaseOrderReport.getCustomer().getIndustry().getIndustryName()); tempList.add(purchaseOrderReport.getCustomer().getSector().getSectorName()); tempList.add(purchaseOrderReport.getCustomer().getCustomerType().getCustomerTypeName()); tempList.add(purchaseOrderReport.getCustomer().getMisldAccountSettings().getLicenseAgreementType() .getLicenseAgreementTypeName()); tempList.add(new String("" + purchaseOrderReport.getCustomer().getAccountNumber())); tempList.add(purchaseOrderReport.getCustomer().getCustomerName()); tempList.add(new String("" + purchaseOrderReport.getTotalPrice())); List poList = null; poList = session.getNamedQuery("getCustomerPoNumbers") .setEntity("customer", purchaseOrderReport.getCustomer()).list(); Iterator k = poList.iterator(); while (k.hasNext()) { tempList.add((String) k.next()); } poReportVector.add(tempList); } } session.close(); return poReportVector; }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
/** * @param customer//from w ww . j a v a 2 s . c o m * @param remoteUser * @return * @throws NamingException * @throws HibernateException */ public static List getSPLAAccountReport(String remoteUser) throws HibernateException, NamingException { List priceReports = null; Session session = getHibernateSession(); priceReports = session.getNamedQuery("getActiveSPLA").list(); session.close(); return priceReports; }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
/** * @param customer//from w ww .j a va 2 s . c o m * @param remoteUser * @return * @throws NamingException * @throws HibernateException */ public static List getEmailSPLAAccountReport(String remoteUser) throws HibernateException, NamingException { List priceReports = null; PriceReportArchive priceReportArchive = new PriceReportArchive(); Session session = getHibernateSession(); priceReports = session.getNamedQuery("getActiveSPLA").list(); session.close(); ListIterator priceReportIterator = priceReports.listIterator(); Vector reportVector = new Vector(); while (priceReportIterator.hasNext()) { priceReportArchive = (PriceReportArchive) priceReportIterator.next(); Vector rowVector = new Vector(); rowVector.add(priceReportArchive.getPod()); rowVector.add(priceReportArchive.getAccountNumber().toString()); rowVector.add(priceReportArchive.getCustomerName()); rowVector.add(priceReportArchive.getCustomerType()); rowVector.add(priceReportArchive.getNodeName()); rowVector.add(priceReportArchive.getProductDescription()); reportVector.add(rowVector); } return reportVector; }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
/** * @param customer/* ww w.j a v a2s . com*/ * @param remoteUser * @return * @throws NamingException * @throws HibernateException */ public static List getEmailPriceReportApprovalStatus(String remoteUser) throws HibernateException, NamingException { List customers = null; Customer customer = new Customer(); MisldAccountSettings misldAccountSettings = new MisldAccountSettings(); Session session = getHibernateSession(); customers = session.getNamedQuery("getApprovedPriceReports").list(); session.close(); ListIterator customerIterator = customers.listIterator(); Vector reportVector = new Vector(); while (customerIterator.hasNext()) { customer = (Customer) customerIterator.next(); misldAccountSettings = customer.getMisldAccountSettings(); Vector rowVector = new Vector(); rowVector.add(customer.getPod().getPodName()); rowVector.add(customer.getCustomerName()); rowVector.add(customer.getAccountNumber().toString()); rowVector.add(customer.getContactDPE().getFullName()); rowVector.add(misldAccountSettings.getPriceReportTimestamp().toString()); rowVector.add(misldAccountSettings.getPriceReportStatusUser()); reportVector.add(rowVector); } return reportVector; }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
/** * @param customer/* w w w .ja v a 2 s . co m*/ * @return * @throws NamingException * @throws HibernateException */ public static PriceReportCycle getActivePriceReportCycle(Customer customer) throws HibernateException, NamingException { PriceReportCycle priceReportCycle = null; Session session = getHibernateSession(); priceReportCycle = (PriceReportCycle) session.getNamedQuery("getActivePriceReportCycle") .setEntity("customer", customer).uniqueResult(); session.close(); return priceReportCycle; }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
public static HashMap createSplaMoetReport(String usageDate) throws HibernateException, NamingException { Date usageDateAsDate = Util.parseDayString(usageDate); Calendar calendar = Calendar.getInstance(); calendar.setTime(usageDateAsDate);// w w w .jav a 2s. co m HashMap poHash = new HashMap(); Session session = getHibernateSession(); List moetList = session.getNamedQuery("moetQuery").setDate("usageDate", usageDateAsDate).list(); session.close(); if (moetList != null) { Iterator j = moetList.iterator(); while (j.hasNext()) { Vector tempVector = new Vector(); int countInt = 0; Object[] pair = (Object[]) j.next(); String poNumber = (String) pair[0]; String sku = (String) pair[1]; String licenseType = (String) pair[2]; String country = (String) pair[3]; Long procCount = (Long) pair[4]; Integer processorCount = (Integer) procCount.intValue(); Long usrCount = (Long) pair[5]; Integer userCount = (Integer) usrCount.intValue(); Integer count; if (licenseType.equals(Constants.PROCESSOR_BASED_LICENSE)) { count = processorCount; } else { count = userCount; } countInt = count.intValue() * 3; count = new Integer(countInt); tempVector.add(""); tempVector.add(sku); tempVector.add("" + count); tempVector.add(""); tempVector.add("STD"); tempVector.add(country); tempVector.add(""); if (poHash.get(poNumber) == null) { Moet moet = new Moet(); moet.setAgreementNumber("5585168"); moet.setPoNumber(poNumber); moet.setPoType("NE"); String month = ""; if ((calendar.get(Calendar.MONTH) + 1) < 10) { month = "0" + (calendar.get(Calendar.MONTH) + 1); } else { month = "" + (calendar.get(Calendar.MONTH) + 1); } moet.setUsageDate( "" + calendar.get(Calendar.YEAR) + month + calendar.get(Calendar.DAY_OF_MONTH)); Vector productVector = moet.getProductVector(); productVector.add(tempVector); moet.setProductVector(productVector); poHash.put(poNumber, moet); } else { Moet moet = (Moet) poHash.get(poNumber); Vector productVector = moet.getProductVector(); productVector.add(tempVector); moet.setProductVector(productVector); poHash.put(poNumber, moet); } } } return poHash; }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
/** * @return/* w ww . ja v a2 s . c o m*/ * @throws HibernateException * @throws NamingException */ public static List getDistinctUsageDates() throws HibernateException, NamingException { List usageDateList = null; Vector dateList = new Vector(); Session session = getHibernateSession(); usageDateList = session.getNamedQuery("getDistinctUsageDates").list(); session.close(); if (usageDateList != null) { Iterator j = usageDateList.iterator(); while (j.hasNext()) { Date usageDate = (Date) j.next(); dateList.add(usageDate); } } return dateList; }
From source file:com.ibm.tap.misld.report.PriceReportDelegate.java
/** * @return//from w w w .ja v a 2 s . co m * @throws HibernateException * @throws NamingException */ public static Vector getAcceptMoetDates() throws HibernateException, NamingException { List usageDateList = null; Vector dateList = new Vector(); Session session = getHibernateSession(); usageDateList = session.getNamedQuery("getAcceptMoetDates").list(); session.close(); if (usageDateList != null) { Iterator j = usageDateList.iterator(); while (j.hasNext()) { Date usageDate = (Date) j.next(); dateList.add(usageDate); } } return dateList; }