使用下面的函数来获取sql date的月份。但是我没有得到正确的信息,它显示异常,任何人都请帮帮我
public static List<data> getCount(Long month,String activity)
{
session = HibernateUtils.getHibernateConnection();
Criteria c = session.createCriteria(Statement.class, "statement");
Criteria text = c.createAlias("activity", "activity");
c.add(Restrictions.eq("activity.defintionType",activity));
c.add(Restrictions.eq("month(statement.stored)",month));
alist= c.list();
}
答案 0 :(得分:2)
更改此行:
c.add(Restrictions.eq("month(statement.stored)",month));
到此:
c.add(Restrictions.sqlRestriction("month(stored) = ? ", 1,Hibernate.INTEGER));
假设提供的月份参数是数字类型。