mysql - Grails 中的 SQL 语法错误 MySQLSyntaxErrorException

标签 mysql grails

我确实向 MySQL 数据库发出请求,它按条件搜索表中的数据:

def tableAcounting(){
    def user = Person.findByUsername(springSecurityService.currentUser.username)
    def cafee = user.cafee
    def tablesQuery = TablePlacesInfo.createCriteria()
    def tables = tablesQuery.list {            //AN ERROR SHOW ON THIS STRING
        'in'("hall", HallsZones.findAllByCafee(cafee))
    }
    def halls = cafee.halls

但是我收到这样的错误:

Class:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
Message:You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version
for the right syntax to use near ')' at line 1

最佳答案

如果您使用空集进行 in 搜索,通常会发生这种情况。这意味着您需要检查 HallsZones.findAllByCafee(cafee) 的大小,因为该集合可能为空。

关于mysql - Grails 中的 SQL 语法错误 MySQLSyntaxErrorException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30642845/

相关文章:

mysql - MySQL 表名中的特殊字符

mysql - Spring Data JPA - 对 crud 存储库的 native 查询与连接一起使用?

grails - 不使用Neo4j GORM插件的Grails应用程序的Neo4j数据库

chalice : how to customize order with a sql function?

php - group by laravel eloquent 子查询结果之和

mysql - 使用类别表创建 MySQL View

php - 如何检查结果条件

grails - 关于RestfulController的Grails文档:嵌套资源查询包含id == id

hibernate - 如何使用Gorm DetachedCriteria获取ScrollableResults?

grails - 在 Groovy 中检查集合是否为 null 或为空