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 */ import org.orm.*; import org.hibernate.Query; import org.hibernate.LockMode; import java.util.List; public class Proveedor { public Proveedor() { } public static Proveedor loadProveedorByORMID(int ID) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadProveedorByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor getProveedorByORMID(int ID) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return getProveedorByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor loadProveedorByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadProveedorByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor getProveedorByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return getProveedorByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor loadProveedorByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Proveedor) session.load(Proveedor.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor getProveedorByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Proveedor) session.get(Proveedor.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor loadProveedorByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Proveedor) session.load(Proveedor.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor getProveedorByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Proveedor) session.get(Proveedor.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryProveedor(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return queryProveedor(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryProveedor(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return queryProveedor(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor[] listProveedorByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return listProveedorByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor[] listProveedorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return listProveedorByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryProveedor(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From Proveedor as Proveedor"); 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 queryProveedor(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From Proveedor as Proveedor"); 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("Proveedor", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor[] listProveedorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryProveedor(session, condition, orderBy); return (Proveedor[]) list.toArray(new Proveedor[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor[] listProveedorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryProveedor(session, condition, orderBy, lockMode); return (Proveedor[]) list.toArray(new Proveedor[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor loadProveedorByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadProveedorByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor loadProveedorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadProveedorByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor loadProveedorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Proveedor[] proveedors = listProveedorByQuery(session, condition, orderBy); if (proveedors != null && proveedors.length > 0) return proveedors[0]; else return null; } public static Proveedor loadProveedorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Proveedor[] proveedors = listProveedorByQuery(session, condition, orderBy, lockMode); if (proveedors != null && proveedors.length > 0) return proveedors[0]; else return null; } public static java.util.Iterator iterateProveedorByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return iterateProveedorByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateProveedorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return iterateProveedorByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateProveedorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From Proveedor as Proveedor"); 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 iterateProveedorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From Proveedor as Proveedor"); 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("Proveedor", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Proveedor loadProveedorByCriteria(ProveedorCriteria proveedorCriteria) { Proveedor[] proveedors = listProveedorByCriteria(proveedorCriteria); if (proveedors == null || proveedors.length == 0) { return null; } return proveedors[0]; } public static Proveedor[] listProveedorByCriteria(ProveedorCriteria proveedorCriteria) { return proveedorCriteria.listProveedor(); } public static Proveedor createProveedor() { return new Proveedor(); } public boolean save() throws PersistentException { try { GestinEconmicaConstructoraPersistentManager.instance().saveObject(this); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean delete() throws PersistentException { try { GestinEconmicaConstructoraPersistentManager.instance().deleteObject(this); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean refresh() throws PersistentException { try { GestinEconmicaConstructoraPersistentManager.instance().getSession().refresh(this); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean evict() throws PersistentException { try { GestinEconmicaConstructoraPersistentManager.instance().getSession().evict(this); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean deleteAndDissociate() throws PersistentException { try { Persona[] lContactos = contacto.toArray(); for (int i = 0; i < lContactos.length; i++) { lContactos[i].proveedor.remove(this); } Albaran[] lAlbarans = albaran.toArray(); for (int i = 0; i < lAlbarans.length; i++) { lAlbarans[i].setProveedor(null); } return delete(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean deleteAndDissociate(org.orm.PersistentSession session) throws PersistentException { try { Persona[] lContactos = contacto.toArray(); for (int i = 0; i < lContactos.length; i++) { lContactos[i].proveedor.remove(this); } Albaran[] lAlbarans = albaran.toArray(); for (int i = 0; i < lAlbarans.length; i++) { lAlbarans[i].setProveedor(null); } try { session.delete(this); return true; } catch (Exception e) { return false; } } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } private java.util.Set this_getSet(int key) { if (key == ORMConstants.KEY_PROVEEDOR_CONTACTO) { return ORM_contacto; } else if (key == ORMConstants.KEY_PROVEEDOR_ALBARAN) { return ORM_albaran; } return null; } org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() { public java.util.Set getSet(int key) { return this_getSet(key); } }; private int ID; private String nombre; private String direccion; private java.util.Set ORM_contacto = new java.util.HashSet(); private java.util.Set ORM_albaran = new java.util.HashSet(); private void setID(int value) { this.ID = value; } public int getID() { return ID; } public int getORMID() { return getID(); } public void setNombre(String value) { this.nombre = value; } public String getNombre() { return nombre; } public void setDireccion(String value) { this.direccion = value; } public String getDireccion() { return direccion; } private void setORM_Contacto(java.util.Set value) { this.ORM_contacto = value; } private java.util.Set getORM_Contacto() { return ORM_contacto; } public final PersonaSetCollection contacto = new PersonaSetCollection(this, _ormAdapter, ORMConstants.KEY_PROVEEDOR_CONTACTO, ORMConstants.KEY_PERSONA_PROVEEDOR, ORMConstants.KEY_MUL_MANY_TO_MANY); private void setORM_Albaran(java.util.Set value) { this.ORM_albaran = value; } private java.util.Set getORM_Albaran() { return ORM_albaran; } public final AlbaranSetCollection albaran = new AlbaranSetCollection(this, _ormAdapter, ORMConstants.KEY_PROVEEDOR_ALBARAN, ORMConstants.KEY_ALBARAN_PROVEEDOR, ORMConstants.KEY_MUL_ONE_TO_MANY); public String toString() { return String.valueOf(getID()); } }