terça-feira, 18 de junho de 2013

HQL com clausula ON nos JOIN


SELECT {msg.*}, {cmd.*} 
FROM Schema.Messages AS msg 
  LEFT OUTER JOIN schema.send_commands AS cmd 
    ON cmd.message_key = msg.unique_key 
    AND ( lower(cmd.status) IN (lower('failed') ) ) 
WHERE msg.sequence_received < 10";

SELECT m, c 
FROM Message m LEFT JOIN m.commands c WITH (lower(c.status) = 'failed')
WHERE m.sequenceReceived < 10
Fonte: http://stackoverflow.com/questions/6345052/hibernate-hql-joins-on-many-clauses

Nenhum comentário:

Postar um comentário