日期:2014-05-16  浏览次数:20756 次

Hibenate hql 中使用mysql函数DATE_SUB出错
String hql = "Update Threads set lastPost='"+ author + "' ," + "lasttime=DATE_SUB(lasttime,INTERVAL 1 YEAR)" + " where tid="+ tid;

不知道Hql语句写错没有,执行时出错!

org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 1 near line 1, column 90 [Update com.prebbs.models.Threads set lastPost='hyy' ,lasttime=DATE_SUB(lasttime,INTERVAL 1 YEAR) where tid=48]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 1 near line 1, column 90 [Update com.prebbs.models.Threads set lastPost='hyy' ,lasttime=DATE_SUB(lasttime,INTERVAL 1 YEAR) where tid=48]