List of usage examples for org.hibernate SQLQuery addEntity
SQLQuery<T> addEntity(Class entityType);
From source file:daos.AdresTypeDao.java
@Override public List<AdresType> readByKlantId(Integer id) { String query = "select a.* from klant_has_adres ka inner join adres_type a on a.idAdres_type = ka.Adres_type_idAdres_type where ka.Klant_idKlant = " + id;/* w w w . j a v a2 s .c om*/ Session session = getCurrentSession(); SQLQuery q = session.createSQLQuery(query); q.addEntity(AdresType.class); List<AdresType> results = (List<AdresType>) q.list(); return results; }
From source file:daos.BestellingHasArtikelDao.java
@Override public List<BestellingHasArtikel> readAll() { String query = "select * from bestelling_has_artikel"; Session session = getCurrentSession(); SQLQuery q = session.createSQLQuery(query); q.addEntity(BestellingHasArtikel.class); List<BestellingHasArtikel> results = (List<BestellingHasArtikel>) q.list(); return results; }
From source file:daos.BestellingHasArtikelDao.java
@Override public List<BestellingHasArtikel> readByKlantId(Integer id) { String query = "select ba.* from bestelling_has_artikel ba where ba.bestelling_idBestelling = " + id; Session session = getCurrentSession(); SQLQuery q = session.createSQLQuery(query); q.addEntity(BestellingHasArtikel.class); List<BestellingHasArtikel> results = (List<BestellingHasArtikel>) q.list(); return results; }
From source file:daos.BetaalwijzeDao.java
@Override public List<Betaalwijze> readAll() { String query = "select * from betaalwijze"; Session session = getCurrentSession(); SQLQuery q = session.createSQLQuery(query); q.addEntity(Betaalwijze.class); List<Betaalwijze> results = (List<Betaalwijze>) q.list(); return results; }
From source file:daos.BetalingDao.java
@Override public List<Betaling> readAll() { String query = "select * from betaling"; Session session = getCurrentSession(); SQLQuery q = session.createSQLQuery(query); q.addEntity(Betaling.class); List<Betaling> results = (List<Betaling>) q.list(); return results; }
From source file:daos.KlantDao.java
@Override public List<Klant> readAll() { String query = "select * from klant"; Session session = getCurrentSession(); SQLQuery q = session.createSQLQuery(query); q.addEntity(Klant.class); List<Klant> results = (List<Klant>) q.list(); return results; }
From source file:daos.LoginDao.java
public boolean checkLogin(Login login) { Session session = getCurrentSession(); String query = "select * from login l where l.inlognaam = '" + login.getInlognaam() + "'"; SQLQuery q = session.createSQLQuery(query); q.addEntity(Login.class); List<Login> result = (List<Login>) q.list(); return SCryptUtil.check(login.getInlogwachtwoord(), result.get(0).getInlogwachtwoord()); }
From source file:db.manage.FinanceManage.java
public FinanceEntity receiveFinanceByCaseID(String caseID) { FinanceEntity financeEntity = null;// ww w .j a v a 2 s . c o m Session session = sessionFactory.openSession(); Transaction tx = null; try { tx = session.beginTransaction(); String sql = "SELECT * FROM FINANCE WHERE CASE_ID = " + "'" + caseID + "'"; SQLQuery query = session.createSQLQuery(sql); query.addEntity(FinanceEntity.class); List finances = query.list(); if (finances.isEmpty()) { financeEntity = new FinanceEntity(); financeEntity.setCaseId(caseID); financeEntity.setNew1(1); financeEntity.setStateCurrent(0); financeEntity.setDatareceivedfromsales0string(""); financeEntity.setDatareceivedfromsales0checkbox(0); financeEntity.setDatareceivedfromsales0done(""); financeEntity.setCheckingavailablefinancing1y(""); financeEntity.setCheckingavailablefinancing1ca(""); financeEntity.setCheckingavailablefinancing1he(""); financeEntity.setCheckingavailablefinancing1che(0); financeEntity.setCheckingavailablefinancing1d(""); financeEntity.setEvaluatehp2button(""); financeEntity.setEvaluateHP2CheckBox(0); financeEntity.setEvaluatehp2done(""); financeEntity.setReceivingdraftagreement3string(""); financeEntity.setReceivingdraftagreement3ch(0); financeEntity.setReceivingdraftagreement3done(""); financeEntity.setGatheringdobssn4date(null); financeEntity.setGatheringdobssn4string(""); financeEntity.setGatheringdobssn4che(0); financeEntity.setGatheringdobssn4done(""); // financeEntity.setSigningeriageement5fileupload(financeBean.getSigningERIAgeement5FileUpload()); financeEntity.setSigningeriageement5string(""); financeEntity.setSigningeriageement5che(0); financeEntity.setSigningeriageement5done(""); financeEntity.setApplytofinancing6string(""); financeEntity.setApplytofinancing6checkbox(0); financeEntity.setApplytofinancing6done(""); // financeEntity.setFinancingdocsreceived7fileupl(financeBean.getFinancingDocsReceived7FileUpload()); financeEntity.setFinancingdocsreceived7string(""); financeEntity.setFinancingdocsreceived7che(0); financeEntity.setFinancingdocsreceived7do(""); financeEntity.setScheduleappointmentby8d(null); financeEntity.setScheduleappointmentby8st(""); financeEntity.setScheduleappointmentby8che(0); financeEntity.setScheduleappointmentby8do(""); // financeEntity.setSigningcontractbycustomer9fi(financeBean.getSigningContractByCustomer9FileUpload()); financeEntity.setSigningcontractbycustomer9st(""); financeEntity.setSigningcontractbycustomer9che(0); financeEntity.setSigningcontractbycustomer9done(""); financeEntity.setAlldocscompleted10string(""); financeEntity.setAlldocscompleted10checkbox(0); financeEntity.setAlldocscompleted10do(""); financeEntity.setNoticetoproceed11string(""); financeEntity.setNoticetoproceed11checkbox(0); financeEntity.setNoticetoproceed11done(""); financeEntity.setGivenforconcierge12string(""); financeEntity.setGivenforconcierge12checkbox(0); financeEntity.setGivenforconcierge12done(""); financeEntity.setGivenforconcierge12checkbox(0); financeEntity.setGivenforconcierge12done(""); financeEntity.setCustomerId(0); } else { financeEntity = (FinanceEntity) finances.get(0); } tx.commit(); } catch (HibernateException e) { if (tx != null) { tx.rollback(); } e.printStackTrace(); } finally { session.close(); } return financeEntity; }
From source file:db.manage.HouseManage.java
public List<CustomerEntity> getHouseByLikeCaseID(String caseID) { List<CustomerEntity> customers = null; Session session = sessionFactory.openSession(); Transaction tx = null;//from ww w. j a v a 2 s. c om try { tx = session.beginTransaction(); String sql = "SELECT * FROM CUSTOMER WHERE CASE_ID " + "LIKE '%" + caseID + "%'"; SQLQuery query = session.createSQLQuery(sql); query.addEntity(CustomerEntity.class); customers = query.list(); tx.commit(); } catch (HibernateException e) { if (tx != null) { tx.rollback(); } e.printStackTrace(); } finally { session.close(); } System.out.println("customers.get(0) = " + customers.size()); return customers; }
From source file:db.manage.HouseManage.java
public CustomerEntity getHouseByCaseID(String caseID) { CustomerEntity customerEntity = null; Session session = sessionFactory.openSession(); Transaction tx = null;//from w w w .j a v a 2 s .co m try { tx = session.beginTransaction(); String sql = "SELECT * FROM CUSTOMER WHERE CASE_ID = " + "'" + caseID + "'"; SQLQuery query = session.createSQLQuery(sql); query.addEntity(CustomerEntity.class); List customers = query.list(); if (customers.isEmpty()) { customerEntity = new CustomerEntity(); customerEntity.setNew1(1); } else { customerEntity = (CustomerEntity) customers.get(0); } tx.commit(); } catch (HibernateException e) { if (tx != null) { tx.rollback(); } e.printStackTrace(); } finally { session.close(); } return customerEntity; }