Select between with hibernate

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:

	public List<Venda> consultar(Date dataInicial, Date dataFinal) {
		Criteria criteria = criarCriteria(Venda.class);
		if (dataInicial != null)
			criteria.add("dataInicial", dataInicial));
		if (dataFinal != null)
			criteria.add(Restrictions.le("dataFinal", dataFinal));

		List<Venda> vendas = (List<Venda>) criteria.list();
		return vendas;

in the most updated way

I have no idea what that should mean. Either way, I would recommend you use the JPA Criteria API as the legacy Hibernate Criteria API will be removed in 6.0. Here is a nice overview of all possible usages: