/** * "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: Universidad de La Frontera * License Type: Academic */ package orm; import org.orm.*; import org.hibernate.Query; import org.hibernate.LockMode; import java.util.List; public class ColegioDAO { public static Colegio loadColegioByORMID(int id_pk) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return loadColegioByORMID(session, id_pk); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio getColegioByORMID(int id_pk) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return getColegioByORMID(session, id_pk); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio loadColegioByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return loadColegioByORMID(session, id_pk, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio getColegioByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return getColegioByORMID(session, id_pk, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio loadColegioByORMID(PersistentSession session, int id_pk) throws PersistentException { try { return (Colegio) session.load(orm.Colegio.class, new Integer(id_pk)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio getColegioByORMID(PersistentSession session, int id_pk) throws PersistentException { try { return (Colegio) session.get(orm.Colegio.class, new Integer(id_pk)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio loadColegioByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Colegio) session.load(orm.Colegio.class, new Integer(id_pk), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio getColegioByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Colegio) session.get(orm.Colegio.class, new Integer(id_pk), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryColegio(String condition, String orderBy) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return queryColegio(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryColegio(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return queryColegio(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio[] listColegioByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return listColegioByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio[] listColegioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return listColegioByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryColegio(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio"); 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 queryColegio(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio"); 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("Colegio", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio[] listColegioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryColegio(session, condition, orderBy); return (Colegio[]) list.toArray(new Colegio[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio[] listColegioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryColegio(session, condition, orderBy, lockMode); return (Colegio[]) list.toArray(new Colegio[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio loadColegioByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return loadColegioByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio loadColegioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return loadColegioByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio loadColegioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Colegio[] colegios = listColegioByQuery(session, condition, orderBy); if (colegios != null && colegios.length > 0) return colegios[0]; else return null; } public static Colegio loadColegioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Colegio[] colegios = listColegioByQuery(session, condition, orderBy, lockMode); if (colegios != null && colegios.length > 0) return colegios[0]; else return null; } public static java.util.Iterator iterateColegioByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return iterateColegioByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateColegioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = orm.ColegioPersistentManager.instance().getSession(); return iterateColegioByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateColegioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio"); 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 iterateColegioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio"); 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("Colegio", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Colegio createColegio() { return new orm.Colegio(); } public static boolean save(orm.Colegio colegio) throws PersistentException { try { orm.ColegioPersistentManager.instance().saveObject(colegio); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(orm.Colegio colegio) throws PersistentException { try { orm.ColegioPersistentManager.instance().deleteObject(colegio); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(orm.Colegio colegio)throws PersistentException { try { orm.Curso[] lCursos = colegio.curso.toArray(); for(int i = 0; i < lCursos.length; i++) { lCursos[i].setColegio_id_fk(null); } orm.Apoderado[] lApoderados = colegio.apoderado.toArray(); for(int i = 0; i < lApoderados.length; i++) { lApoderados[i].setColegio_id_fk(null); } orm.Profesor[] lProfesors = colegio.profesor.toArray(); for(int i = 0; i < lProfesors.length; i++) { lProfesors[i].setColegio_id_fk(null); } return delete(colegio); } catch(Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(orm.Colegio colegio, org.orm.PersistentSession session)throws PersistentException { try { orm.Curso[] lCursos = colegio.curso.toArray(); for(int i = 0; i < lCursos.length; i++) { lCursos[i].setColegio_id_fk(null); } orm.Apoderado[] lApoderados = colegio.apoderado.toArray(); for(int i = 0; i < lApoderados.length; i++) { lApoderados[i].setColegio_id_fk(null); } orm.Profesor[] lProfesors = colegio.profesor.toArray(); for(int i = 0; i < lProfesors.length; i++) { lProfesors[i].setColegio_id_fk(null); } try { session.delete(colegio); return true; } catch (Exception e) { return false; } } catch(Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(orm.Colegio colegio) throws PersistentException { try { orm.ColegioPersistentManager.instance().getSession().refresh(colegio); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(orm.Colegio colegio) throws PersistentException { try { orm.ColegioPersistentManager.instance().getSession().evict(colegio); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } }