List of usage examples for org.hibernate Session createQuery
@Override org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
From source file:Anbulategi.GaixoaDAOHibernate.java
@Override public boolean checkGaixoa(int GSZ, String password) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try {/* ww w .j a v a2 s. c o m*/ session.beginTransaction(); String hql = "From Gaixoa gaixo where gaixo.GSZ = ? and gaixo.pasahitza = ?"; Query kontsulta = session.createQuery(hql).setParameter(0, GSZ).setParameter(1, password); List<Gaixoa> lista = kontsulta.list(); session.getTransaction().commit(); return !lista.isEmpty(); } catch (Exception ex) { ex.printStackTrace(); session.getTransaction().rollback(); return false; } }
From source file:Anbulategi.IdazkariaDAOHibernate.java
@Override public boolean checkIdazkari(int id, String password) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try {//from w w w . j a va 2s. co m session.beginTransaction(); String hql = "From Idazkaria idazkari where idazkari.id = ? and idazkari.pasahitza = ?"; Query kontsulta = session.createQuery(hql).setParameter(0, id).setParameter(1, password); List<Idazkaria> lista = kontsulta.list(); session.getTransaction().commit(); return !lista.isEmpty(); } catch (Exception ex) { ex.printStackTrace(); session.getTransaction().rollback(); return false; } }
From source file:Anbulategi.SendagileaDAOHibernate.java
@Override public boolean checkSendagile(int GSZ, String password) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try {//from www . java2s . co m session.beginTransaction(); String hql = "From Sendagilea sendagile where sendagile.NAN = ? and sendagile.pasahitza = ?"; Query kontsulta = session.createQuery(hql).setParameter(0, GSZ).setParameter(1, password); List<Gaixoa> lista = kontsulta.list(); session.getTransaction().commit(); return !lista.isEmpty(); } catch (Exception ex) { ex.printStackTrace(); session.getTransaction().rollback(); return false; } }
From source file:angeldx.manager.EstudianteManager.java
public List<Estudiante> listar() { List<Estudiante> list = new ArrayList<Estudiante>(); Session session = HibernateUtil.openSession(); Transaction tran = null;/* w w w. jav a 2s.c o m*/ try { tran = session.getTransaction(); tran.begin(); list = session.createQuery("from Estudiante").list(); //from Estudiante de llama de la persitencia de datos (to) tran.commit(); } catch (Exception e) { e.printStackTrace(); } finally { session.flush(); session.close(); } return list; }
From source file:angeldx.manager.EstudianteManager.java
public Estudiante buscarPorId(int id) { Estudiante est = null;//from ww w . j a va 2 s . c om Transaction tran = null; Session session = HibernateUtil.openSession(); try { tran = session.beginTransaction(); String queryString = "from Estudiante where id = :id"; Query query = session.createQuery(queryString); query.setInteger("id", id); est = (Estudiante) query.uniqueResult(); } catch (RuntimeException e) { e.printStackTrace(); } finally { session.flush(); session.close(); } return est; }
From source file:app.dao.EmployeeDAOImpl.java
@Override public List<Employee> getAllEmployees() { List<Employee> employees = new ArrayList<>(); Session session = getCurrentSession(); Query query;/*from w ww . j a v a 2s . com*/ Transaction tx = session.beginTransaction(); String hql = "FROM Employee"; query = session.createQuery(hql); employees = query.list(); tx.commit(); return employees; }
From source file:app.datos.servicios.implementacion.InmuebleServiceImpl.java
License:Open Source License
@Override @Transactional(readOnly = true, rollbackFor = PersistenciaException.class) public ArrayList<Inmueble> listarInmuebles(FiltroInmueble filtro) throws PersistenciaException { ArrayList<Inmueble> inmuebles = new ArrayList<>(); Session session = getSessionFactory().getCurrentSession(); try {/*from www .j ava 2s. c o m*/ Query query = session.createQuery(filtro.getConsultaDinamica()); filtro.setParametros(query); for (Object o : query.list()) { if (o instanceof Inmueble) { inmuebles.add((Inmueble) o); } } } catch (Exception e) { throw new ConsultaException(e); } return inmuebles; }
From source file:app.model.repository.impl.UserRoleDaoImpl.java
@Transactional @Override//from ww w .j ava 2 s.c o m public List<UserRole> getUserRoleListByUser(User user) { Session session = sessionFactory.getCurrentSession(); Transaction transaction = session.getTransaction(); try { transaction.begin(); List<UserRole> userRoleList = session.createQuery("from USER_ROLES where user=?").setParameter(0, user) .list(); transaction.commit(); return userRoleList; } catch (Exception e) { e.printStackTrace(); transaction.rollback(); } finally { if (session.isOpen()) session.close(); } return null; }
From source file:appcostal.model.DAO.java
public List<Hermano> hermanosDisponibles() { List<Hermano> hermanos; SessionFactory s = HibernateUtil.getSessionFactory(); Session se; se = s.openSession();// w w w. ja v a 2 s. co m Transaction tx = se.beginTransaction(); Query q = se.createQuery("From Hermano"); hermanos = (List<Hermano>) q.list(); tx.commit(); se.close(); return hermanos; }
From source file:appcostal.model.DAO.java
public Hermano buscaHermano(String email, String clave) { Hermano hermano = null;//from ww w.ja va 2s.co m SessionFactory s = HibernateUtil.getSessionFactory(); Session se; se = s.openSession(); Transaction tx = se.beginTransaction(); Query q = se.createQuery("From Hermano where email='" + email + "' and clave='" + clave + "'"); List<Hermano> lista = (List<Hermano>) q.list(); if (!lista.isEmpty()) { hermano = lista.get(0); } tx.commit(); se.close(); return hermano; }