[英]getting exception org.hibernate.exception.SQLGrammarException:
@SuppressWarnings("unchecked")
@Override
@Transactional
public List<FormFields> findFormFieldsByFormFieldIds(
List<Integer> formFiledsIds) {
try {
logger.info("############### findFormFieldsByFormFieldIds dao called ################");
System.out.println("############### getDashboardXFieldByDashboardIds size : "+formFiledsIds.size());
Session session=sessionFactory.getCurrentSession();
Criteria criteria=session.createCriteria(FormFields.class);
criteria.add(Restrictions.in("fieldId", formFiledsIds)).addOrder(Order.asc("sequenceNo"));
List<FormFields> list = criteria.list();
logger.info("############### getDashboardXFieldByDashboardIds size : "+list.size());
System.out.println("############### getDashboardXFieldByDashboardIds size : "+list.size());
return list;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
Is there any thing wrong in above code? 上面的代码有什么问题吗? I got below error
我低于错误
org.hibernate.exception.SQLGrammarException: You have an error in your SQL syntax;
org.hibernate.exception.SQLGrammarException:您的SQL语法有错误。 check the manual that corresponds to your MySQL server version for the right syntax to use near ') order by this_.sequence_no asc' at line 1
检查与您的MySQL服务器版本相对应的手册,以找到正确的语法,以在第1行的this_.sequence_no asc'附近使用')顺序
The formFiledsIds
mus not be empty. formFiledsIds
不能为空。 I had such error when nothing was sent in the list. 当列表中未发送任何内容时,我遇到了这样的错误。
Just check the list size and if it's empty return empty list as result. 只需检查列表大小,如果为空,则返回空列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.