I have a query that i want to call a function without parsing a parameter to the function. Example....
CREATE OR REPLACE function demo_fn()
RETURNS TABLE (
id bigint,
somename varchar,
something varchar) AS $$
BEGIN
RETURN QUERY SELECT DISTINCT c.id, c.somename , c.something FROM pluto c
ORDER BY id ASC LIMIT 10;
END;
$$
LANGUAGE plpgsql;
This query function is called like this select * from demo_fn();
which work perfectly well from the database.
On the other hand, the method calling the function is like this....
CriteriaBuilder cb = em.getCriteriaBuilder();
cb.function("demo_fn", PlutoDTO.class, cb.parameter(null))));
CriteriaQuery cq = cb.createQuery(PlutoDTO.class);
Root root = cq.from(Pluto.class);
TypedQuery q = em.createQuery(cq);
List<PlutoDTO> pluto = q.getResultList();
When i run the function
Caused by: java.lang.IllegalArgumentException: Error occurred validating the Criteria
Can someone please point me to the right direction Can't really see my way out here.....much appreciated