Ibatis SQL maps

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.