-
1. Re: JBoss 4.0.2, EJB QL and Left join problem
holyjoe Aug 22, 2006 4:56 PM (in response to schlaufuchs)I have no idea if this will work, or even if it's legal HQL, but the first thing I would try is
SELECT OBJECT(o) FROM ChargingPoint AS o, IN(o.history) AS h RIGHT JOIN SubNetwork n WHERE h.isActive = true AND h.beginDate <= ?2 AND (h.endDate IS NULL OR h.endDate > ?2) AND (h.downstreamSubNetwork = n OR h.upstreamSubNetwork = n) AND (n = ?1) ORDER BY o.identifier
-
2. Re: JBoss 4.0.2, EJB QL and Left join problem
schlaufuchs Aug 23, 2006 2:30 AM (in response to schlaufuchs)Sorry, didn't work:
08:26:01,002 INFO [STDOUT] org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "RIGHT" at line 1, column 62.
Was expecting one of:
"," ... -
3. Re: JBoss 4.0.2, EJB QL and Left join problem
holyjoe Aug 23, 2006 9:51 AM (in response to schlaufuchs)Sorry about that. I'm afraid I don't have the ambition to write a small test app so that I can get the query right, but if you're stuck for ideas you may want to tweak it to get the RIGHT JOIN working (I know that part is legal, anyway). I suspect it is because of the use of IN() instead of INNER JOIN syntax, but I'm not sure. Maybe something like
SELECT OBJECT(o) FROM ChargingPoint AS o JOIN o.history AS h RIGHT JOIN SubNetwork n WHERE h.isActive = true AND h.beginDate <= ?2 AND (h.endDate IS NULL OR h.endDate > ?2) AND (h.downstreamSubNetwork = n OR h.upstreamSubNetwork = n) AND (n = ?1) ORDER BY o.identifier
Again, though, I don't have a whole lot of hope that the right join will fix the problem anyway, so you may not want to spend too much time on it. Perhaps just issuing two queries won't be too much of a performance problem.
Good luck. -
4. Re: JBoss 4.0.2, EJB QL and Left join problem
schlaufuchs Aug 23, 2006 9:59 AM (in response to schlaufuchs)I think it was the keyword RIGHT which he doesn't like. Seems not to be compatible. In meantime I created two separate finders and then I join the collection. May be a little less efficient but at least it is working.
Ciao!
Kai