简体   繁体   English

获取异常org.hibernate.exception.SQLGrammarException:

[英]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.

相关问题 获取异常:org.hibernate.exception.sqlgrammarexception - Getting Exception : org.hibernate.exception.sqlgrammarexception JPA 异常:org.hibernate.exception.SQLGrammarException - JPA Exception: org.hibernate.exception.SQLGrammarException Spring Hibernate:org.hibernate.exception.SQLGrammarException - Spring hibernate: org.hibernate.exception.SQLGrammarException InvalidDataAccessResourceUsageException:org.hibernate.exception.SQLGrammarException: - InvalidDataAccessResourceUsageException: org.hibernate.exception.SQLGrammarException: 嵌套的异常是org.hibernate.exception.SQLGrammarException:无法执行查询 - nested exception is org.hibernate.exception.SQLGrammarException: could not execute query Spring MVC JPA异常org.hibernate.exception.SQLGrammarException - Spring MVC JPA exception org.hibernate.exception.SQLGrammarException 引起:org.hibernate.exception.SQLGrammarException: JDBC 异常执行 SQL - Caused by: org.hibernate.exception.SQLGrammarException: JDBC exception executing SQL org.hibernate.exception.SQLGrammarException:无法插入,使用mysql休眠 - org.hibernate.exception.SQLGrammarException: could not insert, hibernate with mysql org.hibernate.exception.SQLGrammarException:休眠不会加入列 - org.hibernate.exception.SQLGrammarException: hibernate will not join column 通过Hibernate使用MySQL:org.hibernate.exception.SQLGrammarException - using MySQL by Hibernate : org.hibernate.exception.SQLGrammarException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM