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 com.coedil99.modello_di_dominio.impl; import com.coedil99.modello_di_dominio.Commessa; import com.coedil99.modello_di_dominio.CommessaCriteria; import org.hibernate.Query; import org.orm.PersistentException; import org.orm.PersistentSession; import java.util.List; public class CommessaDAOImpl implements com.coedil99.modello_di_dominio.dao.CommessaDAO { public Commessa loadCommessaByORMID(int ID) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return loadCommessaByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa getCommessaByORMID(int ID) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return getCommessaByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa loadCommessaByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return loadCommessaByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa getCommessaByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return getCommessaByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa loadCommessaByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Commessa) session.load(com.coedil99.modello_di_dominio.Commessa.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa getCommessaByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Commessa) session.get(com.coedil99.modello_di_dominio.Commessa.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa loadCommessaByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Commessa) session.load(com.coedil99.modello_di_dominio.Commessa.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa getCommessaByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Commessa) session.get(com.coedil99.modello_di_dominio.Commessa.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public List queryCommessa(String condition, String orderBy) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return queryCommessa(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public List queryCommessa(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return queryCommessa(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa[] listCommessaByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return listCommessaByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa[] listCommessaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return listCommessaByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public List queryCommessa(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From com.coedil99.modello_di_dominio.Commessa as Commessa"); 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 List queryCommessa(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From com.coedil99.modello_di_dominio.Commessa as Commessa"); 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("Commessa", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa[] listCommessaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryCommessa(session, condition, orderBy); return (Commessa[]) list.toArray(new Commessa[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa[] listCommessaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryCommessa(session, condition, orderBy, lockMode); return (Commessa[]) list.toArray(new Commessa[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa loadCommessaByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return loadCommessaByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa loadCommessaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return loadCommessaByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa loadCommessaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Commessa[] commessas = listCommessaByQuery(session, condition, orderBy); if (commessas != null && commessas.length > 0) return commessas[0]; else return null; } public Commessa loadCommessaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Commessa[] commessas = listCommessaByQuery(session, condition, orderBy, lockMode); if (commessas != null && commessas.length > 0) return commessas[0]; else return null; } public java.util.Iterator iterateCommessaByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return iterateCommessaByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public java.util.Iterator iterateCommessaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance() .getSession(); return iterateCommessaByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public java.util.Iterator iterateCommessaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From com.coedil99.modello_di_dominio.Commessa as Commessa"); 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 java.util.Iterator iterateCommessaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From com.coedil99.modello_di_dominio.Commessa as Commessa"); 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("Commessa", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa createCommessa() { return new com.coedil99.modello_di_dominio.Commessa(); } public boolean save(com.coedil99.modello_di_dominio.Commessa commessa) throws PersistentException { try { com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance().saveObject(commessa); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean delete(com.coedil99.modello_di_dominio.Commessa commessa) throws PersistentException { try { com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance().deleteObject(commessa); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean deleteAndDissociate(com.coedil99.modello_di_dominio.Commessa commessa) throws PersistentException { try { if (commessa.getOrdine() != null) { commessa.getOrdine().commesse.remove(commessa); } if (commessa.getDistinta() != null) { commessa.getDistinta().setCommessa(null); } return delete(commessa); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean deleteAndDissociate(com.coedil99.modello_di_dominio.Commessa commessa, org.orm.PersistentSession session) throws PersistentException { try { if (commessa.getOrdine() != null) { commessa.getOrdine().commesse.remove(commessa); } if (commessa.getDistinta() != null) { commessa.getDistinta().setCommessa(null); } try { session.delete(commessa); return true; } catch (Exception e) { return false; } } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean refresh(com.coedil99.modello_di_dominio.Commessa commessa) throws PersistentException { try { com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance().getSession().refresh(commessa); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean evict(com.coedil99.modello_di_dominio.Commessa commessa) throws PersistentException { try { com.coedil99.modello_di_dominio.Coedil99PersistentManager.instance().getSession().evict(commessa); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public Commessa loadCommessaByCriteria(CommessaCriteria commessaCriteria) { Commessa[] commessas = listCommessaByCriteria(commessaCriteria); if (commessas == null || commessas.length == 0) { return null; } return commessas[0]; } public Commessa[] listCommessaByCriteria(CommessaCriteria commessaCriteria) { return commessaCriteria.listCommessa(); } }