Hello,
It looks as if nhibernate 2.0.1 is producing invalid sql with a
composite id using fetch="subselect"on sql server 2008. Is this a
known problem? If so, has it been fixed in the latest NHibernate?
There is a one-to-many relationship from QuestionInPaper to
CandidateAnswer.
CandidateAnswer has a huge composite key including ReleaseNo,
QuestionCode, and UniquePaperNo and a few other columns - I know
composite keys aren't recommended but we are probably stuck with
this...
QuestionInPaper mapping as follows:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="BCS.QMIS.Domain.QuestionInPaper, QMISDomain"
table="QuestionInPaper">
<composite-id>
<key-many-to-one name="Question"
class="BCS.QMIS.Domain.Question, QMISDomain">
<column name="ReleaseNo" />
<column name="QuestionCode" />
</key-many-to-one>
<key-many-to-one name="ExamPaper" column="UniquePaperNo"
class="BCS.QMIS.Domain.ExamPaper, QMISDomain" />
</composite-id>
<version name="Version" unsaved-value="0"/>
<property name="QuestionNo" type="int" />
<bag name="CandidateAnswers" inverse="true" cascade="save-update"
batch-size="20" fetch="subselect">
<key>
<column name="ReleaseNo"/>
<column name="QuestionCode"/>
<column name="UniquePaperNo"/>
</key>
<one-to-many class="BCS.QMIS.Domain.CandidateAnswer, QMISDomain"/
>
</bag>
</class>
</hibernate-mapping>
This is a simplified version of the sql produced:
SELECT * FROM CandidateAnswer
WHERE (ReleaseNo, QuestionCode, UniquePaperNo)
in (select ReleaseNo, QuestionCode, UniquePaperNo
FROM QuestionInPaper WHERE ReleaseNo=1 and QuestionCode='6')
SQLServer error:
Server: Msg 4145, Level 15, State 1, Line 3
An expression of non-boolean type specified in a context where a
condition is expected, near ',
many thanks,
Jordan.
--
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.