List of usage examples for org.hibernate SQLQuery setString
@Deprecated @SuppressWarnings("unchecked") default Query<R> setString(int position, String val)
From source file:dao.CompoundDao.java
public List<Compound> findCompoundById(String str) { SQLQuery sqlq = null; List<Compound> objects = null; try {/* w w w . j ava 2 s .co m*/ tx = session.beginTransaction(); sqlq = session.createSQLQuery("SELECT * FROM Compound WHERE Compound.idCompound=:str"); sqlq.setString("str", str); objects = sqlq.addEntity(Compound.class).list(); tx.commit(); } catch (HibernateException e) { tx.rollback(); } return objects; }
From source file:dao.DrugDao.java
public Integer findWhetherDrugExist(String str) { SQLQuery sqlq = null; BigInteger aa = null;// ww w.j a v a2s.c o m try { tx = session.beginTransaction(); sqlq = session.createSQLQuery("SELECT COUNT(1) FROM Drug WHERE drugNumber=:str"); sqlq.setString("str", str); aa = (BigInteger) sqlq.uniqueResult(); System.out.println(aa + "aaaaaaaa"); tx.commit(); } catch (HibernateException e) { tx.rollback(); } return aa.intValue(); }
From source file:dao.EnterpriseDao.java
public List<Enterprise> searchEnterpriseByIdCity(String str) { List<Enterprise> objects = null; SQLQuery sqlq = null; try {/*from w w w . j av a 2 s .c o m*/ tx = session.beginTransaction(); sqlq = session.createSQLQuery("select * from Enterprise where idCity=(:str)"); sqlq.setString("str", str); objects = sqlq.addEntity(Enterprise.class).list(); tx.commit(); } catch (HibernateException e) { tx.rollback(); } return objects; }
From source file:dao.JoinSeletedCompoundDao.java
public List<JoinSelectedCompound> findCompoundByDrugNumber(String str) { List<JoinSelectedCompound> objects = null; SQLQuery sqlq = null; try {/* w ww . jav a2s .c om*/ tx = session.beginTransaction(); sqlq = session.createSQLQuery("call selectedCompoundJionCompound(:str)"); sqlq.setString("str", str); objects = sqlq.setResultTransformer(Transformers.aliasToBean(JoinSelectedCompound.class)).list(); tx.commit(); } catch (HibernateException e) { tx.rollback(); } return objects; }
From source file:dao.MessageDao.java
public List<Message> getMessageByUserID(String str) { List<Message> objects = null; SQLQuery sqlq = null; try {/*from w w w . j av a 2 s. c om*/ tx = session.beginTransaction(); sqlq = session.createSQLQuery("select * from Message where Message.receiver=(:str)"); sqlq.setString("str", str); objects = sqlq.addEntity(Message.class).list(); tx.commit(); } catch (HibernateException e) { tx.rollback(); } return objects; }
From source file:dao.PatientsDao.java
public List<Patients> searchPatientsByName(String str) { List<Patients> objects = null; SQLQuery sqlq = null; try {/*w ww . j a v a 2 s . c om*/ tx = session.beginTransaction(); sqlq = session.createSQLQuery("call searchPatientsByLastName(:str)"); sqlq.setString("str", str); objects = sqlq.addEntity(Patients.class).list(); tx.commit(); } catch (HibernateException e) { tx.rollback(); } return objects; }
From source file:DAO.ValidatorDAO.java
public String validate(String user, String pass) { pass = DigestUtils.sha512Hex(pass);// www. j av a 2 s . c om SessionFactory sf = HibernateUtil.getSessionFactory(); Session session = sf.openSession(); SQLQuery sQLQuery = session.createSQLQuery(sqlGeneratorLogin()); sQLQuery.addEntity(Usuarios.class); sQLQuery.setString("user_id", user); sQLQuery.setString("pass", pass); Usuarios u = (Usuarios) sQLQuery.uniqueResult(); if (u != null) { return u.getUsrToken(); } return "Error"; }
From source file:DAO.ValidatorDAO.java
public boolean DocentePermission(String token) { SessionFactory sf = HibernateUtil.getSessionFactory(); Session session = sf.openSession();/* w w w.ja va2s . c o m*/ //SQLQuery sQLQuery = session.createSQLQuery("select * from USUARIOS, DOCENTE where usr_token = '"+token+"' and usr_id = doc_cod"); SQLQuery sQLQuery = session .createSQLQuery("select * from USUARIOS, DOCENTE where usr_token = :token and usr_id = doc_cod"); sQLQuery.addEntity(Usuarios.class); sQLQuery.setString("token", token); if (!sQLQuery.list().isEmpty()) { return true; } else return false; }
From source file:databaseUtility.Database.java
public Evento getEvento(String id) { Session session = factory.openSession(); Transaction tx = session.beginTransaction(); SQLQuery query = session.createSQLQuery("SELECT * FROM WA2P_EVENTI WHERE Id= :id").addEntity(Evento.class); query.setString("id", id); Evento v = (Evento) query.uniqueResult(); tx.commit();//from w w w . j a v a 2 s .co m session.close(); return v; }
From source file:databaseUtility.Database.java
public List<Commento> getCommentiPerEvento(String idevento) { Session session = factory.openSession(); Transaction tx = session.beginTransaction(); SQLQuery query = session.createSQLQuery("SELECT * FROM WA2P_COMMENTI WHERE evento= :id ORDER BY dataC DESC") .addEntity(Commento.class); query.setString("id", idevento); List<Commento> v = (List<Commento>) query.list(); tx.commit();/*www. j ava 2s . c o m*/ session.close(); return v; }