This project is read-only.

String.StartsWith not supported in NH3 QueryOver

Topics: Core, Troubleshooting
Aug 17, 2012 at 5:15 PM

Just looking at 1.x branch with NH3 bits.

It seems as though the underlying QueryOver layer doesn't support String.StartsWith().  It is used in modules such as Taxonomies. I see you have to use IsLike() within the where clause, but that is an extension method in the NHibernate.Criterion namespace.

Any thoughts on how we overcome this?


Aug 17, 2012 at 7:28 PM

I am working on this, because there are a lot of those expressions which are not supported in QueryOver, like Any() also in Tags.

Linq though is working fine, but is not manageable enough to be used in IContentQuery implementation. The implementation in 1.5 was using the old Linq lib, which was itself relying on ICriteria. I tried to use it directly but it failed. So I think I will patch the current QueryOver implementation to handle those missing pieces, maybe by getting some inspiration from the old implementation too.

I am also thinking that it could be interesting to expose the QueryOver directly instead of having the HqlQuery, because it was the only solution previously, and QueryOver makes sense now for this purpose. Would be simpler, handle more scenarios, and we could benefit from the existing documentation on QO. We would just need to add a couple extension methods for Parts and Records.

Aug 18, 2012 at 9:20 PM

Does that mean that there's a possibility of dropping Hql support in favor of QueryOver? Or what are the plans?

Aug 20, 2012 at 10:59 AM

Just tried out the latest 1.x work you did over the weekend and it works well, thanks.

Are you thinking of changing Projection Queries to use QueryOver?

I have been trying to get distinct results back from Projection Queries, for now I have had to hack the ProjectionManager to manipulate the HQL directly, it gets quite tricky when dealing with counts for paging.  I have managed to get it working with NH3 now, it wouldn't work with the old version as NHibernate used the row numbers for skiping records which screwed the distinct aggregator. 

Do you think with moving to QueryOver there will be an easier way for the Projection module to give the user an option to request only distinct rows in a projection query? Duplicate rows come up a lot when using taxonomies and filtering by a parent term.  If a content item is associated with > 1 child terms they are repeated in the results.

Aug 20, 2012 at 6:28 PM

Results should be unique by default, otherwise it's a bug.

What do you think about dropping Hql and using QueryOver instead directly. The idea would just be to add a few extensions methods to QueryOver so that NH queries can be done with Orchard's content in mind, like JoinPartQueryOver<>(), WithVersion(), ... All QueryOver artifacts could be used.

Aug 21, 2012 at 11:22 PM

This would be fine for me, don't really like IHql and friends. But wouldn't this more tightly couple Orchard to NHibernate?

Aug 21, 2012 at 11:36 PM

Orchard *is* coupled to nHibernate. Get over it ;)

Aug 22, 2012 at 10:04 AM

I have filed a bug

I would vote for moving to QueryOver it will give greater control to module developers.  Will this be a breaking change, or will you leave the existing HqlQuery stuff in there? How will this work with QueryFilters, as they seem to work with IHqlQuery?

Aug 22, 2012 at 10:29 AM

I guess I'll have to live with that :-D.