我在TrainSeat表中有日期列。我希望使用where clause.In where claue,指定日期条件来检索数据。
Seats=(ArrayList<TrainSeat>)session.createQuery("from TrainSeat t where t.train.TrainNumber="+TrainNum+"and t.date="+date+"").list();
这里的' Date‘是日期数据类型的实例
此语句提供以下错误
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: Mar near line 1, column 80 [from org.irctc.admin.TrainSeat t where t.train.TrainNumber=11007and t.date=Wed Mar 27 00:00:00 IST 2013]发布于 2013-03-25 15:54:11
您的日期正在转换为字符串,there.You可以将日期作为参数传递到字符串中。
试着这样做
String hql = "from TrainSeat t where t.train.TrainNumber=? and t.date=?";
List result = session.createQuery(hql)
.setString(0, TrainNum)
.setParameter(1,date)
.list();https://stackoverflow.com/questions/15609871
复制相似问题