The current patch provided didn't do enough for me, so I dug a little deeper. I needed to use different aliases on the same table, so I changed the following methods in the HqlSqlWalker (version 3.3.2.GA): handleWithFragment, createFromJoinElement and WithClauseVisitor:visit.
I removed all the alias checking, but preserved the checking on joining across tables.
I also made the decision that, if you're using multiple aliases to point to the same table, I generate an 'OR', because otherwise parentheses are ignored in with clauses (something a Hibernate dev can fix?).
My testcase:
Entity CertificateTransaction has the previous CertificateTransaction as a field.
HQL:
LEFT JOIN CT.previousVersion pv with pv.certificates.length > CT.certificates.length
AND ct.previousVersion.id = pv.id
AND ct.type = pv.type
LEFT JOIN CT.previousVersion pv2 with ct.previousVersion.id = pv2.id
AND pv2.status = nl.certiq.ecs2.model.certificates.CertificateTransactionStatusType.REJECTED
generates something like:
LEFT JOIN CT.previousVersion pv ON (pv.certificates.length > CT.certificates.length
AND ct.previousVersion.id = pv.id
AND ct.type = pv.type)
OR (CT.previousVersion pv2 with ct.previousVersion.id = pv2.id
AND ( pv2.status = 'REJECTED' )
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
The current patch provided didn't do enough for me, so I dug a little deeper. I needed to use different aliases on the same table, so I changed the following methods in the HqlSqlWalker (version 3.3.2.GA): handleWithFragment, createFromJoinElement and WithClauseVisitor:visit.
I removed all the alias checking, but preserved the checking on joining across tables.
I also made the decision that, if you're using multiple aliases to point to the same table, I generate an 'OR', because otherwise parentheses are ignored in with clauses (something a Hibernate dev can fix?).
My testcase:
Entity CertificateTransaction has the previous CertificateTransaction as a field.
HQL:
LEFT JOIN CT.previousVersion pv with pv.certificates.length > CT.certificates.length
AND ct.previousVersion.id = pv.id
AND ct.type = pv.type
LEFT JOIN CT.previousVersion pv2 with ct.previousVersion.id = pv2.id
AND pv2.status = nl.certiq.ecs2.model.certificates.CertificateTransactionStatusType.REJECTED
generates something like:
LEFT JOIN CT.previousVersion pv ON (pv.certificates.length > CT.certificates.length
AND ct.previousVersion.id = pv.id
AND ct.type = pv.type)
OR (CT.previousVersion pv2 with ct.previousVersion.id = pv2.id
AND ( pv2.status = 'REJECTED' )
What do you think?