title: MS SQL Server Full Text search with JPA and EclipseLink
body: <p>MSSQL 2008
  EclipseLink 2.3.0
  JPA 2.0</p>
  
  <p>I am trying to make an JPQL query to use a fulltext search function of an MSSQL.</p>
  
  <p>as we know that FUNC addictional EclipseLink function doesn't work [1] as it expects the return value, while MSSQL <code>freetext</code> [2] is not actually a function but some magic predicate looking like a function [3], I am trying to use the next powerful function mentioned in [4], <code>SQL</code></p>
  
  <p>i tried this</p>
  
  <pre><code>and SQL('freetext(?, ?)', d.title, :title) 
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>and SQL('freetext(?, :title)', d.title) 
  </code></pre>
  
  <p>and that combinations with  =1 endings</p>
  
  <pre><code>and SQL('freetext(?, ?)', d.title, :title) = 1
  </code></pre>
  
  <p>without any success. it says something like</p>
  
  <p>line 5, column 7: unexpected token [(].
  Internal Exception: NoViableAltException(83@[()* loopback of 383:9: (d= DOT right= attribute )<em>])] with root cause
  NoViableAltException(83@[()</em> loopback of 383:9: (d= DOT right= attribute )*])</p>
  
  <p>where the line 5, column 7 is around the first open parenthesis after SQL keyword.</p>
  
  <p>i am trying to avoid the native SQL as I want to use the advantage of not writing joins with many one-to-many related classes.</p>
  
  <p>what is the correct way to use SQL special function?</p>
  
  <p>[1] <a href="https://stackoverflow.com/questions/9186845/how-to-use-mysqls-full-text-search-from-jpa">How to use MySQL&#39;s full text search from JPA</a></p>
  
  <p>[2] <a href="http://msdn.microsoft.com/en-us/library/ms176078(v=sql.105).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms176078(v=sql.105).aspx</a></p>
  
  <p>[3] <a href="https://stackoverflow.com/questions/9488094/hibernate-mssql-fulltext-search-via-contains">Hibernate + MSSQL + Fulltext Search via Contains</a></p>
  
  <p>[4] <a href="http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Support_for_Native_Database_Functions#SQL" rel="nofollow noreferrer">http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Support_for_Native_Database_Functions#SQL</a></p>