1

I've been researching a while about how can I implement an Inner Join using CriteriaBuilder, but the thing is that one of the arguments which both tables have in commons is located inside a jsonb column, so the question is:

How can I INNER JOIN 2 tables by an argument that is located inside a jsonb column called "data" with criteria?

I'll drop down the example code of what I currently have.

public final CriteriaQuery<TutenBookingMacarena> createRatedBookings(
        MacarenaBookingSearchFilter filters,
        Integer page,
        Integer pageSize,
        Security security
) {

    final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    final CriteriaQuery<TutenBookingMacarena> criteria = builder.createQuery(TutenBookingMacarena.class);
    final Root<TutenBookingMacarena> root_Booking = criteria.from(TutenBookingMacarena.class);
   Join<TutenBookingMacarena, TutenCaseMacarena> rootJoin = root_Booking.join(String.valueOf(
            builder.function("jsonb_extract_path_text",
                    String.class,
                    root_Booking.<String>get("data"),
                    builder.literal("caseId")
            )
    )); 
     ... 
}

But when executing those lines of code I get an error message that says the named attribute can not be found. Any idea what's wrong here?

Eduardojls
  • 11
  • 5

0 Answers0