Graham Bunce
unread,Nov 23, 2009, 8:30:16 AM11/23/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nhusers
All,
Trying to use SetLockMode with an IQuery. I don't fully understand
what the alias means (documentation isn't that clear, could do with an
example) but I think it refers to the object being locked.
I have the following statement:
IDomainClassChild child = session.CreateQuery("FROM DomainClassChild
WHERE ChildName = :name")
.SetString("name", "Donna Nobel")
.SetMaxResults(1)
.SetLockMode(string.Empty, LockMode.Upgrade)
.UniqueResult<IDomainClassChild>();
and it fails with an NHibernate ADOException, message is:
could not execute query
[ select domainclas0_.Id as Id1_, domainclas0_.ParentId as ParentId1_,
domainclas0_.ChildName as ChildName1_, domainclas0_.Counter as
Counter1_ from DomainClassChild domainclas0_ where
domainclas0_.ChildName=? ]
Name:name - Value:Donna Nobel
[SQL: select domainclas0_.Id as Id1_, domainclas0_.ParentId as
ParentId1_, domainclas0_.ChildName as ChildName1_,
domainclas0_.Counter as Counter1_ from DomainClassChild domainclas0_
where domainclas0_.ChildName=?]
As far as I can tell, there isn't a lot wrong with the query NH has
produced.
I've also used the LockMode with "DomainClassChild" as the alias
instead of string.Empty, and as the internal NH created reference
"domainclas0" but no difference. If I take out the lock mode, the
query works.
What should this alias be... or how do I use LockMode on an IQuery?