Java tutorial
/** * "Visual Paradigm: DO NOT MODIFY THIS FILE!" * * This is an automatic generated file. It will be regenerated every time * you generate persistence class. * * Modifying its content may cause the program not work, or your work may lost. */ /** * Licensee: University of Almeria * License Type: Academic */ package diagrama_bd.base_de_datos; import org.orm.*; import org.hibernate.Query; import org.hibernate.LockMode; import java.util.List; public class FacturaDAO { public static Factura loadFacturaByORMID(int nFactura) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadFacturaByORMID(session, nFactura); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura getFacturaByORMID(int nFactura) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getFacturaByORMID(session, nFactura); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura loadFacturaByORMID(int nFactura, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadFacturaByORMID(session, nFactura, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura getFacturaByORMID(int nFactura, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getFacturaByORMID(session, nFactura, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura loadFacturaByORMID(PersistentSession session, int nFactura) throws PersistentException { try { return (Factura) session.load(diagrama_bd.base_de_datos.Factura.class, new Integer(nFactura)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura getFacturaByORMID(PersistentSession session, int nFactura) throws PersistentException { try { return (Factura) session.get(diagrama_bd.base_de_datos.Factura.class, new Integer(nFactura)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura loadFacturaByORMID(PersistentSession session, int nFactura, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Factura) session.load(diagrama_bd.base_de_datos.Factura.class, new Integer(nFactura), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura getFacturaByORMID(PersistentSession session, int nFactura, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Factura) session.get(diagrama_bd.base_de_datos.Factura.class, new Integer(nFactura), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryFactura(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryFactura(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryFactura(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryFactura(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura[] listFacturaByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listFacturaByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura[] listFacturaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listFacturaByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryFactura(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Factura as Factura"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try { Query query = session.createQuery(sb.toString()); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryFactura(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Factura as Factura"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try { Query query = session.createQuery(sb.toString()); query.setLockMode("Factura", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura[] listFacturaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryFactura(session, condition, orderBy); return (Factura[]) list.toArray(new Factura[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura[] listFacturaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryFactura(session, condition, orderBy, lockMode); return (Factura[]) list.toArray(new Factura[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura loadFacturaByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadFacturaByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura loadFacturaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadFacturaByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura loadFacturaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Factura[] facturas = listFacturaByQuery(session, condition, orderBy); if (facturas != null && facturas.length > 0) return facturas[0]; else return null; } public static Factura loadFacturaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Factura[] facturas = listFacturaByQuery(session, condition, orderBy, lockMode); if (facturas != null && facturas.length > 0) return facturas[0]; else return null; } public static java.util.Iterator iterateFacturaByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateFacturaByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateFacturaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateFacturaByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateFacturaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Factura as Factura"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try { Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateFacturaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Factura as Factura"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try { Query query = session.createQuery(sb.toString()); query.setLockMode("Factura", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura createFactura() { return new diagrama_bd.base_de_datos.Factura(); } public static boolean save(diagrama_bd.base_de_datos.Factura factura) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().saveObject(factura); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(diagrama_bd.base_de_datos.Factura factura) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().deleteObject(factura); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Factura factura) throws PersistentException { try { diagrama_bd.base_de_datos.Servicio[] lCorresponde_as = factura.corresponde_a.toArray(); for (int i = 0; i < lCorresponde_as.length; i++) { lCorresponde_as[i].setGenera(null); } return delete(factura); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Factura factura, org.orm.PersistentSession session) throws PersistentException { try { diagrama_bd.base_de_datos.Servicio[] lCorresponde_as = factura.corresponde_a.toArray(); for (int i = 0; i < lCorresponde_as.length; i++) { lCorresponde_as[i].setGenera(null); } try { session.delete(factura); return true; } catch (Exception e) { return false; } } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(diagrama_bd.base_de_datos.Factura factura) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .refresh(factura); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(diagrama_bd.base_de_datos.Factura factura) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .evict(factura); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Factura loadFacturaByCriteria(FacturaCriteria facturaCriteria) { Factura[] facturas = listFacturaByCriteria(facturaCriteria); if (facturas == null || facturas.length == 0) { return null; } return facturas[0]; } public static Factura[] listFacturaByCriteria(FacturaCriteria facturaCriteria) { return facturaCriteria.listFactura(); } }