whit criteria builder who to find whit a key in key array on postgresql

33 views Asked by At

Hello everybody and thanks for the time you take to answer me .

in my job i supose to implement a way find one id in array of id

i try to reproduce someting like this but in java hibernate + criteria in postgreSQL i don't understand the documentation and im do java for only 3 month

The sql request i try to reproduce look like this: .

SELECT * FROM commercial_information ci WHERE 'f93064da-5089-4591-a2ed-5f86786daba3' = ANY (ci.prescriber_ids);

and one of my filter is describe like this :

protected Predicate simpleUuidCriteria(SimpleFilter<UUID> simpleFilter, Path<UUID> path, CriteriaBuilder builder) {
    if (getSimpleFilterValue(simpleFilter) != null) {
        if (EQUALS.equals(simpleFilter.getMatchMode())) {
            return builder.equal(path, getSimpleFilterValue(simpleFilter));
        }

    }

    return null;
}

One of my idea was to change every array entry in string and find on it like sql function but isn't working to . i think i don't understant this langage

i try to filter on id in sql column where i have an array of id . but i don't understand who to use keyword ANY in my case

1

There are 1 answers

0
hauretax On

For anyone who encounters the same type of problem here is a nice tutorial by Arnau Aregall.

This helped me a lot