title: Hibernate + MSSQL + Fulltext Search via Contains
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>This is how it works in MSSQL:</p>
  
  <pre><code>select distinct id from content c where CONTAINS(c.content, 'p')
  </code></pre>
  
  <p>This is my idea of using it in HQL:</p>
  
  <pre><code>select id from Content c  where fulltext(c.content, 'p') 
  </code></pre>
  
  <p>This does not work, since HQL needs a return type. For example this will parse in HQL:</p>
  
  <pre><code>select id from Content c  where fulltext(c.content, 'p') = true
  </code></pre>
  
  <p>And it will generate as SQL:</p>
  
  <pre><code>select distinct id from content c where CONTAINS(c.content, 'p') = 1
  </code></pre>
  
  <p>which will not work in MS SQL.</p>
  
  <p>My ideas are so far but what does not seem possible in this setup:</p>
  
  <ol>
  <li>Make hibernate parse functions with no return value (Hibernate does not support this in my version used)</li>
  <li>Trying to mix HQL and SQL (also does not seem to work)</li>
  </ol>
  
  <p>Anyone got another idea or help?</p>
  
  <p>My Hibernate Version used is 3.2.6ga and MSSQL Server 2008.</p>