model.Director2DAO.java Source code

Java tutorial

Introduction

Here is the source code for model.Director2DAO.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: Universidad de La Frontera
 * License Type: Academic
 */
package model;

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

public class Director2DAO {
    public static Director2 loadDirector2ByORMID(int id) throws PersistentException {
        try {
            PersistentSession session = model.PDSTallerPersistentManager.instance().getSession();
            return loadDirector2ByORMID(session, id);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 getDirector2ByORMID(int id) throws PersistentException {
        try {
            PersistentSession session = model.PDSTallerPersistentManager.instance().getSession();
            return getDirector2ByORMID(session, id);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 loadDirector2ByORMID(int id, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = model.PDSTallerPersistentManager.instance().getSession();
            return loadDirector2ByORMID(session, id, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 getDirector2ByORMID(int id, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = model.PDSTallerPersistentManager.instance().getSession();
            return getDirector2ByORMID(session, id, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 loadDirector2ByORMID(PersistentSession session, int id) throws PersistentException {
        try {
            return (Director2) session.load(model.Director2.class, new Integer(id));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 getDirector2ByORMID(PersistentSession session, int id) throws PersistentException {
        try {
            return (Director2) session.get(model.Director2.class, new Integer(id));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 loadDirector2ByORMID(PersistentSession session, int id, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Director2) session.load(model.Director2.class, new Integer(id), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 getDirector2ByORMID(PersistentSession session, int id, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Director2) session.get(model.Director2.class, new Integer(id), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

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

    public static Director2[] listDirector2ByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = model.PDSTallerPersistentManager.instance().getSession();
            return listDirector2ByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

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

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

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

    public static Director2 loadDirector2ByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = model.PDSTallerPersistentManager.instance().getSession();
            return loadDirector2ByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 loadDirector2ByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = model.PDSTallerPersistentManager.instance().getSession();
            return loadDirector2ByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 loadDirector2ByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        Director2[] director2s = listDirector2ByQuery(session, condition, orderBy);
        if (director2s != null && director2s.length > 0)
            return director2s[0];
        else
            return null;
    }

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

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

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

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

    public static Director2 createDirector2() {
        return new model.Director2();
    }

    public static boolean save(model.Director2 director2) throws PersistentException {
        try {
            model.PDSTallerPersistentManager.instance().saveObject(director2);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean delete(model.Director2 director2) throws PersistentException {
        try {
            model.PDSTallerPersistentManager.instance().deleteObject(director2);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean deleteAndDissociate(model.Director2 director2) throws PersistentException {
        try {
            if (director2.getPersona() != null) {
                director2.getPersona().setDirector2(null);
            }

            if (director2.getReporte2() != null) {
                director2.getReporte2().setDirector(null);
            }

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

    public static boolean deleteAndDissociate(model.Director2 director2, org.orm.PersistentSession session)
            throws PersistentException {
        try {
            if (director2.getPersona() != null) {
                director2.getPersona().setDirector2(null);
            }

            if (director2.getReporte2() != null) {
                director2.getReporte2().setDirector(null);
            }

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

    public static boolean refresh(model.Director2 director2) throws PersistentException {
        try {
            model.PDSTallerPersistentManager.instance().getSession().refresh(director2);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean evict(model.Director2 director2) throws PersistentException {
        try {
            model.PDSTallerPersistentManager.instance().getSession().evict(director2);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Director2 loadDirector2ByCriteria(Director2Criteria director2Criteria) {
        Director2[] director2s = listDirector2ByCriteria(director2Criteria);
        if (director2s == null || director2s.length == 0) {
            return null;
        }
        return director2s[0];
    }

    public static Director2[] listDirector2ByCriteria(Director2Criteria director2Criteria) {
        return director2Criteria.listDirector2();
    }
}