title: Converting mysql query into hibernate query
body: <p>I have a MySQL query, and I want to convert this query in to Hibernate Query. This is what I've tried so far.</p>
  
  <pre><code>userInQuery = "SELECT * FROM log where userName in(";
  userCountQuery = "SELECT count(*) FROM log where userName in(";
  
  for (int i = 0; i &lt; users.length; i++) {
      userInQuery += "'" + users[i] + "',";
      userCountQuery += "'" + users[i] + "',";
  }
  
  userInQuery = userInQuery.substring(0, userInQuery.lastIndexOf(","))+ ") and
      systemdate  &gt;= STR_TO_DATE('" + fromDt+ "' ,'%Y-%m-%d') and systemdate  &lt;=
      STR_TO_DATE('"+ toDate + "','%Y-%m-%d')";
  
  userCountQuery = userCountQuery.substring(0, userCountQuery.lastIndexOf(","))+ ")
      and systemdate  &gt;= STR_TO_DATE('"+ fromDt+ "' ,'%Y-%m-%d') and systemdate  &lt;=
      STR_TO_DATE('"+ toDate + "','%Y-%m-%d')";
  
  //System.out.println("Final userInQuery : " + userInQuery);
  
  psmt = conn.prepareStatement(userInQuery);
  
  rscount = stmt.executeQuery(userCountQuery);
  </code></pre>