I had to learn about jpetstore yesterday, so I checked the document on the ibatis official website today.
It is indeed worth learning and applying SQL maps.
------
Ibatis can be said to be very easy to use. You only need to understand JavaBeans, XML, and SQL to apply them smoothly.
This is also the charm of ibatis (I think so)
Ibatis provides a simple and flexible solution for ing javaobject and database.
We only need to use pure SQL statements to convert data from the database to javaobject, instead of writing JDBC code.
This helps us save a lot of time on code.
Ibatis SQL maps requires a simple XML description file to correspond to the relationship between the database and javaobjec.
And other advantages
The following are some ibatis-related features obtained from the ibatis Website:
| 10 |
Works with any database that has a JDBC Driver (no plugins required) |
| 9 |
Retriable caching (including dependencies) |
| 8 |
Local and global transaction support and management (JTA) |
| 7 |
Simple XML mapping document structure |
| 6 |
Supports map, collection, list and primitive wrappers (integer, string etc .) |
| 5 |
Supports JavaBeans classes (get/set methods) |
| 4 |
Supports complex object mappings (populating lists, complex object models etc .) |
| 3 |
Object models are never perfect (no changes required !) |
| 2 |
Database designs are never perfect (no changes required !) |
| 1 |
You already know SQL, why waste time learning something else? |
------
Through the following simple example, I believe that the colleagues who are still unfamiliar with ibatis will be excited. I want to train my hands right away.
Environment:
Required class libraries:
Ibatis utilities-ibatis-common.jar
Ibatis SQL maps framework-ibatis-sqlmap.jar
A simple sqlmap definition snippet:
<Select id = "getaddress" parameterclass = "int"
Resultclass = "examples. domain. Address">
Select
Adr_id as ID,
Adr_description as description,
Adr_street as Street,
Adr_city as city,
Adr_province as Province,
Adr_postal_code as postalcode
From Address
Where adr_id = # value #
</SELECT>
Code in specific implementation:
Integer PK = new INTEGER (5 );
Address = (Address) sqlmap. queryforobject ("getaddress", PK );
It's just that simple.
------
More and better information can go to http://www.ibatis.com to find, Chinese tutorials also have oh