@Override public List<Reservation> getReservListByThisDate(String today) { List<Reservation> reservationsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation where checkinDate=:today", Reservation.class); query.setParameter("today", today); reservationsList = query.getResultList(); logging.setMessage("ReservationDaoImpl -> fetching all reservations by date..."); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("No reservation found!"); frame.setVisible(true); } finally { session.close(); } return reservationsList; }
public static void main(String[] args) { Configuration cfg=null; SessionFactory factory=null; Session ses=null; Transaction tx=null; cfg=new Configuration().configure("com/app/cfgs/hibernate.cfg.xml"); factory=cfg.buildSessionFactory(); ses=factory.openSession(); tx=ses.beginTransaction(); String hql="delete from bigbazarModel where bazarid=:id"; Query q=ses.createQuery(hql); q.setParameter("id", 1003); int c=q.executeUpdate(); //int count=Integer.parseUnsignedInt(c); tx.commit(); System.out.println("\t\t"+c+" rows Deleted"); factory.close(); }
public static void main(String[] args) { Configuration cfg=null; SessionFactory factory=null; Session ses=null; Transaction tx=null; cfg=new Configuration().configure("com/app/cfgs/hibernate.cfg.xml"); factory=cfg.buildSessionFactory(); ses=factory.openSession(); String hql="select item_name from bigbazarModel where bazarid=:id"; Query q=ses.createQuery(hql); q.setParameter("id", 1001); String s=(String) q.uniqueResult(); System.out.println("\t\t"+s); factory.close(); }
public static void main(String[] args) { Configuration cfg=null; SessionFactory factory=null; Session ses=null; Transaction tx=null; cfg=new Configuration().configure("com/app/cfgs/hibernate.cfg.xml"); factory=cfg.buildSessionFactory(); ses=factory.openSession(); tx=ses.beginTransaction(); String hql="insert into newMall(mallid,item_name,item_price,item_quantity) " + "select bazarid,item_name,item_price,item_quantity from bigbazarModel "; Query q=ses.createQuery(hql); int c=q.executeUpdate(); //int count=Integer.parseUnsignedInt(c); tx.commit(); System.out.println("\t\t"+c+" rows Copied Successfully..."); factory.close(); }
@Override public Reservation findReservationById(long theId) { Reservation theReservation = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation where id=:theId", Reservation.class); query.setParameter("theId", theId); query.setMaxResults(1); theReservation = query.getSingleResult(); logging.setMessage("ReservationDaoImpl -> fetching reservation by Id..."); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("No reservation found!"); frame.setVisible(true); } finally { session.close(); } return theReservation; }
@Override public Reservation findSingleReservByThisDate(String Date) { Reservation theReservation = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation where checkinDate=:Date", Reservation.class); query.setParameter("Date", Date); theReservation = query.getSingleResult(); logging.setMessage("ReservationDaoImpl -> fetching reservation by date..."); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("There is no reservation at this date!"); frame.setVisible(true); } finally { session.close(); } return theReservation; }
@Override public List<Reservation> getAllReservations() { List<Reservation> reservationsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation", Reservation.class); reservationsList = query.getResultList(); logging.setMessage("ReservationDaoImpl -> fetching all reservations..."); } catch (NoResultException e) { logging.setMessage("ReservationDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return reservationsList; }
public List<Reservation> getGaranteedReservs(String reservDate) { List<Reservation> reservationsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation " + "where bookStatus = 'GUARANTEE' and checkinDate=:today", Reservation.class); query.setParameter("today", reservDate); reservationsList = query.getResultList(); logging.setMessage("ReservationDaoImpl -> fetching all garanteed reservations..."); } catch (NoResultException e) { logging.setMessage("ReservationDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return reservationsList; }
@Override public List<Reservation> getReservsAsWaitlist(String reservDate) { List<Reservation> reservationsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation " + "where bookStatus = 'WAITLIST' and checkinDate=:today", Reservation.class); query.setParameter("today", reservDate); reservationsList = query.getResultList(); logging.setMessage("ReservationDaoImpl -> fetching all waiting reservations..."); } catch (NoResultException e) { logging.setMessage("ReservationDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return reservationsList; }
@Override public Reservation getLastReservation() { Reservation lastReservation = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation order by Id DESC", Reservation.class); query.setMaxResults(1); lastReservation = query.getSingleResult(); logging.setMessage("ReservationDaoImpl -> fetching last reservation..."); } catch (NoResultException e) { logging.setMessage("ReservationDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return lastReservation; }
@Override public Reservation findReservationByAgencyRefNo(String agencyRefNo) { Reservation reservationByRef = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation where agencyRefNo=:agencyRefNo", Reservation.class); query.setParameter("agencyRefNo", agencyRefNo); query.setMaxResults(1); reservationByRef = query.getSingleResult(); logging.setMessage("ReservationDaoImpl -> fetching reservation by agency referance number..."); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("There is no reservation with this agency referance number!"); frame.setVisible(true); } finally { session.close(); } return reservationByRef; }
@Override public Reservation findReservationByRefNo(String refNo) { Reservation reservationByRef = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation where referanceNo=:refNo", Reservation.class); query.setParameter("refNo", refNo); query.setMaxResults(1); reservationByRef = query.getSingleResult(); logging.setMessage("ReservationDaoImpl -> fetching reservation by referance number..."); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("There is no reservation with this referance number!"); frame.setVisible(true); } finally { session.close(); } return reservationByRef; }
public List<Reservation> getReservationBetweenTwoDates(String checkinDate, String checkoutDate) { List<Reservation> reservationsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Reservation> query = session.createQuery("from Reservation AS r WHERE r.checkinDate BETWEEN :checkinDate AND :checkoutDate", Reservation.class); query.setParameter("checkinDate", checkinDate); query.setParameter("checkoutDate", checkoutDate); reservationsList = query.getResultList(); if(reservationsList == null) reservationsList = session.createQuery("from Reservation", Reservation.class).getResultList(); logging.setMessage("ReservationDaoImpl -> fetching reservation that between two dates..."); } catch (NoResultException e) { logging.setMessage("ReservationDaoImpl Error -> " + e.getLocalizedMessage()); } return reservationsList; }
@Override public HotelSystemStatus getSystemStatus() { HotelSystemStatus systemStatus = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<HotelSystemStatus> query = session.createQuery("from HotelSystemStatus where id=1", HotelSystemStatus.class); systemStatus = query.getSingleResult(); logging.setMessage("HotelSystemStatusImpl -> fetching system status..."); } catch (NoResultException e) { logging.setMessage("HotelSystemStatusImpl Error -> "+e.getLocalizedMessage()); } finally { session.close(); } return systemStatus; }
@Override public boolean deletePosting(long theId) { try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<?> query = session.createQuery("delete Posting where id = :theId"); query.setParameter("theId", theId); query.executeUpdate(); logging.setMessage("PostingDaoImpl -> posting deleted successfully."); return true; } catch (HibernateException e) { session.getTransaction().rollback(); logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return false; }
@Override public List<Posting> getAllPostingsByRoomNumber(String theRoomNumber, String string) { List<Posting> postingsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Posting> query = session.createQuery("from Posting where" + " roomNumber = :theRoomNumber and dateTime >= :localDate", Posting.class); query.setParameter("theRoomNumber", theRoomNumber); query.setParameter("localDate", string); postingsList = query.getResultList(); logging.setMessage("PostingDaoImpl -> fetching all postings by room number..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return postingsList; }
public List<Posting> getAllPostingsForToday(String today) { List<Posting> postingsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Posting> query = session.createQuery("from Posting where dateTime >= :today", Posting.class); query.setParameter("today", today); postingsList = query.getResultList(); logging.setMessage("PostingDaoImpl -> fetching all postings for today..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return postingsList; }
@Override public String getTotalCashLiraPostingsForOneDay(String today) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Posting where currency = 'TURKISH LIRA' and dateTime >= :today", String.class); query.setParameter("today", today); totalCash = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total cash lira posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCashDollarPostingsForOneDay(String today) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery( "select sum(price) from Posting where currency = 'DOLLAR' and dateTime >= :today", String.class); query.setParameter("today", today); totalCash = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total cash dollar posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCashEuroPostingsForOneDay(String today) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Posting where currency = 'EURO' and dateTime >= :today", String.class); query.setParameter("today", today); totalCash = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total cash dollar posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCashPoundPostingsForOneDay(String today) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery( "select sum(price) from Posting where currency = 'POUND' and dateTime >= :today", String.class); query.setParameter("today", today); totalCash = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total cash dollar posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCreditLiraPostingsForOneDay(String date) { String totalCredit = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Posting where " + "currency = 'CREDIT CARD' and currency = 'TURKISH LIRA' and dateTime >= :date", String.class); query.setParameter("date", date); totalCredit = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total credit card lira posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCredit; }
@Override public String getTotalCreditDollarPostingsForOneDay(String date) { String totalCredit = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Posting where " + "currency = 'CREDIT CARD' and currency = 'DOLLAR' and dateTime >= :date", String.class); query.setParameter("date", date); totalCredit = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total credit card dollar posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCredit; }
@Override public String getTotalCreditEuroPostingsForOneDay(String date) { String totalCredit = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Posting where " + "currency = 'CREDIT CARD' and currency = 'EURO' and dateTime >= :date", String.class); query.setParameter("date", date); totalCredit = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total credit card euro posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCredit; }
@Override public String getTotalCreditPoundPostingsForOneDay(String date) { String totalCredit = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Posting where " + "currency = 'CREDIT CARD' and currency = 'POUND' and dateTime >= :date", String.class); query.setParameter("date", date); totalCredit = query.getSingleResult(); logging.setMessage("PostingDaoImpl -> fetching total credit card pound posting for one day..."); } catch (NoResultException e) { logging.setMessage("PostingDaoImpl Error -> " + e.getLocalizedMessage()); } finally { session.close(); } return totalCredit; }
@Override public Customer findCustomerByName(String name, String lastName) { Customer customer = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Customer> query = session.createQuery("from Customer where FirstName=:name and LastName=:lastName", Customer.class); query.setParameter("name", name); query.setParameter("lastName", lastName); query.setMaxResults(1); customer = query.getSingleResult(); logging.setMessage("CustomerDaoImpl -> fetching customer with name :" + name); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("Customers not found! :" +e.getLocalizedMessage()); frame.setVisible(true); } finally { session.close(); } return customer; }
@Override public List<Customer> getAllCustomers() { List<Customer> customerList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Customer> query = session.createQuery("from Customer", Customer.class); customerList = query.getResultList(); logging.setMessage("CustomerDaoImpl -> fetching all customers"); } catch (NoResultException e) { logging.setMessage("CustomerDaoImpl NoResultException -> :"+e.getLocalizedMessage()); } finally { session.close(); } return customerList; }
public List<Customer> getCustomerByReservId(long id) { List<Customer> customersList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Customer> query = session.createQuery("from Customer where ReservationId=:id", Customer.class); query.setParameter("id", id); customersList = query.getResultList(); logging.setMessage("CustomerDaoImpl -> customer updated successfully : "+customersList.toString()); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("Customers not found!"); frame.setVisible(true); } finally { session.close(); } return customersList; }
@Override @SuppressWarnings("rawtypes") public void deleteCustomerByReservationId(long id) { try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query query = session.createQuery("delete from Customers where ReservationId=:id"); query.setParameter("id", id); session.getTransaction().commit(); logging.setMessage("CustomerDaoImpl -> customer deleted successfully"); } catch (HibernateException e) { session.getTransaction().rollback(); logging.setMessage("CustomerDaoImpl -> delete customer error -> "+e.getLocalizedMessage()); } finally { session.close(); } }
@Override public Customer getSinlgeCustomerByReservId(long id, String name) { Customer theCustomer = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Customer> query = session.createQuery("from Customer where ReservationId=:theId and FirstName=:name", Customer.class); query.setParameter("theId", id); query.setParameter("name", name); query.setMaxResults(1); theCustomer = query.getSingleResult(); logging.setMessage("CustomerDaoImpl -> fetched customer successfully :"+theCustomer.toString()); } catch (NoResultException e) { final InformationFrame frame = new InformationFrame(); frame.setMessage("Customers not found!"); frame.setVisible(true); } finally { session.close(); } return theCustomer; }
@Override public Company getCompanyByName(String companyName) { Company company = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Company> query = session.createQuery("from Company where title = :companyName", Company.class); query.setParameter("companyName", companyName); query.setMaxResults(1); company = query.getSingleResult(); logging.setMessage("CompanyDaoImpl -> fetching by name :" + companyName); } catch (NoResultException ex) { logging.setMessage("CompanyDaoImpl Error -> "+ex.getLocalizedMessage()); } finally { if(session.isOpen()){session.close();} } return company; }
@Override public List<Company> getAllCompanies() { List<Company> companiesList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Company> query = session.createQuery("from Company", Company.class); companiesList = query.getResultList(); logging.setMessage("CompanyDaoImpl -> fetching all companies..."); } catch (HibernateException ex) { logging.setMessage("CompanyDaoImpl Error -> "+ex.getLocalizedMessage()); } finally { if(session.isOpen()){session.close();} } return companiesList; }
@Override public void deleteByName(String selectedCompanyName) { try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Company> query = session.createQuery("from Company where title = :companyName", Company.class); query.setParameter("companyName", selectedCompanyName); query.setMaxResults(1); session.delete(query.getSingleResult()); session.getTransaction().commit(); logging.setMessage("CompanyDaoImpl -> deleting company..."); } catch (HibernateException ex) { session.getTransaction().rollback(); logging.setMessage("CompanyDaoImpl Error -> "+ex.getLocalizedMessage()); } finally { if(session.isOpen()){session.close();} } }
@Override public Hotel getHotel() { Hotel hotel = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Hotel> query = session.createQuery("from Hotel", Hotel.class); hotel = query.getSingleResult(); } catch (NoResultException e) { e.getLocalizedMessage(); } finally { session.close(); } return hotel; }
@Override public List<Payment> getAllPaymentsByRoomNumber(String theRoomNumber, String string) { List<Payment> paymentsList = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<Payment> query = session.createQuery("from Payment where " + "roomNumber = :theRoomNumber and dateTime >= :localDate", Payment.class); query.setParameter("theRoomNumber", theRoomNumber); query.setParameter("localDate", string); paymentsList = query.getResultList(); logging.setMessage("PaymentDaoImpl -> fetching all payments..."); } catch (NoResultException e) { logging.setMessage("PaymentDaoImpl Error ->" + e.getLocalizedMessage()); } finally { session.close(); } return paymentsList; }
@Override public String getTotalCashDollarForOneDay(String date) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Payment where " + "paymentType = 'CASH PAYMENT' and currency = 'DOLLAR' and dateTime >= :date", String.class); query.setParameter("date", date); totalCash = query.getSingleResult(); logging.setMessage("PaymentDaoImpl -> fetching total cash dollar for one day..."); } catch (NoResultException e) { logging.setMessage("PaymentDaoImpl Error ->" + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCashLiraPaymentsForOneDay(String date) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Payment where " + "paymentType = 'CASH PAYMENT' and currency = 'TURKISH LIRA' and dateTime >= :date", String.class); query.setParameter("date", date); totalCash = query.getSingleResult(); logging.setMessage("PaymentDaoImpl -> fetching total cash lira for one day..."); } catch (NoResultException e) { logging.setMessage("PaymentDaoImpl Error ->" + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCashEuroPaymentsForOneDay(String date) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Payment where " + "paymentType = 'CASH PAYMENT' and currency = 'EURO' and dateTime >= :date", String.class); query.setParameter("date", date); totalCash = query.getSingleResult(); logging.setMessage("PaymentDaoImpl -> fetching total cash euro for one day..."); } catch (NoResultException e) { logging.setMessage("PaymentDaoImpl Error ->" + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCashPoundPaymentsForOneDay(String date) { String totalCash = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery("select sum(price) from Payment where " + " paymentType = 'CASH PAYMENT' and currency = 'POUND' and dateTime >= :date", String.class); query.setParameter("date", date); totalCash = query.getSingleResult(); logging.setMessage("PaymentDaoImpl -> fetching total cash pound for one day..."); } catch (NoResultException e) { logging.setMessage("PaymentDaoImpl Error ->" + e.getLocalizedMessage()); } finally { session.close(); } return totalCash; }
@Override public String getTotalCreditLiraPaymentsForOneDay(String date) { String totalCredit = null; try { session = dataSourceFactory.getSessionFactory().openSession(); beginTransactionIfAllowed(session); Query<String> query = session.createQuery( "select sum(price) from Payment where " + "paymentType = 'CREDIT CARD' and currency = 'TURKISH LIRA' and dateTime >= :date", String.class); query.setParameter("date", date); totalCredit = query.getSingleResult(); logging.setMessage("PaymentDaoImpl -> fetching total credit pound for one day..."); } catch (NoResultException e) { logging.setMessage("PaymentDaoImpl Error ->" + e.getLocalizedMessage()); } finally { session.close(); } return totalCredit; }