List of usage examples for org.hibernate Session createNamedQuery
<T> org.hibernate.query.Query<T> createNamedQuery(String name, Class<T> resultType);
From source file:proy.datos.servicios.implementacion.FiltroHibernate.java
License:Mozilla Public License
public default ArrayList<T> listar(Session session) throws PersistenciaException { ArrayList<T> resultado = new ArrayList<>(); try {/*from w w w .j a v a 2 s . c o m*/ Query<T> query = null; if (!this.getNamedQueryName().isEmpty()) { query = session.createNamedQuery(this.getNamedQueryName(), getClase()); } else { query = session.createQuery(this.getConsultaDinamica(), getClase()); } this.setParametros(query); this.updateParametros(session); resultado = new ArrayList<>(query.list()); } catch (Exception e) { throw new ConsultaException(e); } return resultado; }