nhibernate-core
nhibernate-core copied to clipboard
NH-2710 - Support Unions on HQL
Ricardo Peres created an issue — :
HQL should support the UNION keyword, since it provides better performance on most DBs than OR clauses.
Fabio Maulo added a comment — :
to do what ?
Ricardo Peres added a comment — :
from Entity e where e.Type = 1 union from Entity e where e.Type = 2
Fabio Maulo added a comment — :
To take that result the UNION is completely unneeded.
- from Entity e where e.Type = 1 or e.Type = 2
- you can use multiquery and union the result in RAM using a very simple LINQ to object expression.
Try again with another example.
Ricardo Peres added a comment — :
OK for multiquery (where the DB supports it), but there is an big difference between OR and UNION in most DB servers. As for joining the results with LINQ to Objects, it is only viable if the queries do not return many results, and, of course, the server already filters duplicates, unless using UNION ALL. I am using this and I have to use SQL queries. I agree, perhaps it's not a critical functionality, but, IMO, it is useful.
David McClelland added a comment — :
I have a case where this would be very useful (for me, at least) - here's the trivial version:
select new CustomerDTO(c.Name, c.Id) from CurrentCustomers c UNION select new CustomerDTO(a.Name, a.Id) from ArchivedCustomers a
Mike added a comment — :
MAKE THIS WORK
Avi Taib added a comment — :
this issue blocking progress of NH-2379. HQL does support left joins only through navigation properties. Left join not through navigation property in HQL could be emulated by cross join and union, but HQL does not support unions.
Alexander Zaytsev added a comment — :
Avi, this feature requires ANTLv3 hql definitions rework for NH
Any updates on this? Any prevision?