This JPQL doesn’t work as expected what did I do wrong?
SELECT distinct ec.event FROM callbook$EventCard ec FULL OUTER JOIN callbook$Event e ON ec.event.id = e.id where ec.id is null
union
SELECT distinct ec.event FROM callbook$EventCard ec FULL OUTER JOIN callbook$Event e ON ec.event.id = e.id WHERE ec.Card.id <> :session$currentMemberID
I want it to act same way as this plain sql:
And also I want to clarify: what exactly is used in Cuba: JPA, hibernate, or ECLIPSELINK Or it depends on component? Oh it seems to be ECLIPSELINK but why doesn’t it then say “Union is not supported” error?
Thanks Keith, but how do you think: is each of the two queries itself correct? (Behave the same as the original native query)?
Turned out it’s eclipseLink which supports UNION
I used “custom Datasource” where I did whatever I wanted in Java and returned Collection but the problem in that approach is that fts (filter and some other features probably) don’t work with such Datasources (without query)… It seemed to me that Ds.commit didn’t work…
I also don’t understand why
SELECT e FROM callbook$Event e
works and
SELECT ec.event FROM callbook$EventCard ec where ec.card.id <> :session$currentMemberID
works but
SELECT e FROM callbook$Event e UNION SELECT ec.event FROM callbook$EventCard ec where ec.card.id <> :session$currentMemberID
doesn’t? Causes error: Query argument session$currentMemberID not found in the list of parameters provided during query execution
Yes, that is interesting. I’m sorry I can’t confirm with certainty the ability to do UNION. I hope someone can jump in and clarify. It is the feature I miss most from SQL.
I’ve been thinking about the custom datasource approach. It does seem tough without a single query. But is it possible to have a single query that grabs too much but override the getEntities method to filter out the results that your union logic would have taken care of? I’m not sure of volumes and performance conditions… You would need to override getCount too… Just a wild idea.