Reputation: 71
My goal is to use the MSSQL Fulltext Function with HQL. For what case I wrote a specific SQLFunction mapping the my "fulltext" function to the contains function.
However, the problem is that in HQL (it seems) I have to explicity use a return type, which the MSSQL Contains functions does not use or accepts.
This is how it works in MSSQL:
select distinct id from content c where CONTAINS(c.content, 'p')
This is my idea of using it in HQL:
select id from Content c where fulltext(c.content, 'p')
This does not work, since HQL needs a return type. For example this will parse in HQL:
select id from Content c where fulltext(c.content, 'p') = true
And it will generate as SQL:
select distinct id from content c where CONTAINS(c.content, 'p') = 1
which will not work in MS SQL.
My ideas are so far but what does not seem possible in this setup:
Anyone got another idea or help?
My Hibernate Version used is 3.2.6ga and MSSQL Server 2008.
Upvotes: 3
Views: 3612
Reputation: 71
I found a way what works for me.
Instead of generating
CONTAINS(a,b)
it will generate
CONTAINS(a,b) AND 1
And in conjunction with the HQL Query
fulltext(a,b) = true
It will result in:
CONTAINS(a,b) AND 1 = 1
And it works.
Upvotes: 4