title: How to use Mysql variables with Hibernate?
body: <p>I need to use a native sql query in Hibernate with use of variable.</p>
  
  <p>But hibernate throws an error saying: Space is not allowed after parameter prefix</p>
  
  <p>So there is a conflict with the := mysql variable assignment and hibernate variable assignment.</p>
  
  <p>Here is my sql query: </p>
  
  <pre><code>SET @rank:=0; 
  UPDATE Rank SET rank_Level=@rank:=@rank+1 ORDER BY Level;
  </code></pre>
  
  <p>the hibernate code (jpa syntax):</p>
  
  <pre><code>Query query = em.createNativeQuery(theQuery);
  query.executeUpdate();
  </code></pre>
  
  <p>I can't use a stored procedure because my sql query is dynamically generated ('Level' can be 'int' or 'force'...)</p>
  
  <p>How can I do this ?</p>
  
  <p>thanks</p>