我有一個MySQL查詢,我想將這個查詢轉換爲Hibernate查詢。這是我到目前爲止嘗試過的。將mysql查詢轉換爲hibernate查詢
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);
給你的MySQL查詢,以獲取有關什麼ü[R問清晰的概念。 – OO7
@ user000324我想問如何在查詢和STR_TO_DATE在休眠 – user3441816