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 PhysicalResourceDAO { public static PhysicalResource loadPhysicalResourceByORMID(int ID) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadPhysicalResourceByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource getPhysicalResourceByORMID(int ID) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return getPhysicalResourceByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource loadPhysicalResourceByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadPhysicalResourceByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource getPhysicalResourceByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return getPhysicalResourceByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource loadPhysicalResourceByORMID(PersistentSession session, int ID) throws PersistentException { try { return (PhysicalResource) session.load(businesslogic.distribution.resource.PhysicalResource.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource getPhysicalResourceByORMID(PersistentSession session, int ID) throws PersistentException { try { return (PhysicalResource) session.get(businesslogic.distribution.resource.PhysicalResource.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource loadPhysicalResourceByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (PhysicalResource) session.load(businesslogic.distribution.resource.PhysicalResource.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource getPhysicalResourceByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (PhysicalResource) session.get(businesslogic.distribution.resource.PhysicalResource.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryPhysicalResource(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return queryPhysicalResource(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryPhysicalResource(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return queryPhysicalResource(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource[] listPhysicalResourceByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return listPhysicalResourceByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource[] listPhysicalResourceByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return listPhysicalResourceByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryPhysicalResource(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer( "From businesslogic.distribution.resource.PhysicalResource as PhysicalResource"); 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 queryPhysicalResource(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer( "From businesslogic.distribution.resource.PhysicalResource as PhysicalResource"); 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("PhysicalResource", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource[] listPhysicalResourceByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryPhysicalResource(session, condition, orderBy); return (PhysicalResource[]) list.toArray(new PhysicalResource[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource[] listPhysicalResourceByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryPhysicalResource(session, condition, orderBy, lockMode); return (PhysicalResource[]) list.toArray(new PhysicalResource[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource loadPhysicalResourceByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadPhysicalResourceByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource loadPhysicalResourceByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadPhysicalResourceByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource loadPhysicalResourceByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { PhysicalResource[] physicalResources = listPhysicalResourceByQuery(session, condition, orderBy); if (physicalResources != null && physicalResources.length > 0) return physicalResources[0]; else return null; } public static PhysicalResource loadPhysicalResourceByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { PhysicalResource[] physicalResources = listPhysicalResourceByQuery(session, condition, orderBy, lockMode); if (physicalResources != null && physicalResources.length > 0) return physicalResources[0]; else return null; } public static java.util.Iterator iteratePhysicalResourceByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return iteratePhysicalResourceByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iteratePhysicalResourceByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return iteratePhysicalResourceByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iteratePhysicalResourceByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer( "From businesslogic.distribution.resource.PhysicalResource as PhysicalResource"); 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 iteratePhysicalResourceByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer( "From businesslogic.distribution.resource.PhysicalResource as PhysicalResource"); 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("PhysicalResource", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource createPhysicalResource() { return new businesslogic.distribution.resource.PhysicalResource(); } public static boolean save(businesslogic.distribution.resource.PhysicalResource physicalResource) throws PersistentException { try { OODPersistentManager.instance().saveObject(physicalResource); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(businesslogic.distribution.resource.PhysicalResource physicalResource) throws PersistentException { try { OODPersistentManager.instance().deleteObject(physicalResource); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(businesslogic.distribution.resource.PhysicalResource physicalResource) throws PersistentException { try { OODPersistentManager.instance().getSession().refresh(physicalResource); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(businesslogic.distribution.resource.PhysicalResource physicalResource) throws PersistentException { try { OODPersistentManager.instance().getSession().evict(physicalResource); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static PhysicalResource loadPhysicalResourceByCriteria( PhysicalResourceCriteria physicalResourceCriteria) { PhysicalResource[] physicalResources = listPhysicalResourceByCriteria(physicalResourceCriteria); if (physicalResources == null || physicalResources.length == 0) { return null; } return physicalResources[0]; } public static PhysicalResource[] listPhysicalResourceByCriteria( PhysicalResourceCriteria physicalResourceCriteria) { return physicalResourceCriteria.listPhysicalResource(); } }