Stephan van Hugten edited a comment on Deprecation HHH-1673

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 (Pseudo MSSQL code):

SELECT ct.*
FROM dbo.certificate_transaction ct
INNER JOIN dbo.certificate c1 ON c1.id = c1.details_id
INNER JOIN dbo.certificate c2 ON c1.id = pv.details_id
LEFT JOIN dbo.certificate_transaction pv ON
(c2.length > c1.length
AND ct.previous_version_id = pv.id
AND ct.type2 = pv.type2)
OR
(ct.previous_version_id = pv.id
AND pv.status = 'REJECTED' )

What do you think?

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