cancel
Showing results for 
Search instead for 
Did you mean: 

Query Bug?MySQLSyntaxErrorException

croc1
Champ in-the-making
Champ in-the-making
Hi,all
When I inovk this method
repositoryService.createProcessDefinitionQuery().processDefinitionNameLike("%%");

then it throw a MySQLSyntaxErrorException


org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'PD.NAME_ like '%%'' at line 9
### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.selectProcessDefinitionCountByQueryCriteria_mysql-Inline
### The error occurred while setting parameters
### Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'PD.NAME_ like '%%'' at line 9
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:80)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38)
   at org.activiti.engine.impl.db.DbSqlSession.selectOne(DbSqlSession.java:201)
   at org.activiti.engine.impl.persistence.entity.ProcessDefinitionManager.findProcessDefinitionCountByQueryCriteria(ProcessDefinitionManager.java:52)
   at org.activiti.engine.impl.ProcessDefinitionQueryImpl.executeCount(ProcessDefinitionQueryImpl.java:212)
   at org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:144)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)

Caused by:

Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'PD.NAME_ like '%%'' at line 9
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2934)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1616)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1708)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:3255)
   at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1293)
   at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:867)
   at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:39)
   at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55)
   at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41)
   at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:238)
   at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:112)
   at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78)

why  '%%'' my parameter is "%%"

THX!
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
The additional ' is added in the mysql stack trace message. You can't actually do 'LIKE %%', because that just matches everything… You should have at least ONE non-wildcard character in the parameter…