/** 获取某人在某时间段内的访问记录 */
public List getLogs (String trueName, String topDate, String bottomDate){
List list = new ArrayList();
[b]Object [] parameter={"%"+trueName+"%"};[/b]
String sql = "select s from Usrs u join u.SYSLOGSs s where [b]u.TrueName like ?[/b] and s.OpeDatetime<='"+topDate+"' and s.OpeDatetime>='"+bottomDate+"'";
list = this.getHibernateTemplate().find(sql,parameter);
return list;
}
public List getLogs (String trueName, String topDate, String bottomDate){
List list = new ArrayList();
[b]Object [] parameter={"%"+trueName+"%"};[/b]
String sql = "select s from Usrs u join u.SYSLOGSs s where [b]u.TrueName like ?[/b] and s.OpeDatetime<='"+topDate+"' and s.OpeDatetime>='"+bottomDate+"'";
list = this.getHibernateTemplate().find(sql,parameter);
return list;
}
本文介绍了一种使用Java和Hibernate查询特定用户在指定日期范围内访问记录的方法。通过构建SQL语句并利用参数化查询防止SQL注入,确保了数据的安全性和准确性。
218

被折叠的 条评论
为什么被折叠?



