Hello,
I have the following table:
CREATE TABLE "pre_vendas" (
"id_prev_venda" BIGINT NOT NULL,
"data_prev_venda" DATE NOT NULL,
"data_real_venda" DATE NOT NULL,
"valor_real_venda" NUMERIC(10,2) NULL DEFAULT NULL,
PRIMARY KEY ("id_prev_venda")
);
I’m having difficulty converting the dates in numeric format (numbers only), I’m trying this way:
CriteriaBuilder builder = sf.getCurrentSession().getCriteriaBuilder();
CriteriaQuery<Tuple> criteria = builder.createTupleQuery();
Root<PreVenda> root = criteria.from(PreVenda.class);
Expression<Long> dataPrevVenda = root.get(PreVenda_.dataPrevVenda).as(Long.class);
Expression<Long> dataRealVenda = root.get(PreVenda_.dataRealVenda).as(Long.class);
criteria.select(builder.tuple(builder.diff(dataRealVenda,dataPrevVenda)));
this is returning a cast exception, Anyone have any idea how to solve this?