Awesome, didnt notice that particular method was public. thanks for the heads up.
On May 23, 4:08 am, "Richard Brown \(gmail\)" <[email protected]> wrote: > Yes, exactly. > > I'm not suggesting it's a great idea (the best idea would be to get 3.2 with > the fix) ... but the CriteriaImpl has an IterateSubcriteria() which returns > the underlying subcriterialist ... and I reckon you could set (copy) the > missing withClause property from the original SubCriteria on the cloned > SubCriteria that has it missing. > > > > > > > > -----Original Message----- > From: birchoff > Sent: Sunday, May 22, 2011 5:15 PM > To: nhusers > Subject: [nhusers] Re: back porting QueryOver withClause support to NH3 > > I figured out this was not an issue in 3.2 and if I implied that it > was I am sorry. > > As for your suggestion, how would I go about doing that? It sounds > like a good solution but off the top of my head I would need to be > able to iterate over all the Criterias created for each join and > figure out which one had the withClause attached to it. Then use > reflection to set the field with the correct value. > > On May 22, 9:32 am, "Richard Brown \(gmail\)" > <[email protected]> wrote: > > > that was not fixed until 3.2 > > > Just to clarify ... it's all ok in 3.2 now? > > > Another option (which may or may not be palatable) is to use reflection to > > fix the incorrectly cloned criteria. Or ... upgrade to NH3.2 beta? (I > > doubt you'll have long to wait for the RC version anyway.) > > > -----Original Message----- > > From: birchoff > > Sent: Saturday, May 21, 2011 7:27 PM > > To: nhusers > > Subject: [nhusers] Re: back porting QueryOver withClause support to NH3 > > > Ok I think I completely understand whats going on here. Even though > > withClause was implemented in NH3.0GA it seems there was a bug with > > the implementation that was not fixed until 3.2. That bug being that > > the clone operation does not copy the withClause from the original > > criteria. So when the new criteria created by the clone is executed it > > doesn't generate the join condition since there is none to generate. > > > As for a method to utilize withClause in NH3.0 in the interim it looks > > like I should be able to if either of the following works > > 1) undo all the changes made to the criteria in order to execute the > > rowcount. > > 2) Maintain two different criteria/queryover objects and apply the > > same joins/filters to them and use one for the count and the other to > > retrieve my result set. > > > of the two options I think (2) is the more palatable since the clone > > operation in RowCount is effectively doing the same thing. I would > > just need to exclude the clone call in my implementation of Count() > > method. > > > If anyone has a better suggestion I would love to hear it. > > > On May 21, 1:46 pm, birchoff <[email protected]> wrote: > > > Just finished figuring out exactly where the problem is. It seems that > > > when the criteria is cloned the withClause doesn't get applied to the > > > cloned criteria. > > > I would gladly file a JIRA ticket for this but need to know what your > > > process is for doing that. > > > > On May 21, 1:30 pm, birchoff <[email protected]> wrote: > > > > > Since it looked like using the criteria directly was going to be my > > > > only means of getting the withClause to work. I spent some time > > > > implementing a weakly type safe extension class on criteria, and > > > > discovered that the problem is simply that the join condition does not > > > > get generated when you use the code defined in > > > > > QueryOver<TRoot,TRoot> ToRowCountQuery() > > > > > to count the number of results in the result set. On the other hand if > > > > take the entire resultset into memory with List() and count the number > > > > of elements their then the join condition is correctly generated. > > > > > Does anyone know why this is happening? > > > > > On May 21, 1:22 am, birchoff <[email protected]> wrote: > > > > > > I see that the ability to use QueryOver to specify a join condition > > > > > has been added to NH 3.2 since Alpha1. Is there some special > > > > > functionality that was added only to 3.2 to support this feature? > > > > > From > > > > > a quick glance at the source it appears that I should be able to > > > > > enable this capability in NH 3.0 till our next release cycle when > > > > > the > > > > > version of NH that we use can be upgraded. > > > > > > Unfortunately when I try to use the following code to create an > > > > > extension method to bolt on this functionality it does not work. > > > > > > public static class QueryOverExtensions > > > > > { > > > > > public static QueryOver<TRoot,U> JoinQueryOver<TRoot, > > > > > TSubType, U>( > > > > > this IQueryOver<TRoot, TSubType> queryOver, > > > > > Expression<Func<U>> path, Expression<Func<U>> alias, JoinType > > > > > joinType, ICriterion withClause) > > > > > { > > > > > return new ExtendedQueryOver<TRoot, > > > > > U>(queryOver.RootCriteria, > > > > > queryOver.UnderlyingCriteria.CreateCriteria( > > > > > > ExpressionProcessor.FindMemberExpression(path.Body), > > > > > > ExpressionProcessor.FindMemberExpression(alias.Body), > > > > > joinType, > > > > > withClause)); > > > > > } > > > > > > public static QueryOver<TRoot, U> JoinQueryOver<TRoot, > > > > > TSubType, U>( > > > > > this IQueryOver<TRoot, TSubType> queryOver, > > > > > Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias, > > > > > JoinType joinType, ICriterion withClause) > > > > > { > > > > > return new ExtendedQueryOver<TRoot, > > > > > U>(queryOver.RootCriteria, > > > > > queryOver.UnderlyingCriteria.CreateCriteria( > > > > > > ExpressionProcessor.FindMemberExpression(path.Body), > > > > > > ExpressionProcessor.FindMemberExpression(alias.Body), > > > > > joinType, > > > > > withClause)); > > > > > } > > > > > > public class ExtendedQueryOver<TRoot, TSubType> : > > > > > QueryOver<TRoot,TSubType> > > > > > { > > > > > public ExtendedQueryOver(ICriteria rootImpl, ICriteria > > > > > criteria) : base((CriteriaImpl)rootImpl, criteria) > > > > > { > > > > > > } > > > > > } > > > > > } > > > > > > However, If I use the UnderLyingCriteria property on my QueryOver to > > > > > retrieve the criteria and execute CreateCriteria directly I am able > > > > > to > > > > > generate a query with the correct join condition. > > > > > > Can someone point me to what I am doing wrong in my effort to get > > > > > this > > > > > working with QueryOver in NH 3.0 or let me know if it is not > > > > > possible > > > > > at all. > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/nhusers?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
