List of usage examples for org.hibernate Session createQuery
@Override org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
From source file:bikerent.AddDeleteEntity.java
private static int countItem(Session session) { List<Item> iList = session.createQuery("from Item").list(); return iList.size(); }
From source file:bikerent.AddOrder.java
public static void main(String[] args) { String[] bike = new String[] {}; String[] helmet = new String[] {}; String[] trailer = new String[] {}; String[] chainlock = new String[] {}; String temp = ""; int cnt = 0;// w w w . ja v a2 s . c o m // Configure the session factory configureSessionFactory(); Session session = null; Transaction tx = null; try { session = sessionFactory.openSession(); tx = session.beginTransaction(); // Fetching saved data List<Bike> bikeList = session.createQuery("from Bike").list(); for (Bike b : bikeList) { temp = ""; temp = b.getModel() + "\t" + b.getBrand(); bike[cnt] = temp; } System.out.println(" --------------------- " + bikeList.size()); } catch (Exception ex) { ex.printStackTrace(); // Rolling back the changes to make the data consistent in case of any failure // in between multiple database write operations. tx.rollback(); } finally { if (session != null) { session.close(); } } Order frame = new Order(bike, helmet, trailer, chainlock); }
From source file:bikerent.BikeRent.java
public static void main(String[] args) { // Configure the session factory configureSessionFactory();// www . ja v a 2s . c o m Session session = null; Transaction tx = null; try { session = sessionFactory.openSession(); tx = session.beginTransaction(); // Creating Contact entity that will be save to the sqlite database Address myAddress = new Address(); // Saving to the database session.save(myAddress); // Committing the change in the database. session.flush(); tx.commit(); // Fetching saved data List<Address> userList = session.createQuery("from Address").list(); for (Address add : userList) { System.out.println("Id: " + add.getId()); } } catch (Exception ex) { ex.printStackTrace(); // Rolling back the changes to make the data consistent in case of any failure // in between multiple database write operations. tx.rollback(); } finally { if (session != null) { session.close(); } } }
From source file:biomart.DAO.AdminDAO.java
public String removeProductDetails(String productName) { Session session = Util.getSessionFactory().openSession(); Query query = session.createQuery("delete from ProductBean where Product_name=:pn"); query.setParameter("pn", productName); session.close();// w w w .ja v a 2s. c o m return "success"; }
From source file:biomart.DAO.AdminDAO.java
public List<CheckBean> checkDetails() { Session session = Util.getSessionFactory().openSession(); Query query = session.createQuery("From CheckBean"); List<CheckBean> checkBeans = query.list(); session.close();//ww w .ja va 2 s. c o m return checkBeans; }
From source file:biomart.DAO.AdminDAO.java
public List<PaymentDetailsBean> paymentDetails() { Session session = Util.getSessionFactory().openSession(); Query query = session.createQuery("From PaymentDetailsBean"); List<PaymentDetailsBean> paymentDetailsBeans = query.list(); session.close();/*ww w .j a va2 s . co m*/ return paymentDetailsBeans; }
From source file:biomart.DAO.AdminDAO.java
public List<ProductBean> getAllProdudctNames() { Session session = Util.getSessionFactory().openSession(); Query query = session.createQuery("From ProductBean"); List<ProductBean> productBeans = query.list(); session.close();//w ww .j a va 2 s . co m return productBeans; }
From source file:bo.gaceta.rcb.dao.impl.TbInCiiuImpl.java
public List<TbInCiiu> list() throws Exception { Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();/*from w w w. j a va 2 s . c o m*/ session.flush(); Query query = session.createQuery("SELECT e FROM TbInCiiu e"); List<TbInCiiu> entities = query.list(); session.getTransaction().commit(); session.close(); return entities; }
From source file:bo.gaceta.rcb.dao.impl.TbInCiiuImpl.java
public List<TbInCiiu> listFiltroClase(String txtClase) throws Exception { Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();/*from www . j av a 2s.co m*/ session.flush(); Query query = session.createQuery("SELECT e FROM TbInCiiu e WHERE e.clase LIKE :_txtBusca") .setParameter("_txtBusca", "%" + txtClase + "%"); List<TbInCiiu> entities = query.list(); session.getTransaction().commit(); session.close(); return entities; }
From source file:bo.gaceta.rcb.dao.impl.TbInCiiuImpl.java
public List<TbInCiiu> listSeccion() throws Exception { Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();/*from w w w . ja va 2 s. com*/ session.flush(); Query query = session.createQuery("SELECT e FROM TbInCiiu e GROUP BY e.idSeccion"); List<TbInCiiu> entities = query.list(); session.getTransaction().commit(); session.close(); return entities; }