NutzCN Logo
问答 Cnd is连用报错
发布于 1928天前 作者 邓华锋 1366 次浏览 复制 上一个帖子 下一个帖子
标签:
SqlExpressionGroup se = Cnd.exps("1", "=", 1);
				if (taskId != null) {
					se.and("taskId", "=", taskId);
				}
		
				se.and("status", "=", 1);
				SqlExpressionGroup se2 = Cnd.exps("published", "is", false).or("published", "is", null);
				// 获取未发布成功的数据,进行导入
				Pager pager = dao.createPager(1, 5);
				List<Record> records = dao.query(tableName Cnd.where(se).and(se2), pager);

报如下错误

SELECT * FROM  task_publish_record WHERE (1=1 AND taskId=1 AND status=1) AND (published IS false OR published IS NULL ) LIMIT 0, 5 
2019-08-06 17:19:34,485 [DEBUG] ao.impl.sql.run.NutDaoExecutor  - SQLException
java.sql.SQLSyntaxErrorException: (conn=20342) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0 OR published IS NULL ) LIMIT 0, 5' at line 1
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:242)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:171)
SqlExpressionGroup se2 = Cnd.exps("published", "is", false).or("published", "is", null);

代码改成

SqlExpressionGroup se2 = Cnd.exps("published", "=", 0).or("published", "is", null);

就不报错了,上面的日志打印出的sql语句在mysql客户端程序执行都没问题,什么问题导致的?

2 回复

mysql控制台执行的是含参数的文本sql,nutz执行的是带?的perpared stat和参数矩阵,特殊情况会有差异

添加回复
请先登陆
回到顶部