Hi,
I've recently upgraded from NHibernate v2.1 to v3.3.3.
For reasons that I'm not going to go into now, I'm forced to build a fairly
complex query with ICriteria, and then "extract" the raw SQL statement from
it, before proceeding with other actions.
This piece of code below worked absolutely fine to obtain the Where
clause's values (to replace the "?" characters in the raw SQL statement),
but once upgraded to v3.3.3 it only results in an empty object array.
private String GetGeneratedSql(ICriteria criteria)
{
NHibernate.Impl.CriteriaImpl criteriaImpl =
(NHibernate.Impl.CriteriaImpl)criteria;
NHibernate.Impl.SessionImpl sessionImpl =
(NHibernate.Impl.SessionImpl)criteriaImpl.Session;
NHibernate.Impl.SessionFactoryImpl factory =
(NHibernate.Impl.SessionFactoryImpl)sessionImpl.SessionFactory;
string[] implementors =
factory.GetImplementors(criteriaImpl.EntityOrClassName);
NHibernate.Loader.Criteria.CriteriaLoader loader = new
NHibernate.Loader.Criteria.CriteriaLoader((NHibernate.Persister.Entity.IOuterJoinLoadable)factory.GetEntityPersister(implementors[0]),
factory, criteriaImpl, implementors[0], sessionImpl.EnabledFilters);
object[] paramValues =
loader.Translator.GetQueryParameters().PositionalParameterValues;
}
So, instead of having the parameter values in the paramValues variable, I
have only an empty array with v3.3.3. Note that I'm using .NET4.0 (VS2012),
and using intellisense, I can see that loader.Translator correctly has
values for its properties when I hover my mouse over that variable, and I
can access those values via intellisense too e.g. the namedParameters property
expands to show all the Where clause's parameters and their values.
Is there something wrong with, or different to, the GetQueryParameters()
method that I need to know about in the new NHibernate version, in order to
get parameter values via this method? I cannot find any reference to
GetQueryParameters or PositionalParameterValues in the NHibernate
documentation. Also no mention of these objects/methods in the NHibernate
release notes.
I've also tried using a CriteriaJoinWalker, same result ~ empty object
array.
Any help would be appreciated.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.