Java tutorial
/** * "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 ProjectDAO { public static Project loadProjectByORMID(int ID) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadProjectByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project getProjectByORMID(int ID) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return getProjectByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project loadProjectByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadProjectByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project getProjectByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return getProjectByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project loadProjectByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Project) session.load(businesslogic.distribution.resource.Project.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project getProjectByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Project) session.get(businesslogic.distribution.resource.Project.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project loadProjectByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Project) session.load(businesslogic.distribution.resource.Project.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project getProjectByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Project) session.get(businesslogic.distribution.resource.Project.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryProject(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return queryProject(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryProject(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return queryProject(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project[] listProjectByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return listProjectByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project[] listProjectByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return listProjectByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryProject(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Project as Project"); 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 queryProject(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Project as Project"); 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("Project", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project[] listProjectByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryProject(session, condition, orderBy); return (Project[]) list.toArray(new Project[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project[] listProjectByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryProject(session, condition, orderBy, lockMode); return (Project[]) list.toArray(new Project[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project loadProjectByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadProjectByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project loadProjectByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadProjectByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project loadProjectByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Project[] projects = listProjectByQuery(session, condition, orderBy); if (projects != null && projects.length > 0) return projects[0]; else return null; } public static Project loadProjectByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Project[] projects = listProjectByQuery(session, condition, orderBy, lockMode); if (projects != null && projects.length > 0) return projects[0]; else return null; } public static java.util.Iterator iterateProjectByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return iterateProjectByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateProjectByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return iterateProjectByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateProjectByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Project as Project"); 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 iterateProjectByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Project as Project"); 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("Project", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project createProject() { return new businesslogic.distribution.resource.Project(); } public static boolean save(businesslogic.distribution.resource.Project project) throws PersistentException { try { OODPersistentManager.instance().saveObject(project); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(businesslogic.distribution.resource.Project project) throws PersistentException { try { OODPersistentManager.instance().deleteObject(project); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(businesslogic.distribution.resource.Project project) throws PersistentException { try { if (project.getProjectManagement() != null) { project.getProjectManagement().informationResources.remove(project); } return delete(project); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(businesslogic.distribution.resource.Project project, org.orm.PersistentSession session) throws PersistentException { try { if (project.getProjectManagement() != null) { project.getProjectManagement().informationResources.remove(project); } try { session.delete(project); return true; } catch (Exception e) { return false; } } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(businesslogic.distribution.resource.Project project) throws PersistentException { try { OODPersistentManager.instance().getSession().refresh(project); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(businesslogic.distribution.resource.Project project) throws PersistentException { try { OODPersistentManager.instance().getSession().evict(project); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Project loadProjectByCriteria(ProjectCriteria projectCriteria) { Project[] projects = listProjectByCriteria(projectCriteria); if (projects == null || projects.length == 0) { return null; } return projects[0]; } public static Project[] listProjectByCriteria(ProjectCriteria projectCriteria) { return projectCriteria.listProject(); } }