My Ibatis Summary

xiaoxiao2021-03-06  62

EJB is very heavy, there is no need to use a small and medium-sized project, Hibernate is good, the company lacks high level OO designers, the programmer level is not quite, iBATIS is the semi-automatic ORM stuff with myself.

After the lasting layer used Ibatis, the JDBC packaging of the past eight fairy in the team did not see it. Everyone's coding style is unified, and the small wooden board will be added to the wooden barrel. Everyone will wast the energy to waste the paging pool primary key generation and other places, and can focus on the writing of business components.

The following is a personal feeling:

1. The cache is not a pity, but which is how much the capacity of Memory Lru Fifo OSCache is set, it has to be determined according to the actual situation of the project, I usually use Memory's Weak mode. Correctly set the caching Flushonexecute statement to prevent cache possible possible possible. The premise of cache use is that the reading and writing of the table in the system must be done by ibatis, which is closed.

2. Dynamic SQL is indeed a strong point. It feels very good after familiarity. All DAO methods in iBatis only pass a value object, and complex queries are of course no exception.

3. It is best to be set to lazyload = true. If there is a complex object property, there is a certain advantage in performance.

4. Daomanager class do two things: one is a getDao method, return a DAO interface implementation (note that this interface is a declarative interface, that is, there is no interface method), used to solve the DAO layer and the SQLMAP implementation layer ( Is it a bit a bit of Spring advocated IOC's feeling); the second thing is responsible for using the DAO method of the transaction unified dispatching in the business layer, the transaction is of course placed in the Server layer, each service method is a transaction, DAO The fine grainity method of the layer is directly dealt with the database.

5. I usually write a JUnit test class directly after writing the service interface. It is the boundaries of the business layer and the web layer. It is important to test. First, it is convenient to refactor whether it destroys the function, in addition, write test Category is also a process that masters such use. Looking at a row of green through the progress bar, the mood is good.

6. About accessories: Hibernate tape is very convenient, iBatis's developers seem to feel simple enough, there is no need to get such a tool. Now there is a generator written with Perl, the DLL script of the official website, the DLL script of the table, is automatically generated by Pojo and SQLMAP XML configuration file, I Down is tested, depressed, 60% will report error, I don't know why. I wrote one with java, more stupid, write files directly, but personal feeling enough, you need to enter a SELECT statement, single table or view can, generate POJO and XML files, omitted to modify.

转载请注明原文地址:https://www.9cbs.com/read-85281.html

New Post(0)