iBATIS Result Maps - iBATIS

What are result maps?

The resultMap element is the most important and powerful element in iBATIS. Use iBATIS ResultMap to reduce up to 90% JDBC coding with this. You can also perform some acts which cannot be supported by JDBC.

ResultMaps is designed in such a way that simple statements don't require explicit result mappings at all, and more complex statements require no more than is absolutely necessary to describe the relationships.

Here you can learn about the introduction of iBATIS ResultMaps.

Let’s see the following EMPLOYEE table in MySQL −

This table has two records as follows −

Employee POJO Class

To use iBATIS ResultMap, you do not need to modify the Employee.java file. Let us keep it as it was in the last chapter.

Employee.xml File

Here we would modify Employee.xml to introduce <resultMap></resultMap> tag. This tag would have an id which is required to run this resultMap in our <select> tag's resultMap attribute.

IbatisResultMap.java File

This file has application level logic to read records from the Employee table using ResultMap −

Compilation and Run

Following steps are used to compile and run the above-mentioned software. Let’s have set PATH and CLASSPATH appropriately before proceeding for compilation and execution.

  • Create Employee.xml as shown above.
  • Create Employee.java as shown above and compile it.
  • Create IbatisResultMap.java as shown above and compile it.
  • Execute IbatisResultMap binary to run the program.

After executing the above program you will get the following result which is a read operation on the EMPLOYEE table.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

iBATIS Topics