To recap. The subject is "Select Count(*) with NOLOCK Ho to do that" and
after some discussion the query being used was
session
> .CreateQuery("select count(c.Number) from Candidate c
> where c.Template = :template")
> .SetLockMode("c", LockMode.None)
> .SetEntity("template", template)
> .UniqueResult();
>
where Candidate and Template are mapped classes.
I ran some tests in the trunk and then locally. Tests in the trunk work and
most local tests work, except when adding a "select x" to the HQL. This
results in :
----> System.InvalidOperationException : could not locate alias to apply
lock mode : c
So in your query they would want no lock on Person p.
John Davidson
On Sat, Jul 17, 2010 at 8:29 AM, Fabio Maulo <[email protected]> wrote:
> select o.Position, p.Name, Count(*) from Person p join p.Occupation o group
> by o.Position, p.Name
>
> No lock on what ?
>
> On Sat, Jul 17, 2010 at 9:19 AM, John Davidson <[email protected]>wrote:
>
>> The tests in the current trunk would indicate that this is not a problem,
>> where both SetLockMode and ReturnAliases both function correctly. I needed
>> to add a test to my local trunk tests to verify ReturnAliases functionality.
>> This is probably why http://216.121.112.228/browse/NH-1968 is such low
>> priority.
>>
>> When I setup tests in _my_ project using VS2010, instead of VS2008, I am
>> unable to get ReturnAliases to work at all. I am able to get SetLockMode to
>> run provided there the hql looks like "from Person p", but if I try even
>> "select Id from Person p" the error being discussed appears.
>>
>> when the query is run with LockMode.NONE it does not add the nolock hint
>> anyway, but it may be running without a lock (I just cannot verify the lock
>> state easily).
>>
>> In conclusion the tests in the trunk are either incomplete, or
>> ReturnAliases and SetLockMode have a very restricted functionality that is
>> not documented.
>>
>>
>> John Davidson
>>
>>
>> On Fri, Jul 16, 2010 at 11:09 AM, John Davidson <[email protected]>wrote:
>>
>>> It looks like the bug originates in the ReturnAliases property. This is
>>> supposed to be an array of strings containing the alias names, but it
>>> actually contains the alias position (zero-based) rather than the name.
>>>
>>> I will investigate further this evening, to see how difficult it is to
>>> fix in current trunk. I already have the failing test case.
>>>
>>> John Davidson
>>>
>>>
>>> On Fri, Jul 16, 2010 at 10:22 AM, Muhammad Shehabeddeen <
>>> [email protected]> wrote:
>>>
>>>> Looks like it is an old and unresolved bug.
>>>>
>>>>
>>>> On Fri, Jul 16, 2010 at 5:12 PM, Richard Brown (gmail) <
>>>> [email protected]> wrote:
>>>>
>>>>> I think it's the same issue reported here:
>>>>>
>>>>> http://216.121.112.228/browse/NH-1968
>>>>>
>>>>>
>>>>> *From:* Muhammad Shehabeddeen <[email protected]>
>>>>> *Sent:* Friday, July 16, 2010 2:39 PM
>>>>> *To:* [email protected]
>>>>> *Subject:* Re: [nhusers] Re: Select Count(*) with NOLOCK how to do
>>>>> that
>>>>>
>>>>> session
>>>>>> .CreateQuery("select count(c.Number) from
>>>>>> Candidate c where c.Template = :template")
>>>>>> .SetLockMode("c", LockMode.None)
>>>>>> .SetEntity("template", template)
>>>>>> .UniqueResult();
>>>>>>
>>>>>
>>>>> where Candidate and Template are mapped classes.
>>>>>
>>>>> On Fri, Jul 16, 2010 at 4:26 PM, John Davidson
>>>>> <[email protected]>wrote:
>>>>>
>>>>>> Do you have a code snippet of how you are using SetLockMode and how
>>>>>> you create the entity that is being aliased?
>>>>>>
>>>>>> John Davidson
>>>>>>
>>>>>> On Fri, Jul 16, 2010 at 9:11 AM, Muhammad Shehabeddeen <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> So I take it that SetLockMode has a bug in it?
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Jul 16, 2010 at 3:56 PM, [email protected] <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Start a transaction with readuncommitted. It is the exact same
>>>>>>>> thing. My company has an incredibly anal DBA who demands this most
>>>>>>>> of
>>>>>>>> the time. Good thing we aren't a banking system :)
>>>>>>>>
>>>>>>>> On Jul 16, 5:29 am, MSD <[email protected]> wrote:
>>>>>>>> > I tried using SetLockMode(string alias, LockMode lockMode), but
>>>>>>>> this
>>>>>>>> > lead to an error: "could not locate alias to apply lock mode"
>>>>>>>> which I
>>>>>>>> > noticed in sql profiler. I ended up using CreateSQLQuery() which
>>>>>>>> is
>>>>>>>> > not a solution. Is there a solution?
>>>>>>>>
>>>>>>>> --
>>>>>>>> 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]<nhusers%[email protected]>
>>>>>>>> .
>>>>>>>> For more options, visit this group at
>>>>>>>> http://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]<nhusers%[email protected]>
>>>>>>> .
>>>>>>> For more options, visit this group at
>>>>>>> http://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]<nhusers%[email protected]>
>>>>>> .
>>>>>> For more options, visit this group at
>>>>>> http://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]<nhusers%[email protected]>
>>>>> .
>>>>> For more options, visit this group at
>>>>> http://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]<nhusers%[email protected]>
>>>>> .
>>>>> For more options, visit this group at
>>>>> http://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]<nhusers%[email protected]>
>>>> .
>>>> For more options, visit this group at
>>>> http://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]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>
>
>
> --
> Fabio Maulo
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://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.