List of usage examples for org.hibernate Session createNamedQuery
Query createNamedQuery(String name);
From source file:kievreclama.task.dao.impl.DepartmentDaoImpl.java
@Override public void delete(int id) { Session session = sessionFactory.getCurrentSession(); session.createNamedQuery("deleteDepartment").setParameter("id", id).executeUpdate(); }
From source file:manejadorDB.controlador.AeropuertoControlador.java
@Override public List<Aeropuerto> todos() { List<Aeropuerto> aeropuertos = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {//www. j ava2 s.co m //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista aeropuertos = session.createNamedQuery("Aeropuerto.findAll").list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } return aeropuertos; }
From source file:manejadorDB.controlador.AeropuertoControlador.java
@Override public int cantidad() { List<Aeropuerto> aeropuertos = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {/*from w ww .j a va 2 s . c o m*/ //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista aeropuertos = session.createNamedQuery("Aeropuerto.findAll").list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } if (aeropuertos == null) return 0; else return aeropuertos.size(); }
From source file:manejadorDB.controlador.AeropuertoControlador.java
@Override public List<Aeropuerto> buscarByLugar(Lugar filtro) { List<Aeropuerto> aeropuertos = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {/*from w ww. j a va2 s . c o m*/ //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); System.out.println("filtro : " + filtro.toString()); aeropuertos = session.createNamedQuery("Aeropuerto.findByLugar").setParameter("idlugar", filtro) .list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } return aeropuertos; }
From source file:manejadorDB.controlador.AvionControlador.java
@Override public List<Avion> todos() { List<Avion> aviones = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {/*from w ww. ja v a 2s . c o m*/ //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista aviones = session.createNamedQuery("Avion.findAll").list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } return aviones; }
From source file:manejadorDB.controlador.AvionControlador.java
@Override public int cantidad() { List<Avion> aviones = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {// ww w . ja v a2 s . c o m //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista aviones = session.createNamedQuery("Avion.findAll").list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } if (aviones == null) return 0; else return aviones.size(); }
From source file:manejadorDB.controlador.CargoControlador.java
@Override public List<Cargo> todos() { List<Cargo> cargos = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {/*from w w w. ja v a 2 s . c o m*/ //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista cargos = session.createNamedQuery("Cargo.findAll").list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } return cargos; }
From source file:manejadorDB.controlador.CargoControlador.java
@Override public int cantidad() { List<Cargo> cargos = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {//from ww w . java2 s. c o m //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista cargos = session.createNamedQuery("Cargo.findAll").list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } if (cargos == null) return 0; else return cargos.size(); }
From source file:manejadorDB.controlador.CargoControlador.java
@Override public Cargo devolverCargo(Integer idCargo) { List<Cargo> cargos = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {// w w w . j a v a2s . c om //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista cargos = session.createNamedQuery("Cargo.findByIdcargo").setParameter("idcargo", idCargo).list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } if (cargos != null && cargos.size() > 0) { return cargos.get(0); } else { return null; } }
From source file:manejadorDB.controlador.ClienteControlador.java
@Override public List<Cliente> todos() { List<Cliente> clientes = null; SessionFactory factory = Sesion.init(); if (factory != null) { try {//from ww w. j ava 2 s . c o m //crear sesion Session session = factory.getCurrentSession(); //transaccion session.beginTransaction(); //obtener lista clientes = session.createNamedQuery("Cliente.findAll").list(); //commitear transaccion session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { Sesion.close(); } } return clientes; }