jpa - JPQL - multiple joins with OR -


i'm using jpa , wondering best way construct query.

here data model (this totally contrived , non-sensical):
table "thing" has many-to-many relationship tables "height" "width" , "length"
height, width, length each have many-to-one relationship table "creator"

for given thing, creators associated @ least 1 of height, width, or length (note single thing can have many heights - said it's contrived).

for example, if concerned height, this:

select c creator c
inner join c.heights height
height.thing = :thing

is there way specify multiple inner joins or? i'm assuming multiple inner joins function boolean and.

here's current best guess:

select c creator c
exists (select h height h h.creator = c , h.thing = :thing)
or exists (select w width w w.creator = c , w.thing = :thing)
or exists (select l length l l.creator = c , l.thing = :thing)

is there better way construct query? real-world case has 10 elements in height-width-length collection.

or work inner joins long relationship exists (as long creator has heights, regardless of condition). if relationship empty or null, need use outer join, or sub-select.

i believe , outer join perform better sub-select, may depend on database.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -