Hibernate + MSSQL +全文搜索通过包含 [英] Hibernate + MSSQL + Fulltext Search via Contains
问题描述
这是MSSQL中的工作原理:
从内容c中选择不同的ID,其中CONTAINS(c.content,'p')
这是我在HQL中使用它的想法:
从Content c中选择id where fulltext(c.content,'p')
这不起作用,因为HQL需要返回类型。例如,这将在HQL中解析:
从内容c中选择id fulltext(c.content,'p')= true
它会以SQL的形式生成:
<$ p
在MS SQL中不起作用。 我的想法很到位,但在这种设置中似乎不可能: 任何人有另一个想法或帮助? 我使用的Hibernate版本是3.2.6ga和MSSQL Server 2008。 为我工作。 而不是生成 它会生成 结合HQL Query 它将导致: 它很有用。 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: This is my idea of using it in HQL: This does not work, since HQL needs a return type. For example this will parse in HQL: And it will generate as SQL: 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. I found a way what works for me. Instead of generating it will generate And in conjunction with the HQL Query It will result in: And it works. 这篇关于Hibernate + MSSQL +全文搜索通过包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
CONTAINS(a,b)
CONTAINS(a,b)AND 1
全文(a,b)= true
pre $ CONTAINS(a,b)AND 1 = 1
select distinct id from content c where CONTAINS(c.content, 'p')
select id from Content c where fulltext(c.content, 'p')
select id from Content c where fulltext(c.content, 'p') = true
select distinct id from content c where CONTAINS(c.content, 'p') = 1
CONTAINS(a,b)
CONTAINS(a,b) AND 1
fulltext(a,b) = true
CONTAINS(a,b) AND 1 = 1