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.LockMode; import org.hibernate.Query; import org.orm.PersistentException; import org.orm.PersistentSession; import orm.OODPersistentManager; public class SpecDAO { public static Spec loadSpecByORMID(int ID) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadSpecByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec getSpecByORMID(int ID) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return getSpecByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec loadSpecByORMID(int ID, LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadSpecByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec getSpecByORMID(int ID, LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return getSpecByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec loadSpecByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Spec) session.load(Spec.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec getSpecByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Spec) session.get(Spec.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec loadSpecByORMID(PersistentSession session, int ID, LockMode lockMode) throws PersistentException { try { return (Spec) session.load(Spec.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec getSpecByORMID(PersistentSession session, int ID, LockMode lockMode) throws PersistentException { try { return (Spec) session.get(Spec.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List querySpec(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return querySpec(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List querySpec(String condition, String orderBy, LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return querySpec(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec[] listSpecByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return listSpecByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec[] listSpecByQuery(String condition, String orderBy, LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return listSpecByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List querySpec(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Spec as Spec"); 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 querySpec(PersistentSession session, String condition, String orderBy, LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Spec as Spec"); 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("Spec", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec[] listSpecByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = querySpec(session, condition, orderBy); return (Spec[]) list.toArray(new Spec[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec[] listSpecByQuery(PersistentSession session, String condition, String orderBy, LockMode lockMode) throws PersistentException { try { List list = querySpec(session, condition, orderBy, lockMode); return (Spec[]) list.toArray(new Spec[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec loadSpecByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadSpecByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec loadSpecByQuery(String condition, String orderBy, LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return loadSpecByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec loadSpecByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Spec[] Specs = listSpecByQuery(session, condition, orderBy); if (Specs != null && Specs.length > 0) return Specs[0]; else return null; } public static Spec loadSpecByQuery(PersistentSession session, String condition, String orderBy, LockMode lockMode) throws PersistentException { Spec[] Specs = listSpecByQuery(session, condition, orderBy, lockMode); if (Specs != null && Specs.length > 0) return Specs[0]; else return null; } public static java.util.Iterator iterateSpecByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return iterateSpecByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateSpecByQuery(String condition, String orderBy, LockMode lockMode) throws PersistentException { try { PersistentSession session = OODPersistentManager.instance().getSession(); return iterateSpecByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateSpecByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Spec as Spec"); 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 iterateSpecByQuery(PersistentSession session, String condition, String orderBy, LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From businesslogic.distribution.resource.Spec as Spec"); 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("Spec", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec createSpec() { return new Spec(); } public static boolean save(Spec Spec) throws PersistentException { try { OODPersistentManager.instance().saveObject(Spec); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(Spec Spec) throws PersistentException { try { OODPersistentManager.instance().deleteObject(Spec); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(Spec Spec) throws PersistentException { try { OODPersistentManager.instance().getSession().refresh(Spec); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(Spec Spec) throws PersistentException { try { OODPersistentManager.instance().getSession().evict(Spec); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Spec loadSpecByCriteria(SpecCriteria specCriteria) { Spec[] Specs = listSpecByCriteria(specCriteria); if (Specs == null || Specs.length == 0) { return null; } return Specs[0]; } public static Spec[] listSpecByCriteria(SpecCriteria specCriteria) { return specCriteria.listSpec(); } }