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 java.rmi.RemoteException; import org.orm.*; import org.hibernate.Query; import java.util.List; public class ClienteDAO { public static Cliente loadClienteByORMID(int ID) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return loadClienteByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(int ID) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return getClienteByORMID(session, ID); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return loadClienteByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.instance().getSession(); return getClienteByORMID(session, ID, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Cliente) session.load(entity.Cliente.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(PersistentSession session, int ID) throws PersistentException { try { return (Cliente) session.get(entity.Cliente.class, new Integer(ID)); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente loadClienteByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Cliente) session.load(entity.Cliente.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente getClienteByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) throws PersistentException { try { return (Cliente) session.get(entity.Cliente.class, new Integer(ID), lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente[] listClienteByQuery(String condition, String orderBy) throws PersistentException { try { PersistentSession session = entity.ProvaSVNPersistentManager.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 = entity.ProvaSVNPersistentManager.instance().getSession(); return listClienteByQuery(session, condition, orderBy, lockMode); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente[] listClienteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entity.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()); List list = query.list(); 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 { StringBuffer sb = new StringBuffer("From entity.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("this", lockMode); List list = query.list(); 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 = entity.ProvaSVNPersistentManager.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 = entity.ProvaSVNPersistentManager.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 = entity.ProvaSVNPersistentManager.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 = entity.ProvaSVNPersistentManager.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 entity.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 entity.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("this", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static Cliente createCliente() throws RemoteException { return new entity.Cliente(); } public static boolean save(entity.Cliente cliente) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().saveObject(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean delete(entity.Cliente cliente) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().deleteObject(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean refresh(entity.Cliente cliente) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().getSession().refresh(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } public static boolean evict(entity.Cliente cliente) throws PersistentException { try { entity.ProvaSVNPersistentManager.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(); } public static boolean update(Cliente cliente) throws PersistentException { try { entity.ProvaSVNPersistentManager.instance().saveObject(cliente); return true; } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } } }