Why use MyBatis XML based Mapped Statements to execute custom SQL queries? One useful case is when SQL statements have to be separated from Java code (so that for example SQL statements can be modified without modifying Java code). Another useful case is when working with complicated statements, as mentioned in the MyBatis documentation
"The annotations are a lot cleaner for simple statements, however, Java Annotations are both limited and messier for more complicated statements. Therefore, if you have to do anything complicated, you're better off with XML mapped statements."
"The annotations are a lot cleaner for simple statements, however, Java Annotations are both limited and messier for more complicated statements. Therefore, if you have to do anything complicated, you're better off with XML mapped statements."