It also allows you to specify opening and closing strings, and add a separator to place in between iterations. The foreach element is very powerful, and allows you to specify a collection, declare item and index variables that can be used inside the body of the element. The most common thing to do in dynamic SQL is conditionally include a part of a where clause. MyBatis employs powerful OGNL based expressions to eliminate most of the other elements: MyBatis 3 greatly improves upon this, and now there are less than half of those elements to work with. In previous versions of MyBatis, there were a lot of elements to know and understand. The Dynamic SQL elements should be familiar to anyone who has used JSTL or any similar XML based text processors. While working with Dynamic SQL will never be a party, MyBatis certainly improves the situation with a powerful Dynamic SQL language that can be used within any mapped SQL statement. Dynamic SQL can be downright painful to deal with. If you have any experience with JDBC or any similar framework, you understand how painful it is to conditionally concatenate strings of SQL together, making sure not to forget spaces or to omit a comma at the end of a list of columns. One of the most powerful features of MyBatis has always been its Dynamic SQL capabilities.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |