Hello All,
I have the same issue as described in https://hibernate.onjira.com/browse/HHH-7321. Any attempt to make complex condition using 'with' HSQL statement fails with exception: 'with-clause referenced two different from-clause elements'.
Has anyone workaround this issue?
I see only the two ways:
1) write Native SQL
2) patch Hibernate according to patch in https://hibernate.onjira.com/browse/HHH-1673
But both solutions are dirty for me. Also it is not clear for me why HHH-1673 is marked as deprecated?
In my example there was following classes:
Code:
MInstance (long id, String name, MInstanceScanResult lastScanResult, Set<MInstanceThreshold> thresholds)
MInstanceThreshold (long id, MInstance instanse, String metric, Double value)
MInstanceScanResult (long id, Date startDate, Date finishDate, Set<MInstanceValue> values)
MInstanceValue (long id, MInstanceScanResult scanResult, String metric, Double value)
I wanted to select planned and actual values by one HSQL query:
Code:
select i.id, p.metric, p.value, s.value
from MInstance i
join i.thresholds p
left join i.lastScanResult lsr
left join lsr.values s with s.metric = p.metric
It fails with exception 'with-clause referenced two different from-clause elements'. And it is not clear why, because I'm able to add similar 'ON' statement in SQL.