Package orm.impl

Source Code of orm.impl.ComunaDAOImpl

/**
* "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 orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class ComunaDAOImpl implements orm.dao.ComunaDAO {
  private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(ComunaDAOImpl.class);
  public Comuna loadComunaByORMID(int comuna_id) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadComunaByORMID(session, comuna_id);
    }
    catch (Exception e) {
      _logger.error("loadComunaByORMID(int comuna_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna getComunaByORMID(int comuna_id) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return getComunaByORMID(session, comuna_id);
    }
    catch (Exception e) {
      _logger.error("getComunaByORMID(int comuna_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna loadComunaByORMID(int comuna_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadComunaByORMID(session, comuna_id, lockMode);
    }
    catch (Exception e) {
      _logger.error("loadComunaByORMID(int comuna_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna getComunaByORMID(int comuna_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return getComunaByORMID(session, comuna_id, lockMode);
    }
    catch (Exception e) {
      _logger.error("getComunaByORMID(int comuna_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna loadComunaByORMID(PersistentSession session, int comuna_id) throws PersistentException {
    try {
      return (Comuna) session.load(orm.Comuna.class, new Integer(comuna_id));
    }
    catch (Exception e) {
      _logger.error("loadComunaByORMID(PersistentSession session, int comuna_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna getComunaByORMID(PersistentSession session, int comuna_id) throws PersistentException {
    try {
      return (Comuna) session.get(orm.Comuna.class, new Integer(comuna_id));
    }
    catch (Exception e) {
      _logger.error("getComunaByORMID(PersistentSession session, int comuna_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna loadComunaByORMID(PersistentSession session, int comuna_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      return (Comuna) session.load(orm.Comuna.class, new Integer(comuna_id), lockMode);
    }
    catch (Exception e) {
      _logger.error("loadComunaByORMID(PersistentSession session, int comuna_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna getComunaByORMID(PersistentSession session, int comuna_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      return (Comuna) session.get(orm.Comuna.class, new Integer(comuna_id), lockMode);
    }
    catch (Exception e) {
      _logger.error("getComunaByORMID(PersistentSession session, int comuna_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna[] listComunaByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return listComunaByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("listComunaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna[] listComunaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return listComunaByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("listComunaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna[] listComunaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Comuna as Comuna");
    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 (Comuna[]) list.toArray(new Comuna[list.size()]);
    }
    catch (Exception e) {
      _logger.error("listComunaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna[] listComunaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Comuna as Comuna");
    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 (Comuna[]) list.toArray(new Comuna[list.size()]);
    }
    catch (Exception e) {
      _logger.error("listComunaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna loadComunaByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadComunaByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("loadComunaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna loadComunaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadComunaByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("loadComunaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna loadComunaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    Comuna[] comunas = listComunaByQuery(session, condition, orderBy);
    if (comunas != null && comunas.length > 0)
      return comunas[0];
    else
      return null;
  }
 
  public Comuna loadComunaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    Comuna[] comunas = listComunaByQuery(session, condition, orderBy, lockMode);
    if (comunas != null && comunas.length > 0)
      return comunas[0];
    else
      return null;
  }
 
  public static java.util.Iterator iterateComunaByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return iterateComunaByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("iterateComunaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateComunaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return iterateComunaByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("iterateComunaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateComunaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Comuna as Comuna");
    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) {
      _logger.error("iterateComunaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateComunaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Comuna as Comuna");
    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) {
      _logger.error("iterateComunaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna createComuna() {
    return new orm.Comuna();
  }
 
  public boolean save(orm.Comuna comuna) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().saveObject(comuna);
      return true;
    }
    catch (Exception e) {
      _logger.error("save(orm.Comuna comuna)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean delete(orm.Comuna comuna) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().deleteObject(comuna);
      return true;
    }
    catch (Exception e) {
      _logger.error("delete(orm.Comuna comuna)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean deleteAndDissociate(orm.Comuna comuna)throws PersistentException {
    try {
      if(comuna.getComuna_provincia() != null) {
        comuna.getComuna_provincia().comuna.remove(comuna);
      }
     
      orm.Establecimiento[] lEstablecimientos = comuna.establecimiento.toArray();
      for(int i = 0; i < lEstablecimientos.length; i++) {
        lEstablecimientos[i].setEstablecimiento_comuna(null);
      }
      return delete(comuna);
    }
    catch(Exception e) {
      _logger.error("deleteAndDissociate()", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean deleteAndDissociate(orm.Comuna comuna, org.orm.PersistentSession session)throws PersistentException {
    try {
      if(comuna.getComuna_provincia() != null) {
        comuna.getComuna_provincia().comuna.remove(comuna);
      }
     
      orm.Establecimiento[] lEstablecimientos = comuna.establecimiento.toArray();
      for(int i = 0; i < lEstablecimientos.length; i++) {
        lEstablecimientos[i].setEstablecimiento_comuna(null);
      }
      try {
        session.delete(comuna);
        return true;
      } catch (Exception e) {
        return false;
      }
    }
    catch(Exception e) {
      _logger.error("deleteAndDissociate()", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean refresh(orm.Comuna comuna) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().getSession().refresh(comuna);
      return true;
    }
    catch (Exception e) {
      _logger.error("refresh(orm.Comuna comuna)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean evict(orm.Comuna comuna) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().getSession().evict(comuna);
      return true;
    }
    catch (Exception e) {
      _logger.error("evict(orm.Comuna comuna)", e);
      throw new PersistentException(e);
    }
  }
 
  public Comuna loadComunaByCriteria(ComunaCriteria comunaCriteria) {
    Comuna[] comunas = listComunaByCriteria(comunaCriteria);
    if(comunas == null || comunas.length == 0) {
      return null;
    }
    return comunas[0];
  }
 
  public Comuna[] listComunaByCriteria(ComunaCriteria comunaCriteria) {
    return comunaCriteria.listComuna();
  }
}
TOP

Related Classes of orm.impl.ComunaDAOImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.