bbdd.Administrador_DAO.java Source code

Java tutorial

Introduction

Here is the source code for bbdd.Administrador_DAO.java

Source

/**
 * "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: Daniel Landa
 * License Type: Purchased
 */
package bbdd;

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

public class Administrador_DAO {
    public static Administrador_ loadAdministrador_ByORMID(String dni) throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return loadAdministrador_ByORMID(session, dni);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ getAdministrador_ByORMID(String dni) throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return getAdministrador_ByORMID(session, dni);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ loadAdministrador_ByORMID(String dni, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return loadAdministrador_ByORMID(session, dni, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ getAdministrador_ByORMID(String dni, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return getAdministrador_ByORMID(session, dni, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ loadAdministrador_ByORMID(PersistentSession session, String dni)
            throws PersistentException {
        try {
            return (Administrador_) session.load(bbdd.Administrador_.class, dni);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ getAdministrador_ByORMID(PersistentSession session, String dni)
            throws PersistentException {
        try {
            return (Administrador_) session.get(bbdd.Administrador_.class, dni);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ loadAdministrador_ByORMID(PersistentSession session, String dni,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            return (Administrador_) session.load(bbdd.Administrador_.class, dni, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ getAdministrador_ByORMID(PersistentSession session, String dni,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            return (Administrador_) session.get(bbdd.Administrador_.class, dni, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryAdministrador_(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return queryAdministrador_(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryAdministrador_(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return queryAdministrador_(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_[] listAdministrador_ByQuery(String condition, String orderBy)
            throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return listAdministrador_ByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_[] listAdministrador_ByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return listAdministrador_ByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryAdministrador_(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        StringBuffer sb = new StringBuffer("From bbdd.Administrador_ as Administrador_");
        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.list();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryAdministrador_(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From bbdd.Administrador_ as Administrador_");
        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.list();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_[] listAdministrador_ByQuery(PersistentSession session, String condition,
            String orderBy) throws PersistentException {
        try {
            List list = queryAdministrador_(session, condition, orderBy);
            return (Administrador_[]) list.toArray(new Administrador_[list.size()]);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_[] listAdministrador_ByQuery(PersistentSession session, String condition,
            String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            List list = queryAdministrador_(session, condition, orderBy, lockMode);
            return (Administrador_[]) list.toArray(new Administrador_[list.size()]);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ loadAdministrador_ByQuery(String condition, String orderBy)
            throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return loadAdministrador_ByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ loadAdministrador_ByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return loadAdministrador_ByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ loadAdministrador_ByQuery(PersistentSession session, String condition,
            String orderBy) throws PersistentException {
        Administrador_[] administrador_s = listAdministrador_ByQuery(session, condition, orderBy);
        if (administrador_s != null && administrador_s.length > 0)
            return administrador_s[0];
        else
            return null;
    }

    public static Administrador_ loadAdministrador_ByQuery(PersistentSession session, String condition,
            String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
        Administrador_[] administrador_s = listAdministrador_ByQuery(session, condition, orderBy, lockMode);
        if (administrador_s != null && administrador_s.length > 0)
            return administrador_s[0];
        else
            return null;
    }

    public static java.util.Iterator iterateAdministrador_ByQuery(String condition, String orderBy)
            throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return iterateAdministrador_ByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static java.util.Iterator iterateAdministrador_ByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = bbdd.ProyectoNuevoPersistentManager.instance().getSession();
            return iterateAdministrador_ByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static java.util.Iterator iterateAdministrador_ByQuery(PersistentSession session, String condition,
            String orderBy) throws PersistentException {
        StringBuffer sb = new StringBuffer("From bbdd.Administrador_ as Administrador_");
        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 iterateAdministrador_ByQuery(PersistentSession session, String condition,
            String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From bbdd.Administrador_ as Administrador_");
        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 Administrador_ createAdministrador_() {
        return new bbdd.Administrador_();
    }

    public static boolean save(bbdd.Administrador_ administrador_) throws PersistentException {
        try {
            bbdd.ProyectoNuevoPersistentManager.instance().saveObject(administrador_);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean delete(bbdd.Administrador_ administrador_) throws PersistentException {
        try {
            bbdd.ProyectoNuevoPersistentManager.instance().deleteObject(administrador_);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean deleteAndDissociate(bbdd.Administrador_ administrador_) throws PersistentException {
        try {
            bbdd.Sugerencia[] lAtiende_sugerencias = administrador_.atiende_sugerencia.toArray();
            for (int i = 0; i < lAtiende_sugerencias.length; i++) {
                lAtiende_sugerencias[i].setEs_atendida_por(null);
            }
            return delete(administrador_);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean deleteAndDissociate(bbdd.Administrador_ administrador_, org.orm.PersistentSession session)
            throws PersistentException {
        try {
            bbdd.Sugerencia[] lAtiende_sugerencias = administrador_.atiende_sugerencia.toArray();
            for (int i = 0; i < lAtiende_sugerencias.length; i++) {
                lAtiende_sugerencias[i].setEs_atendida_por(null);
            }
            try {
                session.delete(administrador_);
                return true;
            } catch (Exception e) {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean refresh(bbdd.Administrador_ administrador_) throws PersistentException {
        try {
            bbdd.ProyectoNuevoPersistentManager.instance().getSession().refresh(administrador_);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static boolean evict(bbdd.Administrador_ administrador_) throws PersistentException {
        try {
            bbdd.ProyectoNuevoPersistentManager.instance().getSession().evict(administrador_);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Administrador_ loadAdministrador_ByCriteria(Administrador_Criteria administrador_Criteria) {
        Administrador_[] administrador_s = listAdministrador_ByCriteria(administrador_Criteria);
        if (administrador_s == null || administrador_s.length == 0) {
            return null;
        }
        return administrador_s[0];
    }

    public static Administrador_[] listAdministrador_ByCriteria(Administrador_Criteria administrador_Criteria) {
        return administrador_Criteria.listAdministrador_();
    }
}