Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.hibernate.model.dao;
- import java.util.List;
- import org.hibernate.*;
- import org.hibernate.criterion.Example;
- import org.hibernate.model.*;
- /**
- *
- * @author Miguel
- */
- public class infoDao {
- Session sn = HibernateUtil.getSessionFactory().getCurrentSession();
- Transaction tx = null;
- Query qr = null;
- public boolean createAeropuerto(Aeropuerto instance) {
- try {
- tx = sn.beginTransaction();
- sn.save(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public List<Aeropuerto> readAeropuerto() {
- List<Aeropuerto> list = null;
- try {
- tx = sn.beginTransaction();
- qr = sn.createQuery("FROM aeropuerto");
- list = qr.list();
- tx.commit();
- return list;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return list;
- }
- }
- public boolean updateAeropuerto(Aeropuerto instance) {
- try {
- tx = sn.beginTransaction();
- sn.update(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public boolean deleteAeropuerto(Aeropuerto instance) {
- try {
- tx = sn.beginTransaction();
- sn.delete(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public Aeropuerto findAeropuertoById(int id) {
- Aeropuerto pci = new Aeropuerto();
- try {
- tx = sn.beginTransaction();
- pci = (Aeropuerto) sn.get("org.hibernate.model.Aeropuerto", id);
- tx.commit();
- return pci;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return pci;
- }
- }
- public List<Aeropuerto> findAeropuertoByCriteria(Aeropuerto instance) {
- List<Aeropuerto> lis = null;
- try {
- tx = sn.beginTransaction();
- lis = sn.createCriteria("org.hibernate.model.Aeropuerto").add(Example.create(instance)).list();
- tx.commit();
- return lis;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return lis;
- }
- }
- public boolean createAvion(Avion instance) {
- try {
- tx = sn.beginTransaction();
- sn.save(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public List<Avion> readAvion() {
- List<Avion> list = null;
- try {
- tx = sn.beginTransaction();
- qr = sn.createQuery("FROM Avion");
- list = qr.list();
- tx.commit();
- return list;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return list;
- }
- }
- public boolean updateAvion(Avion instance) {
- try {
- tx = sn.beginTransaction();
- sn.update(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public boolean deleteAvion(Avion instance) {
- try {
- tx = sn.beginTransaction();
- sn.delete(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public Avion findAvionById(int id) {
- Avion av = new Avion();
- try {
- tx = sn.beginTransaction();
- av = (Avion) sn.get("org.hibernate.model.Avion", id);
- tx.commit();
- return av;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return av;
- }
- }
- public List<Avion> findAvionByCriteria(Avion instance) {
- List<Avion> lis = null;
- try {
- tx = sn.beginTransaction();
- lis = sn.createCriteria("org.hibernate.model.Avion").add(Example.create(instance)).list();
- tx.commit();
- return lis;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return lis;
- }
- }
- public boolean createClientes(Clientes instance) {
- try {
- tx = sn.beginTransaction();
- sn.save(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public List<Clientes> readClientes() {
- List<Clientes> list = null;
- try {
- tx = sn.beginTransaction();
- qr = sn.createQuery("FROM Clientes");
- list = qr.list();
- tx.commit();
- return list;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return list;
- }
- }
- public boolean updateClientes(Clientes instance) {
- try {
- tx = sn.beginTransaction();
- sn.update(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public boolean deleteClientes(Clientes instance) {
- try {
- tx = sn.beginTransaction();
- sn.delete(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public Clientes findClientesById(int id) {
- Clientes cl = new Clientes();
- try {
- tx = sn.beginTransaction();
- cl = (Clientes) sn.get("org.hibernate.model.Clientes", id);
- tx.commit();
- return cl;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return cl;
- }
- }
- public List<Clientes> findClientesByCriteria(Clientes instance) {
- List<Clientes> lis = null;
- try {
- tx = sn.beginTransaction();
- lis = sn.createCriteria("org.hibernate.model.Clientes").add(Example.create(instance)).list();
- tx.commit();
- return lis;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return lis;
- }
- }
- public boolean createReservaciones(Reservaciones instance) {
- try {
- tx = sn.beginTransaction();
- sn.save(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public List<Reservaciones> readReservaciones() {
- List<Reservaciones> list = null;
- try {
- tx = sn.beginTransaction();
- qr = sn.createQuery("FROM Reservaciones");
- list = qr.list();
- tx.commit();
- return list;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return list;
- }
- }
- public boolean updateReservaciones(Reservaciones instance) {
- try {
- tx = sn.beginTransaction();
- sn.update(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public boolean deleteReservaciones(Reservaciones instance) {
- try {
- tx = sn.beginTransaction();
- sn.delete(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public Reservaciones findReservacionesById(int id) {
- Reservaciones re = new Reservaciones();
- try {
- tx = sn.beginTransaction();
- re = (Reservaciones) sn.get("org.hibernate.model.Reservaciones", id);
- tx.commit();
- return re;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return re;
- }
- }
- public List<Reservaciones> findReservacionesByCriteria(Reservaciones instance) {
- List<Reservaciones> lis = null;
- try {
- tx = sn.beginTransaction();
- lis = sn.createCriteria("org.hibernate.model.Reservaciones").add(Example.create(instance)).list();
- tx.commit();
- return lis;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return lis;
- }
- }
- public boolean createVuelos(Vuelos instance) {
- try {
- tx = sn.beginTransaction();
- sn.save(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public List<Vuelos> readVuelos() {
- List<Vuelos> list = null;
- try {
- tx = sn.beginTransaction();
- qr = sn.createQuery("FROM Vuelos");
- list = qr.list();
- tx.commit();
- return list;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return list;
- }
- }
- public boolean updateVuelos(Vuelos instance) {
- try {
- tx = sn.beginTransaction();
- sn.update(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public boolean deleteVuelos(Vuelos instance) {
- try {
- tx = sn.beginTransaction();
- sn.delete(instance);
- tx.commit();
- return true;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return false;
- }
- }
- public Vuelos findVuelosById(int id) {
- Vuelos vu = new Vuelos();
- try {
- tx = sn.beginTransaction();
- vu = (Vuelos) sn.get("org.hibernate.model.Vuelos", id);
- tx.commit();
- return vu;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return vu;
- }
- }
- public List<Vuelos> findVuelosByCriteria(Vuelos instance) {
- List<Vuelos> lis = null;
- try {
- tx = sn.beginTransaction();
- lis = sn.createCriteria("org.hibernate.model.Vuelos").add(Example.create(instance)).list();
- tx.commit();
- return lis;
- } catch (HibernateException he) {
- tx.rollback();
- System.out.println(he.getMessage());
- return lis;
- }
- }
- }
Add Comment
Please, Sign In to add comment