Example usage for org.hibernate Session getNamedQuery

List of usage examples for org.hibernate Session getNamedQuery

Introduction

In this page you can find the example usage for org.hibernate Session getNamedQuery.

Prototype

org.hibernate.Query getNamedQuery(String queryName);

Source Link

Document

Create a Query instance for the named query.

Usage

From source file:br.com.ln.dao.FavorecidoDao.java

public static LnFavorecido grabFavorecidoCodigo(Integer idFavorecido) {

    Session session = null;
    Transaction tx;//from   w  w  w  .ja  v  a  2 s.  c  om
    LnFavorecido lnFavorecido = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnFavorecido.findByFavInCodigo");
        query.setInteger("favInCodigo", idFavorecido);
        List l = query.list();
        tx.commit();

        if (l != null && l.size() > 0) {
            lnFavorecido = (LnFavorecido) l.get(0);
        }

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }
    return lnFavorecido;
}

From source file:br.com.ln.dao.FavorecidoDao.java

public static List<LnFavorecido> grabListaFavorecido() {

    Session session = null;
    Transaction tx;/*from  w ww  . j  av  a  2 s.  co  m*/
    List<LnFavorecido> listaFavorecido = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnFavorecido.findAll");
        listaFavorecido = query.list();
        tx.commit();

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }
    return listaFavorecido;
}

From source file:br.com.ln.dao.FavorecidoDao.java

public static List<LnFavorecido> grabListaFavorecidoAtivo() {

    Session session = null;
    Transaction tx;//from   w w w  .  j  a v  a2s  . c om
    List<LnFavorecido> listaFavorecido = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnFavorecido.findByFavChAtivo");
        query.setCharacter("favChAtivo", 'S');
        listaFavorecido = query.list();
        tx.commit();
    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }

    return listaFavorecido;
}

From source file:br.com.ln.dao.HistoricoDao.java

public static boolean grabVerificaHistorico(String usuStCodigo) {

    Session session = null;
    Transaction tx;/*from   w w w  .j av a2  s .  co  m*/
    List<LnHistorico> listHis;
    boolean retorno = false;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnHistorico.findByUsuStCodigo");
        query.setString("usuStCodigo", usuStCodigo);

        listHis = query.list();
        tx.commit();

        if (listHis != null) {
            retorno = listHis.isEmpty();
        } else {
            retorno = false;
        }
    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }

    return retorno;
}

From source file:br.com.ln.dao.HistoricoDao.java

public static List<LnHistorico> grabListHistorico(Integer modInCodigo) {

    Session session = null;
    Transaction tx = null;//from   w w w .j  a  v a  2  s  .  c  o  m
    List<LnHistorico> listHistorico = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();
        Query query;

        if (modInCodigo != null) {
            query = session.getNamedQuery("LnHistorico.findByModInCodigo");
            query.setInteger("modInCodigo", modInCodigo);
        } else {
            query = session.getNamedQuery("LnHistorico.findAll");
        }
        listHistorico = query.list();

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }

    return listHistorico;
}

From source file:br.com.ln.dao.MenuDao.java

/**
     * Busca o Menu/*from   www.j  a v a  2 s. c o m*/
     * @param clazz
     * @param strDbName
     * @return List Object
     */
public static List<LnMenu> grabMenu(Character menChAtivo) {

    Session session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
    Transaction tx = session.beginTransaction();
    List<LnMenu> listMenu = null;
    try {
        Query query = session.getNamedQuery("LnMenu.findAllAtivo");
        query.setCharacter("menChAtivo", 'S');
        listMenu = (List<LnMenu>) query.list();

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }
    return listMenu;
}

From source file:br.com.ln.dao.ModuloDao.java

public static List<LnModulo> grabListModuloAtivo(Character modChAtivo) {

    Session session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
    Transaction tx = session.beginTransaction();
    List<LnModulo> listlnModulo = null;

    try {/* w  w  w. j  a va 2s  .  c  om*/
        Query query = session.getNamedQuery("LnModulo.findAllAtivo");
        query.setCharacter("modChAtivo", modChAtivo);

        List l = query.list();

        if (l != null && !l.isEmpty()) {
            listlnModulo = l;
        }

    } finally {
        if (session.isOpen()) {
            session.close();
        }
    }
    return listlnModulo;
}

From source file:br.com.ln.dao.ModuloDao.java

public static LnModulo getModulo(Integer modInCodigo) {

    Session session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
    Transaction tx = session.getTransaction();
    LnModulo lnModulo = null;//from   w  w w  .  j  av a2  s. c  o m

    try {
        Query query = session.getNamedQuery("LnModulo.findByModInCodigo");
        query.setInteger("modInCodigo", modInCodigo);

        List list = query.list();

        if (list != null && !list.isEmpty()) {
            lnModulo = (LnModulo) list.get(0);
        }

    } finally {
        if (session.isOpen()) {
            session.close();
        }
    }

    return lnModulo;
}

From source file:br.com.ln.dao.PerfilDao.java

/**
 * Perfil especifico//from   www . ja  va  2s  . com
 * @param perInCodigo
 * @param perChAtivo
 * @return List Object
 */
public static LnPerfil grabPerfil(Integer perInCodigo, Character perChAtivo) {

    Session session = null;
    Transaction tx = null;
    LnPerfil lnPerfil = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();
        Query query = session.getNamedQuery("LnPerfil.findByPerInCodigoPerChAtivo");
        query.setInteger("perInCodigo", perInCodigo);
        query.setCharacter("perChAtivo", perChAtivo);

        List l = query.list();
        tx.commit();

        if (l != null && !l.isEmpty()) {
            lnPerfil = (LnPerfil) l.get(0);
        }

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }
    return lnPerfil;
}

From source file:br.com.ln.dao.PerfilDao.java

/**
 * grabListPerfilAtivo Get list profile active
 * @param perChAtivo/*from   w  w w  . jav  a2s  .  com*/
 * @return List Object
 */

public static List<LnPerfil> grabListPerfilAtivo(Character perChAtivo) {

    Session session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
    Transaction tx = session.beginTransaction();
    List<LnPerfil> listPerfil;

    try {
        Query query = session.getNamedQuery("LnPerfil.findByPerChAtivo");
        query.setCharacter("perChAtivo", perChAtivo);
        listPerfil = query.list();
        tx.commit();
    } finally {
        if (session.isOpen()) {
            session.close();
        }
    }
    return listPerfil;
}