Hi, sorry, I don’t know if I chose the correct category to ask for help…
I want to make a select with between with hibernate in the most updated way. I looked, I looked and I didn’t find it. It’s a simple query. I would love this query in hibernate more up to date. I believe that’s what “persistence” uses. Example of my sql below:
select horario
from venda
where horario between 'dataInicial' and 'dataFinal'
order by horario asc
This type of hibernate below doesn’t work in my project, I think it’s because of my database connection factory which is more up-to-date than this way of doing this sql in below:
@SuppressWarnings("unchecked")
public List<Venda> consultar(Date dataInicial, Date dataFinal) {
Criteria criteria = criarCriteria(Venda.class);
if (dataInicial != null)
criteria.add(Restrictions.ge("dataInicial", dataInicial));
if (dataFinal != null)
criteria.add(Restrictions.le("dataFinal", dataFinal));
List<Venda> vendas = (List<Venda>) criteria.list();
fecharConexao();
return vendas;
}