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: DuKe TeAm * License Type: Purchased */ package entity; import org.orm.*; import org.hibernate.Query; import java.util.List; public class FornitoreDAO { public static Fornitore loadFornitoreByORMID(int ID) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return loadFornitoreByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore getFornitoreByORMID(int ID) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return getFornitoreByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore loadFornitoreByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return loadFornitoreByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore getFornitoreByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return getFornitoreByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore loadFornitoreByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Fornitore) session.load(entity.Fornitore.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore getFornitoreByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Fornitore) session.get(entity.Fornitore.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore loadFornitoreByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Fornitore) session.load(entity.Fornitore.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore getFornitoreByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Fornitore) session.get(entity.Fornitore.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore[] listFornitoreByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return listFornitoreByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore[] listFornitoreByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return listFornitoreByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore[] listFornitoreByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entity.Fornitore as Fornitore"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try { Query query = session.createQuery(sb.toString()); List list = query.list(); return (Fornitore[]) list.toArray(new Fornitore[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore[] listFornitoreByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From entity.Fornitore as Fornitore"); 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("this", lockMode); List list = query.list(); return (Fornitore[]) list.toArray(new Fornitore[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore loadFornitoreByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return loadFornitoreByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore loadFornitoreByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return loadFornitoreByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore loadFornitoreByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Fornitore[] fornitores = listFornitoreByQuery(session, condition, orderBy); if (fornitores != null && fornitores.length > 0) return fornitores[0]; else return null; } public static Fornitore loadFornitoreByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Fornitore[] fornitores = listFornitoreByQuery(session, condition, orderBy, lockMode); if (fornitores != null && fornitores.length > 0) return fornitores[0]; else return null; } public static java.util.Iterator iterateFornitoreByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return iterateFornitoreByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateFornitoreByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return iterateFornitoreByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateFornitoreByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entity.Fornitore as Fornitore"); 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 iterateFornitoreByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From entity.Fornitore as Fornitore"); 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("this", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore createFornitore() { return new entity.Fornitore(); } public static boolean save(entity.Fornitore fornitore) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().saveObject(fornitore); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(entity.Fornitore fornitore) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().deleteObject(fornitore); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(entity.Fornitore fornitore) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().getSession().refresh(fornitore); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(entity.Fornitore fornitore) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().getSession().evict(fornitore); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Fornitore loadFornitoreByCriteria(FornitoreCriteria fornitoreCriteria) { Fornitore[] fornitores = listFornitoreByCriteria(fornitoreCriteria); if (fornitores == null || fornitores.length == 0) { return null; } return fornitores[0]; } public static Fornitore[] listFornitoreByCriteria(FornitoreCriteria fornitoreCriteria) { return fornitoreCriteria.listFornitore(); } }