In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "what is iBatis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is iBatis" this article.
What is iBatis:
Using the ORM mechanism provided by ibatis, business logic implementers are faced with pure Java objects, which is basically the same as implementing ORM through Hibernate. For specific data operations, Hibernate automatically generates SQL statements, while ibatis requires developers to write specific SQL statements. Compared with "fully automatic" ORM mechanisms such as Hibernate, ibatis provides more free space for system design because of the workload of SQL development and the concession of database portability. As a useful supplement to the "fully automated" ORM implementation, the emergence of ibatis makes sense.
Using iBatis to develop a project is a lot of work because each sql statement has to be written on its own. The general CRUD sql is sql 92 specification, basically all databases are common. I think how much development can be simplified if automatic generation of iql (ibatis sql) can be realized through hack ibatis source code. (the original idea was because ibatis for. Net implemented this feature, but ibatis for java did not.)
Just do it and decide to implement it according to the implementation of ibatis for. Net, through the parametermap of sql-map. Implement this function with minimal code.
After looking at the relevant dtd, it is found that the "parameter" node has no column definition, the "parameterMap" node has no extends definition, and there are "result" and "resultMap". So modify the dtd definition and the BasicParameterMapping class to support column. And modify the SqlMapParser class to support column and extends when initializing. The purpose of adding column is to support the java attribute to correspond to different fields. The purpose of joining extends is to reuse parametermap.
After the parameter modification is completed, we have to modify the dtd document definition to support the "generate" node. We only need the "insert", "update", "delete" and "select" nodes to support these four nodes. The "statement" and "sql" nodes are considered to be supported in the next version. Generate requires three attributes, which are table, where, and excludes. Where table represents the corresponding table and applies to all; where represents the query condition field, which is applicable to select, update and delete;excludes to indicate which parameter to exclude, and applicable to select and update.
Once the dtd document definition has been modified, you can modify the ibatis add-in class to support generate. This pointcut is difficult to find because of the careful analysis of his source code. After careful consideration, I found that ibatis and sql-map supported "include" and decided to add the parsing code of generate after include. In this way, it is more convenient to find the entry point.
Find the SqlStatementParser class, find the parseDynamicTags method, and there is the parsing of include. The judgment code in this is else if, and I add another else if of generate to OK. After a day of revision, it is completed. The workload is not too heavy.
The above is all the contents of this article "what is iBatis?" thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.