Package orm.impl

Source Code of orm.impl.NivelDAOImpl

/**
* "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 NivelDAOImpl implements orm.dao.NivelDAO {
  private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(NivelDAOImpl.class);
  public Nivel loadNivelByORMID(int nivel_id) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadNivelByORMID(session, nivel_id);
    }
    catch (Exception e) {
      _logger.error("loadNivelByORMID(int nivel_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel getNivelByORMID(int nivel_id) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return getNivelByORMID(session, nivel_id);
    }
    catch (Exception e) {
      _logger.error("getNivelByORMID(int nivel_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel loadNivelByORMID(int nivel_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadNivelByORMID(session, nivel_id, lockMode);
    }
    catch (Exception e) {
      _logger.error("loadNivelByORMID(int nivel_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel getNivelByORMID(int nivel_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return getNivelByORMID(session, nivel_id, lockMode);
    }
    catch (Exception e) {
      _logger.error("getNivelByORMID(int nivel_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel loadNivelByORMID(PersistentSession session, int nivel_id) throws PersistentException {
    try {
      return (Nivel) session.load(orm.Nivel.class, new Integer(nivel_id));
    }
    catch (Exception e) {
      _logger.error("loadNivelByORMID(PersistentSession session, int nivel_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel getNivelByORMID(PersistentSession session, int nivel_id) throws PersistentException {
    try {
      return (Nivel) session.get(orm.Nivel.class, new Integer(nivel_id));
    }
    catch (Exception e) {
      _logger.error("getNivelByORMID(PersistentSession session, int nivel_id)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel loadNivelByORMID(PersistentSession session, int nivel_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      return (Nivel) session.load(orm.Nivel.class, new Integer(nivel_id), lockMode);
    }
    catch (Exception e) {
      _logger.error("loadNivelByORMID(PersistentSession session, int nivel_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel getNivelByORMID(PersistentSession session, int nivel_id, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      return (Nivel) session.get(orm.Nivel.class, new Integer(nivel_id), lockMode);
    }
    catch (Exception e) {
      _logger.error("getNivelByORMID(PersistentSession session, int nivel_id, org.hibernate.LockMode lockMode)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel[] listNivelByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return listNivelByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("listNivelByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel[] listNivelByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return listNivelByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("listNivelByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel[] listNivelByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Nivel as Nivel");
    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 (Nivel[]) list.toArray(new Nivel[list.size()]);
    }
    catch (Exception e) {
      _logger.error("listNivelByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel[] listNivelByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Nivel as Nivel");
    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 (Nivel[]) list.toArray(new Nivel[list.size()]);
    }
    catch (Exception e) {
      _logger.error("listNivelByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel loadNivelByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadNivelByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("loadNivelByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel loadNivelByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return loadNivelByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("loadNivelByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel loadNivelByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    Nivel[] nivels = listNivelByQuery(session, condition, orderBy);
    if (nivels != null && nivels.length > 0)
      return nivels[0];
    else
      return null;
  }
 
  public Nivel loadNivelByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    Nivel[] nivels = listNivelByQuery(session, condition, orderBy, lockMode);
    if (nivels != null && nivels.length > 0)
      return nivels[0];
    else
      return null;
  }
 
  public static java.util.Iterator iterateNivelByQuery(String condition, String orderBy) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return iterateNivelByQuery(session, condition, orderBy);
    }
    catch (Exception e) {
      _logger.error("iterateNivelByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateNivelByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    try {
      PersistentSession session = orm.VP2PersistentManager.instance().getSession();
      return iterateNivelByQuery(session, condition, orderBy, lockMode);
    }
    catch (Exception e) {
      _logger.error("iterateNivelByQuery(String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateNivelByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Nivel as Nivel");
    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("iterateNivelByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public static java.util.Iterator iterateNivelByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From orm.Nivel as Nivel");
    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("iterateNivelByQuery(PersistentSession session, String condition, String orderBy)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel createNivel() {
    return new orm.Nivel();
  }
 
  public boolean save(orm.Nivel nivel) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().saveObject(nivel);
      return true;
    }
    catch (Exception e) {
      _logger.error("save(orm.Nivel nivel)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean delete(orm.Nivel nivel) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().deleteObject(nivel);
      return true;
    }
    catch (Exception e) {
      _logger.error("delete(orm.Nivel nivel)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean deleteAndDissociate(orm.Nivel nivel)throws PersistentException {
    try {
      orm.Puntaje[] lPuntajes = nivel.puntaje.toArray();
      for(int i = 0; i < lPuntajes.length; i++) {
        lPuntajes[i].setPuntaje_nivel(null);
      }
      orm.Alumno[] lAlumnos = nivel.alumno.toArray();
      for(int i = 0; i < lAlumnos.length; i++) {
        lAlumnos[i].setAlumno_nivel(null);
      }
      return delete(nivel);
    }
    catch(Exception e) {
      _logger.error("deleteAndDissociate()", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean deleteAndDissociate(orm.Nivel nivel, org.orm.PersistentSession session)throws PersistentException {
    try {
      orm.Puntaje[] lPuntajes = nivel.puntaje.toArray();
      for(int i = 0; i < lPuntajes.length; i++) {
        lPuntajes[i].setPuntaje_nivel(null);
      }
      orm.Alumno[] lAlumnos = nivel.alumno.toArray();
      for(int i = 0; i < lAlumnos.length; i++) {
        lAlumnos[i].setAlumno_nivel(null);
      }
      try {
        session.delete(nivel);
        return true;
      } catch (Exception e) {
        return false;
      }
    }
    catch(Exception e) {
      _logger.error("deleteAndDissociate()", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean refresh(orm.Nivel nivel) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().getSession().refresh(nivel);
      return true;
    }
    catch (Exception e) {
      _logger.error("refresh(orm.Nivel nivel)", e);
      throw new PersistentException(e);
    }
  }
 
  public boolean evict(orm.Nivel nivel) throws PersistentException {
    try {
      orm.VP2PersistentManager.instance().getSession().evict(nivel);
      return true;
    }
    catch (Exception e) {
      _logger.error("evict(orm.Nivel nivel)", e);
      throw new PersistentException(e);
    }
  }
 
  public Nivel loadNivelByCriteria(NivelCriteria nivelCriteria) {
    Nivel[] nivels = listNivelByCriteria(nivelCriteria);
    if(nivels == null || nivels.length == 0) {
      return null;
    }
    return nivels[0];
  }
 
  public Nivel[] listNivelByCriteria(NivelCriteria nivelCriteria) {
    return nivelCriteria.listNivel();
  }
}
TOP

Related Classes of orm.impl.NivelDAOImpl

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.