美文网首页
mybatis 备忘录

mybatis 备忘录

作者: DimonHo | 来源:发表于2020-09-14 21:40 被阅读0次

问题一、执行mybatis某个查询的时候,抛出如下异常是怎么回事?

堆栈信息:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'fileType != null and (fileType=="IMAGE" OR fileType=="VIDEO" OR fileType=="PSD")'. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: fileType != null and (fileType=="IMAGE" OR fileType=="VIDEO" OR fileType=="PSD") [org.apache.ibatis.ognl.ParseException: Encountered " <IDENT> "OR "" at line 1, column 41.
Was expecting one of:
    "," ...
    "=" ...
    "?" ...
    "||" ...
    "or" ...
    "&&" ...
    "and" ...
    "|" ...
    "bor" ...
    "^" ...
    "xor" ...
    "&" ...
    "band" ...
    "==" ...
    "eq" ...
    "!=" ...
    "neq" ...
    "<" ...
    "lt" ...
    ">" ...
    "gt" ...
    "<=" ...
    "lte" ...
    ">=" ...
    "gte" ...
    "in" ...
    "not" ...
    "<<" ...
    "shl" ...
    ">>" ...
    "shr" ...
    ">>>" ...
    "ushr" ...
    "+" ...
    "-" ...
    "*" ...
    "/" ...
    "%" ...
    "instanceof" ...
    "." ...
    "(" ...
    ")" ...
    "[" ...
    <DYNAMIC_SUBSCRIPT> ...
    ]

原因:mybatis 不识别大写的OR AND 等关键词
fileType != null AND (fileType=="IMAGE" OR fileType=="VIDEO" OR fileType=="PSD") 把这里 大写的ANDOR改成小写andor即可解决。

扩展:
eq==or||
所以,以上也可以改写成fileType != null and (fileType eq "IMAGE" || fileType eq "VIDEO" || fileType eq "PSD")

相关文章

网友评论

      本文标题:mybatis 备忘录

      本文链接:https://www.haomeiwen.com/subject/evstyktx.html