I am new to the criteria api and am trying to build a select query where id matches id.
I would like to build this:
SELECT * FROM movie WHERE id = id(input var)
So far I have this with an input variable id as a long
:
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Movie> critQuery = criteriaBuilder.createQuery(Movie.class);
Root<Movie> rootMovie = critQuery.from(Movie.class);
critQuery.select(rootMovie).where(rootMovie.get("movieId"), id);
This will create errors and doesn't work. Any ideas how to make it work?
error: The method where(Expression) in the type CriteriaQuery is not applicable for the arguments (Path, Long)