1
此語句用於檢查用戶是否存在於數據庫中。如何將此語句更改爲分離標準
public boolean isExisting(int userId) {
String sql = "{call isExistingUser(?)}";
Session session = null;
boolean isExisting = false;
try {
session = getSession();
SQLQuery query = session.createSQLQuery(sql);
query.setParameter(0, userId);
List<?> list = query.list();
isExisting = list.get(0) != null ? (Boolean) list.get(0) : false;
} finally {
if (session != null)
session.close();
}
return isExisting;
}
這是存儲過程:
CREATE DEFINER = cbsadmin
@%
PROCEDURE isExistingUser
(IN用戶id INT) BEGIN SELECT USER_ID FROM USER_LOGIN_STATUS WHERE USER_ID =用戶id; END
好的,非常感謝!真的幫助.. –