diagrama_de_base_de_datos.EventoDAO.java Source code

Java tutorial

Introduction

Here is the source code for diagrama_de_base_de_datos.EventoDAO.java

Source

/**
 * "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_de_base_de_datos;

import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;

public class EventoDAO {
    public static Evento loadEventoByORMID(int ID) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return loadEventoByORMID(session, ID);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento getEventoByORMID(int ID) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return getEventoByORMID(session, ID);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento loadEventoByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return loadEventoByORMID(session, ID, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento getEventoByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return getEventoByORMID(session, ID, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento loadEventoByORMID(PersistentSession session, int ID) throws PersistentException {
        try {
            return (Evento) session.load(diagrama_de_base_de_datos.Evento.class, new Integer(ID));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento getEventoByORMID(PersistentSession session, int ID) throws PersistentException {
        try {
            return (Evento) session.get(diagrama_de_base_de_datos.Evento.class, new Integer(ID));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento loadEventoByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Evento) session.load(diagrama_de_base_de_datos.Evento.class, new Integer(ID), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento getEventoByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Evento) session.get(diagrama_de_base_de_datos.Evento.class, new Integer(ID), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryEvento(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return queryEvento(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryEvento(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return queryEvento(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento[] listEventoByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return listEventoByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento[] listEventoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return listEventoByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryEvento(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        StringBuffer sb = new StringBuffer("From diagrama_de_base_de_datos.Evento as Evento");
        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 queryEvento(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From diagrama_de_base_de_datos.Evento as Evento");
        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("Evento", lockMode);
            return query.list();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento[] listEventoByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        try {
            List list = queryEvento(session, condition, orderBy);
            return (Evento[]) list.toArray(new Evento[list.size()]);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento[] listEventoByQuery(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            List list = queryEvento(session, condition, orderBy, lockMode);
            return (Evento[]) list.toArray(new Evento[list.size()]);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento loadEventoByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return loadEventoByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento loadEventoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return loadEventoByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento loadEventoByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        Evento[] eventos = listEventoByQuery(session, condition, orderBy);
        if (eventos != null && eventos.length > 0)
            return eventos[0];
        else
            return null;
    }

    public static Evento loadEventoByQuery(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        Evento[] eventos = listEventoByQuery(session, condition, orderBy, lockMode);
        if (eventos != null && eventos.length > 0)
            return eventos[0];
        else
            return null;
    }

    public static java.util.Iterator iterateEventoByQuery(String condition, String orderBy)
            throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return iterateEventoByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static java.util.Iterator iterateEventoByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance()
                    .getSession();
            return iterateEventoByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static java.util.Iterator iterateEventoByQuery(PersistentSession session, String condition,
            String orderBy) throws PersistentException {
        StringBuffer sb = new StringBuffer("From diagrama_de_base_de_datos.Evento as Evento");
        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 iterateEventoByQuery(PersistentSession session, String condition,
            String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From diagrama_de_base_de_datos.Evento as Evento");
        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("Evento", lockMode);
            return query.iterate();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento createEvento() {
        return new diagrama_de_base_de_datos.Evento();
    }

    public static boolean save(diagrama_de_base_de_datos.Evento evento) throws PersistentException {
        try {
            diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance().saveObject(evento);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean delete(diagrama_de_base_de_datos.Evento evento) throws PersistentException {
        try {
            diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance().deleteObject(evento);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean deleteAndDissociate(diagrama_de_base_de_datos.Evento evento) throws PersistentException {
        try {
            diagrama_de_base_de_datos.Parada[] lContienes = evento.contiene.toArray();
            for (int i = 0; i < lContienes.length; i++) {
                lContienes[i].evento_pertenece.remove(evento);
            }
            if (evento.getTiene_evento() != null) {
                evento.getTiene_evento().setEvento_se_ubica(null);
            }

            return delete(evento);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean deleteAndDissociate(diagrama_de_base_de_datos.Evento evento,
            org.orm.PersistentSession session) throws PersistentException {
        try {
            diagrama_de_base_de_datos.Parada[] lContienes = evento.contiene.toArray();
            for (int i = 0; i < lContienes.length; i++) {
                lContienes[i].evento_pertenece.remove(evento);
            }
            if (evento.getTiene_evento() != null) {
                evento.getTiene_evento().setEvento_se_ubica(null);
            }

            try {
                session.delete(evento);
                return true;
            } catch (Exception e) {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean refresh(diagrama_de_base_de_datos.Evento evento) throws PersistentException {
        try {
            diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance().getSession().refresh(evento);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean evict(diagrama_de_base_de_datos.Evento evento) throws PersistentException {
        try {
            diagrama_de_base_de_datos.ProyectoMDS2PersistentManager.instance().getSession().evict(evento);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Evento loadEventoByCriteria(EventoCriteria eventoCriteria) {
        Evento[] eventos = listEventoByCriteria(eventoCriteria);
        if (eventos == null || eventos.length == 0) {
            return null;
        }
        return eventos[0];
    }

    public static Evento[] listEventoByCriteria(EventoCriteria eventoCriteria) {
        return eventoCriteria.listEvento();
    }
}