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