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 Empleado extends Persona { public Empleado() { } public static Empleado loadEmpleadoByORMID(int ID) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadEmpleadoByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado getEmpleadoByORMID(int ID) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return getEmpleadoByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado loadEmpleadoByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadEmpleadoByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado getEmpleadoByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return getEmpleadoByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado loadEmpleadoByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Empleado) session.load(Empleado.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado getEmpleadoByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Empleado) session.get(Empleado.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado loadEmpleadoByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Empleado) session.load(Empleado.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado getEmpleadoByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Empleado) session.get(Empleado.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryEmpleado(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return queryEmpleado(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryEmpleado(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return queryEmpleado(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado[] listEmpleadoByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return listEmpleadoByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado[] listEmpleadoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return listEmpleadoByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryEmpleado(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From Empleado as Empleado"); 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 queryEmpleado(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From Empleado as Empleado"); 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("Empleado", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado[] listEmpleadoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryEmpleado(session, condition, orderBy); return (Empleado[]) list.toArray(new Empleado[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado[] listEmpleadoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryEmpleado(session, condition, orderBy, lockMode); return (Empleado[]) list.toArray(new Empleado[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado loadEmpleadoByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadEmpleadoByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado loadEmpleadoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return loadEmpleadoByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado loadEmpleadoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Empleado[] empleados = listEmpleadoByQuery(session, condition, orderBy); if (empleados != null && empleados.length > 0) return empleados[0]; else return null; } public static Empleado loadEmpleadoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Empleado[] empleados = listEmpleadoByQuery(session, condition, orderBy, lockMode); if (empleados != null && empleados.length > 0) return empleados[0]; else return null; } public static java.util.Iterator iterateEmpleadoByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return iterateEmpleadoByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateEmpleadoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = GestinEconmicaConstructoraPersistentManager.instance().getSession(); return iterateEmpleadoByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateEmpleadoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From Empleado as Empleado"); 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 iterateEmpleadoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From Empleado as Empleado"); 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("Empleado", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Empleado loadEmpleadoByCriteria(EmpleadoCriteria empleadoCriteria) { Empleado[] empleados = listEmpleadoByCriteria(empleadoCriteria); if (empleados == null || empleados.length == 0) { return null; } return empleados[0]; } public static Empleado[] listEmpleadoByCriteria(EmpleadoCriteria empleadoCriteria) { return empleadoCriteria.listEmpleado(); } public static Empleado createEmpleado() { return new Empleado(); } public boolean deleteAndDissociate() throws PersistentException { try { if (getCategoria() != null) { getCategoria().empleado.remove(this); } Proveedor[] lProveedors = proveedor.toArray(); for (int i = 0; i < lProveedors.length; i++) { lProveedors[i].contacto.remove(this); } return delete(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public boolean deleteAndDissociate(org.orm.PersistentSession session) throws PersistentException { try { if (getCategoria() != null) { getCategoria().empleado.remove(this); } Proveedor[] lProveedors = proveedor.toArray(); for (int i = 0; i < lProveedors.length; i++) { lProveedors[i].contacto.remove(this); } try { session.delete(this); return true; } catch (Exception e) { return false; } } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } private void this_setOwner(Object owner, int key) { if (key == ORMConstants.KEY_EMPLEADO_CATEGORIA) { this.categoria = (Categoria) owner; } } org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() { public void setOwner(Object owner, int key) { this_setOwner(owner, key); } }; private Categoria categoria; private String usuario; private String contra; public void setUsuario(String value) { this.usuario = value; } public String getUsuario() { return usuario; } public void setContra(String value) { this.contra = value; } public String getContra() { return contra; } public void setCategoria(Categoria value) { if (categoria != null) { categoria.empleado.remove(this); } if (value != null) { value.empleado.add(this); } } public Categoria getCategoria() { return categoria; } /** * This method is for internal use only. */ private void setORM_Categoria(Categoria value) { this.categoria = value; } private Categoria getORM_Categoria() { return categoria; } public String toString() { return super.toString(); } }