Dear all,
I have been using nhibernate and hibernate for a long time and I am
facing a pretty interesting problem.
The query I have to deal with returns a list of candidates by matching
their resume (a word file, stored as a varbinary(max) in the DB and
mapped to a byte[] in the POCO) with a full text expression (exemple :
nhibernate AND (Oracle OR "SQL Server") ).
The query uses CONTAINSTABLE to process the fulltext search and order
the results by RANK Desc.
<sql-query name="find" >
<return alias="c" class="Candidate" />
select
c.Id_candidate as {c.Id},
c.Name as {c.Name}
from
CANDIDATE c
INNER JOIN CONTAINSTABLE(CANDIDATE, RESUME, :keyword) x on
c.ID_CANDIDATE=x.[KEY]
order by
x.RANK desc
</sql-query>
It woks fine but I need to get the rank value in the results. Of
course I do not have any 'Rank' property in my Candidate c# class. And
even if I had one I would not be able to use it the select
clause because this field is not mapped to any column.
I tried to return a list of KeyValuePair<Candidate, int> where the
value is the quality of the result within the specific search
regarding the search expression :
<sql-query name="find" >
<return alias="c"
class="System.Collections.Generic.KeyValuePair`2[[MyNamespace.Candidate],
[System.Int32]]" />
select
c.Id_candidate as {
c.Key.Id},
c.Name as {
c.Key.Name},
x.RANK as {c.Value}
from
CANDIDATE c
INNER JOIN CONTAINSTABLE(CANDIDATE, RESUME, :keyword) x on
c.ID_CANDIDATE=x.[KEY]
order by
x.RANK desc
</sql-query>
but it does not work, the application crashs at startup when
nhibernate try to 'compile' mapping file (message : "Errors in named
queries: {find}")
Any Idea ?
Thanks.