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: University of Almeria * License Type: Academic */ package diagrama_bd.base_de_datos; import org.orm.*; import org.hibernate.Query; import org.hibernate.LockMode; import java.util.List; public class ClienteDAO { public static Cliente loadClienteByORMID(int nCliente) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadClienteByORMID(session, nCliente); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(int nCliente) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getClienteByORMID(session, nCliente); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByORMID(int nCliente, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadClienteByORMID(session, nCliente, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(int nCliente, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return getClienteByORMID(session, nCliente, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByORMID(PersistentSession session, int nCliente) throws PersistentException { try { return (Cliente) session.load(diagrama_bd.base_de_datos.Cliente.class, new Integer(nCliente)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(PersistentSession session, int nCliente) throws PersistentException { try { return (Cliente) session.get(diagrama_bd.base_de_datos.Cliente.class, new Integer(nCliente)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByORMID(PersistentSession session, int nCliente, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Cliente) session.load(diagrama_bd.base_de_datos.Cliente.class, new Integer(nCliente), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(PersistentSession session, int nCliente, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Cliente) session.get(diagrama_bd.base_de_datos.Cliente.class, new Integer(nCliente), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryCliente(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryCliente(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryCliente(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return queryCliente(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente[] listClienteByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listClienteByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente[] listClienteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return listClienteByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static List queryCliente(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Cliente as Cliente"); 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 queryCliente(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Cliente as Cliente"); 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("Cliente", lockMode); return query.list(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente[] listClienteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { try { List list = queryCliente(session, condition, orderBy); return (Cliente[]) list.toArray(new Cliente[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente[] listClienteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { List list = queryCliente(session, condition, orderBy, lockMode); return (Cliente[]) list.toArray(new Cliente[list.size()]); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadClienteByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return loadClienteByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { Cliente[] clientes = listClienteByQuery(session, condition, orderBy); if (clientes != null && clientes.length > 0) return clientes[0]; else return null; } public static Cliente loadClienteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { Cliente[] clientes = listClienteByQuery(session, condition, orderBy, lockMode); if (clientes != null && clientes.length > 0) return clientes[0]; else return null; } public static java.util.Iterator iterateClienteByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateClienteByQuery(session, condition, orderBy); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateClienteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager .instance().getSession(); return iterateClienteByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static java.util.Iterator iterateClienteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Cliente as Cliente"); 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 iterateClienteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From diagrama_bd.base_de_datos.Cliente as Cliente"); 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("Cliente", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente createCliente() { return new diagrama_bd.base_de_datos.Cliente(); } public static boolean save(diagrama_bd.base_de_datos.Cliente cliente) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().saveObject(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(diagrama_bd.base_de_datos.Cliente cliente) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().deleteObject(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Cliente cliente) throws PersistentException { try { diagrama_bd.base_de_datos.Terminales[] lTerminalesss = cliente.terminaless.toArray(); for (int i = 0; i < lTerminalesss.length; i++) { lTerminalesss[i].setCliente(null); } diagrama_bd.base_de_datos.Incidencia[] lReclamas = cliente.reclama.toArray(); for (int i = 0; i < lReclamas.length; i++) { lReclamas[i].setReclamada_por(null); } return delete(cliente); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean deleteAndDissociate(diagrama_bd.base_de_datos.Cliente cliente, org.orm.PersistentSession session) throws PersistentException { try { diagrama_bd.base_de_datos.Terminales[] lTerminalesss = cliente.terminaless.toArray(); for (int i = 0; i < lTerminalesss.length; i++) { lTerminalesss[i].setCliente(null); } diagrama_bd.base_de_datos.Incidencia[] lReclamas = cliente.reclama.toArray(); for (int i = 0; i < lReclamas.length; i++) { lReclamas[i].setReclamada_por(null); } try { session.delete(cliente); return true; } catch (Exception e) { return false; } } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(diagrama_bd.base_de_datos.Cliente cliente) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .refresh(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(diagrama_bd.base_de_datos.Cliente cliente) throws PersistentException { try { diagrama_bd.base_de_datos.ProyectoCompletoIluminatiPersistentManager.instance().getSession() .evict(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByCriteria(ClienteCriteria clienteCriteria) { Cliente[] clientes = listClienteByCriteria(clienteCriteria); if (clientes == null || clientes.length == 0) { return null; } return clientes[0]; } public static Cliente[] listClienteByCriteria(ClienteCriteria clienteCriteria) { return clienteCriteria.listCliente(); } }