title: How can I use MySQL assign operator(:=) in hibernate native query?
body: <p>I'm using Hibernate. I wrote some native query because I need to use sub select statement.</p>
  
  <p>Query looks like this:</p>
  
  <pre><code>SELECT sub.rownum FROM 
      (SELECT k.`news_master_id` AS id, @row := @row + 1 AS rownum 
          FROM keyword_news_list k 
          JOIN (SELECT @row := 0) r 
          WHERE k.`keyword_news_id` = :kid
      ORDER BY k.`news_master_id` ASC) AS sub 
  WHERE sub.id  = :nid
  </code></pre>
  
  <p>When I run this query like this:</p>
  
  <pre><code>sessionFactory.getCurrentSession()
      .createSQLQuery(query)
      .setParameter("kid", kid)
      .setParameter("nid", nid)
      .uniqueResult();
  </code></pre>
  
  <p>This exception comes out:</p>
  
  <pre><code>org.hibernate.QueryException: Space is not allowed after parameter prefix ':' ....
  </code></pre>
  
  <p>This might because of <code>:=</code> operator. I found some <a href="https://hibernate.onjira.com/browse/HHH-2697" rel="noreferrer">Hibernate issue</a> about this. This issue is still open. Isn't there any solution for this problem?</p>