You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Referring to InterfaceViewTest.testInterface(), following query is generated so far:
SELECT contacts, d.id, contacts, d.name FROM Document d LEFT JOIN d.contacts contacts WHERE KEY(contacts) = 1 AND KEY(contacts) = :contactPersonNumber ORDER BY d.id ASC NULLS LAST
This results in an empty result set if :contactPersonNumber != 1
Instead the query should be built like this:
SELECT contacts1, d.id, contacts2, d.name FROM Document d LEFT JOIN d.contacts contacts1 LEFT JOIN d.contacts contacts2 WHERE KEY(contacts1) = 1 OR KEY(contacts2) = :contactPersonNumber ORDER BY d.id ASC NULLS LAST
Currently we can only join a path like "doc.localized.name" once, but it is sometimes necessary to join it multiple times with different aliases.
This is especially necessary for queries that use indexed collections.
If for example one would want to select two distinct values from a map attribute with different keys, the resulting JPQL Query could look like:
"SELECT o1, o2, FROM SomeType s LEFT JOIN s.map o1 LEFT JOIN s.map o2 WHERE KEY(o1) = 1 AND KEY(o2) = 2"
Note that this query in contrast to the next one, only returns a result, if both there are objects for both keys 1 and 2.
"SELECT o1, o2, FROM SomeType s LEFT JOIN s.map o1 LEFT JOIN s.map o2 WHERE KEY(o1) = 1 OR KEY(o2) = 2"
This query would return null for o2 if there was no entry with key 2.
When enabling this feature, please consider the different use cases.
The text was updated successfully, but these errors were encountered: