How do I implement multiple root entities on a Blaze Persistence query?

289 Views Asked by At

According to the Blaze Persistence Document, a query could have multiple root entities. However, I could not find the way to do it. How do I implement multiple root entities on a Blaze Persistence query?


Add
Solved problem:

I implemented the following working test code thanks to Cristian.

    @Test
    void testThownExceptionWhenUsingRelativePathWithMultipleQueryRoots() {

        // @formatter:off
        IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
            CriteriaBuilder<String> cb = cbf.create(em, String.class)
                    .from(Cat.class, "c")
                    .from(Person.class, "p")
                    .select("name");
            List<String> cats = cb.getResultList();
        });
        // @formatter:on
    }
1

There are 1 best solutions below

1
Christian Beikov On BEST ANSWER

You just need to call .from(..) multiple times.