/**
* "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 EstablecimientoDAOImpl implements orm.dao.EstablecimientoDAO {
private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(EstablecimientoDAOImpl.class);
public Establecimiento loadEstablecimientoByORMID(int establecimiento_id) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return loadEstablecimientoByORMID(session, establecimiento_id);
}
catch (Exception e) {
_logger.error("loadEstablecimientoByORMID(int establecimiento_id)", e);
throw new PersistentException(e);
}
}
public Establecimiento getEstablecimientoByORMID(int establecimiento_id) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return getEstablecimientoByORMID(session, establecimiento_id);
}
catch (Exception e) {
_logger.error("getEstablecimientoByORMID(int establecimiento_id)", e);
throw new PersistentException(e);
}
}
public Establecimiento loadEstablecimientoByORMID(int establecimiento_id, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return loadEstablecimientoByORMID(session, establecimiento_id, lockMode);
}
catch (Exception e) {
_logger.error("loadEstablecimientoByORMID(int establecimiento_id, org.hibernate.LockMode lockMode)", e);
throw new PersistentException(e);
}
}
public Establecimiento getEstablecimientoByORMID(int establecimiento_id, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return getEstablecimientoByORMID(session, establecimiento_id, lockMode);
}
catch (Exception e) {
_logger.error("getEstablecimientoByORMID(int establecimiento_id, org.hibernate.LockMode lockMode)", e);
throw new PersistentException(e);
}
}
public Establecimiento loadEstablecimientoByORMID(PersistentSession session, int establecimiento_id) throws PersistentException {
try {
return (Establecimiento) session.load(orm.Establecimiento.class, new Integer(establecimiento_id));
}
catch (Exception e) {
_logger.error("loadEstablecimientoByORMID(PersistentSession session, int establecimiento_id)", e);
throw new PersistentException(e);
}
}
public Establecimiento getEstablecimientoByORMID(PersistentSession session, int establecimiento_id) throws PersistentException {
try {
return (Establecimiento) session.get(orm.Establecimiento.class, new Integer(establecimiento_id));
}
catch (Exception e) {
_logger.error("getEstablecimientoByORMID(PersistentSession session, int establecimiento_id)", e);
throw new PersistentException(e);
}
}
public Establecimiento loadEstablecimientoByORMID(PersistentSession session, int establecimiento_id, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Establecimiento) session.load(orm.Establecimiento.class, new Integer(establecimiento_id), lockMode);
}
catch (Exception e) {
_logger.error("loadEstablecimientoByORMID(PersistentSession session, int establecimiento_id, org.hibernate.LockMode lockMode)", e);
throw new PersistentException(e);
}
}
public Establecimiento getEstablecimientoByORMID(PersistentSession session, int establecimiento_id, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Establecimiento) session.get(orm.Establecimiento.class, new Integer(establecimiento_id), lockMode);
}
catch (Exception e) {
_logger.error("getEstablecimientoByORMID(PersistentSession session, int establecimiento_id, org.hibernate.LockMode lockMode)", e);
throw new PersistentException(e);
}
}
public Establecimiento[] listEstablecimientoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return listEstablecimientoByQuery(session, condition, orderBy);
}
catch (Exception e) {
_logger.error("listEstablecimientoByQuery(String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public Establecimiento[] listEstablecimientoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return listEstablecimientoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
_logger.error("listEstablecimientoByQuery(String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public Establecimiento[] listEstablecimientoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Establecimiento as Establecimiento");
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 (Establecimiento[]) list.toArray(new Establecimiento[list.size()]);
}
catch (Exception e) {
_logger.error("listEstablecimientoByQuery(PersistentSession session, String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public Establecimiento[] listEstablecimientoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Establecimiento as Establecimiento");
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 (Establecimiento[]) list.toArray(new Establecimiento[list.size()]);
}
catch (Exception e) {
_logger.error("listEstablecimientoByQuery(PersistentSession session, String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public Establecimiento loadEstablecimientoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return loadEstablecimientoByQuery(session, condition, orderBy);
}
catch (Exception e) {
_logger.error("loadEstablecimientoByQuery(String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public Establecimiento loadEstablecimientoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return loadEstablecimientoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
_logger.error("loadEstablecimientoByQuery(String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public Establecimiento loadEstablecimientoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Establecimiento[] establecimientos = listEstablecimientoByQuery(session, condition, orderBy);
if (establecimientos != null && establecimientos.length > 0)
return establecimientos[0];
else
return null;
}
public Establecimiento loadEstablecimientoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Establecimiento[] establecimientos = listEstablecimientoByQuery(session, condition, orderBy, lockMode);
if (establecimientos != null && establecimientos.length > 0)
return establecimientos[0];
else
return null;
}
public static java.util.Iterator iterateEstablecimientoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return iterateEstablecimientoByQuery(session, condition, orderBy);
}
catch (Exception e) {
_logger.error("iterateEstablecimientoByQuery(String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateEstablecimientoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.VP2PersistentManager.instance().getSession();
return iterateEstablecimientoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
_logger.error("iterateEstablecimientoByQuery(String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateEstablecimientoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Establecimiento as Establecimiento");
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("iterateEstablecimientoByQuery(PersistentSession session, String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateEstablecimientoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Establecimiento as Establecimiento");
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("iterateEstablecimientoByQuery(PersistentSession session, String condition, String orderBy)", e);
throw new PersistentException(e);
}
}
public Establecimiento createEstablecimiento() {
return new orm.Establecimiento();
}
public boolean save(orm.Establecimiento establecimiento) throws PersistentException {
try {
orm.VP2PersistentManager.instance().saveObject(establecimiento);
return true;
}
catch (Exception e) {
_logger.error("save(orm.Establecimiento establecimiento)", e);
throw new PersistentException(e);
}
}
public boolean delete(orm.Establecimiento establecimiento) throws PersistentException {
try {
orm.VP2PersistentManager.instance().deleteObject(establecimiento);
return true;
}
catch (Exception e) {
_logger.error("delete(orm.Establecimiento establecimiento)", e);
throw new PersistentException(e);
}
}
public boolean deleteAndDissociate(orm.Establecimiento establecimiento)throws PersistentException {
try {
if(establecimiento.getEstablecimiento_comuna() != null) {
establecimiento.getEstablecimiento_comuna().establecimiento.remove(establecimiento);
}
orm.Alumno[] lAlumnos = establecimiento.alumno.toArray();
for(int i = 0; i < lAlumnos.length; i++) {
lAlumnos[i].setAlumno_establecimiento(null);
}
orm.Puntaje[] lPuntaje1s = establecimiento.puntaje1.toArray();
for(int i = 0; i < lPuntaje1s.length; i++) {
lPuntaje1s[i].setPuntaje_establecimientorbd(null);
}
return delete(establecimiento);
}
catch(Exception e) {
_logger.error("deleteAndDissociate()", e);
throw new PersistentException(e);
}
}
public boolean deleteAndDissociate(orm.Establecimiento establecimiento, org.orm.PersistentSession session)throws PersistentException {
try {
if(establecimiento.getEstablecimiento_comuna() != null) {
establecimiento.getEstablecimiento_comuna().establecimiento.remove(establecimiento);
}
orm.Alumno[] lAlumnos = establecimiento.alumno.toArray();
for(int i = 0; i < lAlumnos.length; i++) {
lAlumnos[i].setAlumno_establecimiento(null);
}
orm.Puntaje[] lPuntaje1s = establecimiento.puntaje1.toArray();
for(int i = 0; i < lPuntaje1s.length; i++) {
lPuntaje1s[i].setPuntaje_establecimientorbd(null);
}
try {
session.delete(establecimiento);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
_logger.error("deleteAndDissociate()", e);
throw new PersistentException(e);
}
}
public boolean refresh(orm.Establecimiento establecimiento) throws PersistentException {
try {
orm.VP2PersistentManager.instance().getSession().refresh(establecimiento);
return true;
}
catch (Exception e) {
_logger.error("refresh(orm.Establecimiento establecimiento)", e);
throw new PersistentException(e);
}
}
public boolean evict(orm.Establecimiento establecimiento) throws PersistentException {
try {
orm.VP2PersistentManager.instance().getSession().evict(establecimiento);
return true;
}
catch (Exception e) {
_logger.error("evict(orm.Establecimiento establecimiento)", e);
throw new PersistentException(e);
}
}
public Establecimiento loadEstablecimientoByCriteria(EstablecimientoCriteria establecimientoCriteria) {
Establecimiento[] establecimientos = listEstablecimientoByCriteria(establecimientoCriteria);
if(establecimientos == null || establecimientos.length == 0) {
return null;
}
return establecimientos[0];
}
public Establecimiento[] listEstablecimientoByCriteria(EstablecimientoCriteria establecimientoCriteria) {
return establecimientoCriteria.listEstablecimiento();
}
}