hibernate支持纯sql的,给你一个我写的一个方法,希望有所帮助
public Date getLatestBugOpenTimeByProjId(int projectId) throws Exception {
String sql="select max(openedDate) as latestdate from BugInfo where projectid="+projectId;
java.sql.ResultSet rs = this.executeJdbcQuery(sql);
if(rs.next()) {
Date latestDate=rs.getDate("latestdate");
//java.sql.Date date = rs.getDate("latestdate");
return latestDate;
}
return null;
}