-1

How do we write sql queries which has bit wise operators in mybatis mapper xml. I have a query which has bitwise operator AND (&) in the where clause.

WHERE id=1000 AND NOT status&4 AND NOT status&16 ; //This is the where clause of the query. 

id and status are columns of the table. status column is INT data type. When i write this query in mybatis mapper file it shows an error for the & operator? and when application runs throws an exception

org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance
  • Does it work when you simplify the `WHERE` clause? *(Remove the bitwise operators... If it runs fine without that part, then you've shown that part is introducing the symptoms...)* – MatBailie Feb 15 '18 at 14:53

1 Answers1

1

Since you're writing the query in an XML file, you should escape the ampersand character using &.

Your queries should look like this

WHERE id=1000 AND NOT status&4 AND NOT status&16
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332