es.tekniker.eefrmwrk.monitoring.tac.dao.domain.EventDAO.java Source code

Java tutorial

Introduction

Here is the source code for es.tekniker.eefrmwrk.monitoring.tac.dao.domain.EventDAO.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: Virginia Aranceta
 * License Type: Purchased
 */
package es.tekniker.eefrmwrk.monitoring.tac.dao.domain;

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

public class EventDAO {
    public static Event loadEventByORMID(int eventId) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return loadEventByORMID(session, eventId);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event getEventByORMID(int eventId) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return getEventByORMID(session, eventId);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event loadEventByORMID(int eventId, org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return loadEventByORMID(session, eventId, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event getEventByORMID(int eventId, org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return getEventByORMID(session, eventId, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event loadEventByORMID(PersistentSession session, int eventId) throws PersistentException {
        try {
            return (Event) session.load(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event.class,
                    new Integer(eventId));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event getEventByORMID(PersistentSession session, int eventId) throws PersistentException {
        try {
            return (Event) session.get(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event.class,
                    new Integer(eventId));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event loadEventByORMID(PersistentSession session, int eventId, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Event) session.load(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event.class,
                    new Integer(eventId), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event getEventByORMID(PersistentSession session, int eventId, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Event) session.get(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event.class,
                    new Integer(eventId), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryEvent(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return queryEvent(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryEvent(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return queryEvent(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event[] listEventByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return listEventByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event[] listEventByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return listEventByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryEvent(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        StringBuffer sb = new StringBuffer("From es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event as Event");
        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 queryEvent(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event as Event");
        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("Event", lockMode);
            return query.list();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

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

    public static Event loadEventByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return loadEventByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event loadEventByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return loadEventByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event loadEventByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        Event[] events = listEventByQuery(session, condition, orderBy);
        if (events != null && events.length > 0)
            return events[0];
        else
            return null;
    }

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

    public static java.util.Iterator iterateEventByQuery(String condition, String orderBy)
            throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return iterateEventByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static java.util.Iterator iterateEventByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager
                    .instance().getSession();
            return iterateEventByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static java.util.Iterator iterateEventByQuery(PersistentSession session, String condition,
            String orderBy) throws PersistentException {
        StringBuffer sb = new StringBuffer("From es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event as Event");
        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 iterateEventByQuery(PersistentSession session, String condition,
            String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event as Event");
        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("Event", lockMode);
            return query.iterate();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event createEvent() {
        return new es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event();
    }

    public static boolean save(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event event)
            throws PersistentException {
        try {
            es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager.instance().saveObject(event);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean delete(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event event)
            throws PersistentException {
        try {
            es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager.instance().deleteObject(event);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean deleteAndDissociate(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event event)
            throws PersistentException {
        try {
            if (event.getEventType() != null) {
                event.getEventType().event.remove(event);
            }

            if (event.getObjectPath() != null) {
                event.getObjectPath().event.remove(event);
            }

            if (event.getShortcutPath() != null) {
                event.getShortcutPath().event1.remove(event);
            }

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

    public static boolean deleteAndDissociate(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event event,
            org.orm.PersistentSession session) throws PersistentException {
        try {
            if (event.getEventType() != null) {
                event.getEventType().event.remove(event);
            }

            if (event.getObjectPath() != null) {
                event.getObjectPath().event.remove(event);
            }

            if (event.getShortcutPath() != null) {
                event.getShortcutPath().event1.remove(event);
            }

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

    public static boolean refresh(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event event)
            throws PersistentException {
        try {
            es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager.instance().getSession()
                    .refresh(event);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean evict(es.tekniker.eefrmwrk.monitoring.tac.dao.domain.Event event)
            throws PersistentException {
        try {
            es.tekniker.eefrmwrk.monitoring.tac.dao.domain.TACPersistentManager.instance().getSession()
                    .evict(event);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Event loadEventByCriteria(EventCriteria eventCriteria) {
        Event[] events = listEventByCriteria(eventCriteria);
        if (events == null || events.length == 0) {
            return null;
        }
        return events[0];
    }

    public static Event[] listEventByCriteria(EventCriteria eventCriteria) {
        return eventCriteria.listEvent();
    }
}