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 CanalDAO { public static Canal loadCanalByORMID(int ID) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadCanalByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal getCanalByORMID(int ID) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getCanalByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal loadCanalByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadCanalByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal getCanalByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getCanalByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal loadCanalByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Canal) session.load(diagrama_bd.base_de_datos.Canal.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal getCanalByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Canal) session.get(diagrama_bd.base_de_datos.Canal.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal loadCanalByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Canal) session.load(diagrama_bd.base_de_datos.Canal.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal getCanalByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Canal) session.get(diagrama_bd.base_de_datos.Canal.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryCanal(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryCanal(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryCanal(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryCanal(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal[] listCanalByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listCanalByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal[] listCanalByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listCanalByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryCanal(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Canal as Canal"); 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 queryCanal(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Canal as Canal"); 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("Canal", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal[] listCanalByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryCanal(session, condition, orderBy); return (Canal[]) list.toArray(new Canal[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal[] listCanalByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryCanal(session, condition, orderBy, lockMode); return (Canal[]) list.toArray(new Canal[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal loadCanalByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadCanalByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal loadCanalByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadCanalByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal loadCanalByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Canal[] canals = listCanalByQuery(session, condition, orderBy); if (canals != null && canals.length > 0) return canals[0]; else return null; } public static Canal loadCanalByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Canal[] canals = listCanalByQuery(session, condition, orderBy, lockMode); if (canals != null && canals.length > 0) return canals[0]; else return null; } public static java.util.Iterator iterateCanalByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateCanalByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateCanalByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateCanalByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateCanalByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Canal as Canal"); 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 iterateCanalByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Canal as Canal"); 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("Canal", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal createCanal() { return new diagrama_bd.base_de_datos.Canal(); } public static boolean save(diagrama_bd.base_de_datos.Canal canal) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().saveObject(canal); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(diagrama_bd.base_de_datos.Canal canal) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().deleteObject(canal); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Canal canal) throws PersistentException { try { diagrama_bd.base_de_datos.ServicioTV[] lEs_partes = canal.es_parte.toArray(); for (int i = 0; i < lEs_partes.length; i++) { lEs_partes[i].compuesto_por.remove(canal); } return delete(canal); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Canal canal, org.orm.PersistentSession session) throws PersistentException { try { diagrama_bd.base_de_datos.ServicioTV[] lEs_partes = canal.es_parte.toArray(); for (int i = 0; i < lEs_partes.length; i++) { lEs_partes[i].compuesto_por.remove(canal); } try { session.delete(canal); 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.Canal canal) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .refresh(canal); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(diagrama_bd.base_de_datos.Canal canal) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .evict(canal); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Canal loadCanalByCriteria(CanalCriteria canalCriteria) { Canal[] canals = listCanalByCriteria(canalCriteria); if (canals == null || canals.length == 0) { return null; } return canals[0]; } public static Canal[] listCanalByCriteria(CanalCriteria canalCriteria) { return canalCriteria.listCanal(); } }