Package orm.impl

Source Code of orm.impl.ProvinciaDAOImpl

/**
* "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 ProvinciaDAOImpl implements orm.dao.ProvinciaDAO {
  private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(ProvinciaDAOImpl.class);
  public Provincia loadProvinciaByORMID(int provincia_id) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadProvinciaByORMID(session, provincia_id);
    }
    catch (Exception e) {
      _logger.error("loadProvinciaByORMID(int provincia_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia getProvinciaByORMID(int provincia_id) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return getProvinciaByORMID(session, provincia_id);
    }
    catch (Exception e) {
      _logger.error("getProvinciaByORMID(int provincia_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia loadProvinciaByORMID(int provincia_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadProvinciaByORMID(session, provincia_id, lockMode);
    }
    catch (Exception e) {
      _logger.error("loadProvinciaByORMID(int provincia_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia getProvinciaByORMID(int provincia_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return getProvinciaByORMID(session, provincia_id, lockMode);
    }
    catch (Exception e) {
      _logger.error("getProvinciaByORMID(int provincia_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia loadProvinciaByORMID(PersistentSession session, int provincia_id) throws PersistentException {
    try {
      return (Provincia) session.load(orm.Provincia.class, new Integer(provincia_id));
    }
    catch (Exception e) {
      _logger.error("loadProvinciaByORMID(PersistentSession session, int provincia_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia getProvinciaByORMID(PersistentSession session, int provincia_id) throws PersistentException {
    try {
      return (Provincia) session.get(orm.Provincia.class, new Integer(provincia_id));
    }
    catch (Exception e) {
      _logger.error("getProvinciaByORMID(PersistentSession session, int provincia_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia loadProvinciaByORMID(PersistentSession session, int provincia_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      return (Provincia) session.load(orm.Provincia.class, new Integer(provincia_id), lockMode);
    }
    catch (Exception e) {
      _logger.error("loadProvinciaByORMID(PersistentSession session, int provincia_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia getProvinciaByORMID(PersistentSession session, int provincia_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      return (Provincia) session.get(orm.Provincia.class, new Integer(provincia_id), lockMode);
    }
    catch (Exception e) {
      _logger.error("getProvinciaByORMID(PersistentSession session, int provincia_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia[] listProvinciaByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return listProvinciaByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("listProvinciaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia[] listProvinciaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return listProvinciaByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("listProvinciaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia[] listProvinciaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Provincia as Provincia");
    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 (Provincia[]) list.toArray(new Provincia[list.size()]);
    }
    catch (Exception e) {
      _logger.error("listProvinciaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia[] listProvinciaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Provincia as Provincia");
    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 (Provincia[]) list.toArray(new Provincia[list.size()]);
    }
    catch (Exception e) {
      _logger.error("listProvinciaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia loadProvinciaByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadProvinciaByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("loadProvinciaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia loadProvinciaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadProvinciaByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("loadProvinciaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia loadProvinciaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    Provincia[] provincias = listProvinciaByQuery(session, condition, orderBy);
    if (provincias != null && provincias.length > 0)
      return provincias[0];
    else
      return null;
  }
 
  public Provincia loadProvinciaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    Provincia[] provincias = listProvinciaByQuery(session, condition, orderBy, lockMode);
    if (provincias != null && provincias.length > 0)
      return provincias[0];
    else
      return null;
  }
 
  public static java.util.Iterator iterateProvinciaByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return iterateProvinciaByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("iterateProvinciaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateProvinciaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return iterateProvinciaByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("iterateProvinciaByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateProvinciaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Provincia as Provincia");
    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("iterateProvinciaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateProvinciaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Provincia as Provincia");
    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("iterateProvinciaByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia createProvincia() {
    return new orm.Provincia();
  }
 
  public boolean save(orm.Provincia provincia) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().saveObject(provincia);
      return true;
    }
    catch (Exception e) {
      _logger.error("save(orm.Provincia provincia)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean delete(orm.Provincia provincia) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().deleteObject(provincia);
      return true;
    }
    catch (Exception e) {
      _logger.error("delete(orm.Provincia provincia)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean deleteAndDissociate(orm.Provincia provincia)throws PersistentException {
    try {
      if(provincia.getProvincia_region() != null) {
        provincia.getProvincia_region().provincia.remove(provincia);
      }
     
      orm.Comuna[] lComunas = provincia.comuna.toArray();
      for(int i = 0; i < lComunas.length; i++) {
        lComunas[i].setComuna_provincia(null);
      }
      return delete(provincia);
    }
    catch(Exception e) {
      _logger.error("deleteAndDissociate()", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean deleteAndDissociate(orm.Provincia provincia, org.orm.PersistentSession session)throws PersistentException {
    try {
      if(provincia.getProvincia_region() != null) {
        provincia.getProvincia_region().provincia.remove(provincia);
      }
     
      orm.Comuna[] lComunas = provincia.comuna.toArray();
      for(int i = 0; i < lComunas.length; i++) {
        lComunas[i].setComuna_provincia(null);
      }
      try {
        session.delete(provincia);
        return true;
      } catch (Exception e) {
        return false;
      }
    }
    catch(Exception e) {
      _logger.error("deleteAndDissociate()", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean refresh(orm.Provincia provincia) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().getSession().refresh(provincia);
      return true;
    }
    catch (Exception e) {
      _logger.error("refresh(orm.Provincia provincia)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean evict(orm.Provincia provincia) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().getSession().evict(provincia);
      return true;
    }
    catch (Exception e) {
      _logger.error("evict(orm.Provincia provincia)", e);
      throw new PersistentException(e);
    }
  }
 
  public Provincia loadProvinciaByCriteria(ProvinciaCriteria provinciaCriteria) {
    Provincia[] provincias = listProvinciaByCriteria(provinciaCriteria);
    if(provincias == null || provincias.length == 0) {
      return null;
    }
    return provincias[0];
  }
 
  public Provincia[] listProvinciaByCriteria(ProvinciaCriteria provinciaCriteria) {
    return provinciaCriteria.listProvincia();
  }
}
TOP

Related Classes of orm.impl.ProvinciaDAOImpl

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.