businesslogic.distribution.resource.SubsystemDAO.java Source code

Java tutorial

Introduction

Here is the source code for businesslogic.distribution.resource.SubsystemDAO.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: 
 * License Type: Evaluation
 */
package businesslogic.distribution.resource;

import java.util.List;

import org.hibernate.Query;
import org.orm.PersistentException;
import org.orm.PersistentSession;

import orm.OODPersistentManager;

public class SubsystemDAO {
    public static Subsystem loadSubsystemByORMID(int ID) throws PersistentException {
        try {
            PersistentSession session = OODPersistentManager.instance().getSession();
            return loadSubsystemByORMID(session, ID);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Subsystem getSubsystemByORMID(int ID) throws PersistentException {
        try {
            PersistentSession session = OODPersistentManager.instance().getSession();
            return getSubsystemByORMID(session, ID);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

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

    public static Subsystem loadSubsystemByORMID(PersistentSession session, int ID) throws PersistentException {
        try {
            return (Subsystem) session.load(businesslogic.distribution.resource.Subsystem.class, new Integer(ID));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Subsystem getSubsystemByORMID(PersistentSession session, int ID) throws PersistentException {
        try {
            return (Subsystem) session.get(businesslogic.distribution.resource.Subsystem.class, new Integer(ID));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Subsystem loadSubsystemByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Subsystem) session.load(businesslogic.distribution.resource.Subsystem.class, new Integer(ID),
                    lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Subsystem getSubsystemByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (Subsystem) session.get(businesslogic.distribution.resource.Subsystem.class, new Integer(ID),
                    lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

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

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

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

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

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

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

    public static Subsystem loadSubsystemByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = OODPersistentManager.instance().getSession();
            return loadSubsystemByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

    public static Subsystem loadSubsystemByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        Subsystem[] subsystems = listSubsystemByQuery(session, condition, orderBy);
        if (subsystems != null && subsystems.length > 0)
            return subsystems[0];
        else
            return null;
    }

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

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

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

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

    public static Subsystem createSubsystem() {
        return new businesslogic.distribution.resource.Subsystem();
    }

    public static boolean save(businesslogic.distribution.resource.Subsystem subsystem) throws PersistentException {
        try {
            OODPersistentManager.instance().saveObject(subsystem);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean delete(businesslogic.distribution.resource.Subsystem subsystem)
            throws PersistentException {
        try {
            OODPersistentManager.instance().deleteObject(subsystem);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean deleteAndDissociate(businesslogic.distribution.resource.Subsystem subsystem)
            throws PersistentException {
        try {
            if (subsystem.getProjectManagement() != null) {
                subsystem.getProjectManagement().informationResources.remove(subsystem);
            }

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

    public static boolean deleteAndDissociate(businesslogic.distribution.resource.Subsystem subsystem,
            org.orm.PersistentSession session) throws PersistentException {
        try {
            if (subsystem.getProjectManagement() != null) {
                subsystem.getProjectManagement().informationResources.remove(subsystem);
            }

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

    public static boolean refresh(businesslogic.distribution.resource.Subsystem subsystem)
            throws PersistentException {
        try {
            OODPersistentManager.instance().getSession().refresh(subsystem);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean evict(businesslogic.distribution.resource.Subsystem subsystem)
            throws PersistentException {
        try {
            OODPersistentManager.instance().getSession().evict(subsystem);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Subsystem loadSubsystemByCriteria(SubsystemCriteria subsystemCriteria) {
        Subsystem[] subsystems = listSubsystemByCriteria(subsystemCriteria);
        if (subsystems == null || subsystems.length == 0) {
            return null;
        }
        return subsystems[0];
    }

    public static Subsystem[] listSubsystemByCriteria(SubsystemCriteria subsystemCriteria) {
        return subsystemCriteria.listSubsystem();
    }
}