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 ComercialDAO { public static Comercial loadComercialByORMID(int nComercial) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadComercialByORMID(session, nComercial); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial getComercialByORMID(int nComercial) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getComercialByORMID(session, nComercial); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial loadComercialByORMID(int nComercial, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadComercialByORMID(session, nComercial, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial getComercialByORMID(int nComercial, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getComercialByORMID(session, nComercial, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial loadComercialByORMID(PersistentSession session, int nComercial) throws PersistentException { try { return (Comercial) session.load(diagrama_bd.base_de_datos.Comercial.class, new Integer(nComercial)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial getComercialByORMID(PersistentSession session, int nComercial) throws PersistentException { try { return (Comercial) session.get(diagrama_bd.base_de_datos.Comercial.class, new Integer(nComercial)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial loadComercialByORMID(PersistentSession session, int nComercial, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Comercial) session.load(diagrama_bd.base_de_datos.Comercial.class, new Integer(nComercial), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial getComercialByORMID(PersistentSession session, int nComercial, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Comercial) session.get(diagrama_bd.base_de_datos.Comercial.class, new Integer(nComercial), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryComercial(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryComercial(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryComercial(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryComercial(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial[] listComercialByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listComercialByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial[] listComercialByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listComercialByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryComercial(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Comercial as Comercial"); 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 queryComercial(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Comercial as Comercial"); 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("Comercial", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial[] listComercialByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryComercial(session, condition, orderBy); return (Comercial[]) list.toArray(new Comercial[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial[] listComercialByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryComercial(session, condition, orderBy, lockMode); return (Comercial[]) list.toArray(new Comercial[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial loadComercialByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadComercialByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial loadComercialByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadComercialByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial loadComercialByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Comercial[] comercials = listComercialByQuery(session, condition, orderBy); if (comercials != null && comercials.length > 0) return comercials[0]; else return null; } public static Comercial loadComercialByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Comercial[] comercials = listComercialByQuery(session, condition, orderBy, lockMode); if (comercials != null && comercials.length > 0) return comercials[0]; else return null; } public static java.util.Iterator iterateComercialByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateComercialByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateComercialByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateComercialByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateComercialByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Comercial as Comercial"); 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 iterateComercialByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Comercial as Comercial"); 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("Comercial", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial createComercial() { return new diagrama_bd.base_de_datos.Comercial(); } public static boolean save(diagrama_bd.base_de_datos.Comercial comercial) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().saveObject(comercial); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(diagrama_bd.base_de_datos.Comercial comercial) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().deleteObject(comercial); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Comercial comercial) throws PersistentException { try { diagrama_bd.base_de_datos.Incidencia[] lTramitas = comercial.tramita.toArray(); for (int i = 0; i < lTramitas.length; i++) { lTramitas[i].setTramitada_por(null); } return delete(comercial); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Comercial comercial, org.orm.PersistentSession session) throws PersistentException { try { diagrama_bd.base_de_datos.Incidencia[] lTramitas = comercial.tramita.toArray(); for (int i = 0; i < lTramitas.length; i++) { lTramitas[i].setTramitada_por(null); } try { session.delete(comercial); 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.Comercial comercial) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .refresh(comercial); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(diagrama_bd.base_de_datos.Comercial comercial) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .evict(comercial); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Comercial loadComercialByCriteria(ComercialCriteria comercialCriteria) { Comercial[] comercials = listComercialByCriteria(comercialCriteria); if (comercials == null || comercials.length == 0) { return null; } return comercials[0]; } public static Comercial[] listComercialByCriteria(ComercialCriteria comercialCriteria) { return comercialCriteria.listComercial(); } }