Hello,
I am using NHibernate v3.2.0, but this issue was the same for v3.0 and
v2.1.2. When I run a particular query, the query runs fine and
returns what I expect, but I see an error while I run in debug mode:
A first chance exception of type
'System.Collections.Generic.KeyNotFoundException' occurred in
mscorlib.dll
A first chance exception of type 'NHibernate.QueryException' occurred
in NHibernate.dll
The particular query looks like:
object obj = session.CreateQuery(
"from RptCollabLink where LinkId in (select
doc.RptCollabLink.LinkId from RptCollabSourceDocument doc where
doc.DocBaseId = 123)").UniqueResult();
I have run into this error before and what I found was that the error
would occur if part of the query syntax did not match what was in the
mapping file. For example, if part of the query stated ".... where
user_id = ...." but the mapping file's property name was "UserId",
then the error would happen. Once I changed the query to be like
".... where UserId = ....", the error would not occur. For the query
in question though, I cannot find where this might be happening. My
two mapping files look like:
.........
<id name="LinkId" type="Int64" column="LINK_ID">
<generator class="sequence">
<param name="sequence">ICEBERG.SEQ_RPT_COLLAB_LINK</param>
</generator>
</id>
<bag table="ICEBERG.RPT_COLLAB_SOURCE_DOCUMENT"
name="RptCollabSourceDocuments" lazy="false" cascade="all">
<key foreign-key="rpt_collab_group_fk" column="LINK_ID" />
<one-to-many class="RptCollabSourceDocument"/>
</bag>
.................
(NOTE: I have found that it doesn't matter what the foreign-key value
is listed as)
and
.............
<id name="DocId" type="Int64" column="DOC_ID">
<generator class="sequence">
<param name="sequence">ICEBERG.SEQ_RPT_COLLAB_SOURCE_DOCUMENT</
param>
</generator>
</id>
<many-to-one name="RptCollabLink" column="LINK_ID"/>
<property name="DocBaseId" column="DOC_BASE_ID" />
...........
Since it is exactly the same error that I previsouly saw on other
queries, I have to believe the problem is the same and has something
to do with the query syntax. Any thoughts would be greatly
appreciated.
- Peter
--
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.