Chapter 6. Using advanced query techniques
This chapter covers
- Using XML
- Declaring relationships
- N+1 solutions
Beyond the simple database operations we have looked at in the last two chapters, iBATIS can be used to perform much more advanced tasks. In this chapter, we will examine techniques that you can use to reduce the amount of code you need to write, and you will learn ways to improve performance and minimize the footprint of your application.
Sometimes, you may need to work with XML-based data. The iBATIS framework will allow you to use XML when passing parameters into a query, and also for returning results from them. In both cases, it probably does not add much value to use XML where you do not need to—using a plain old Java object (POJO) instead is much more efficient in most cases.
In addition, it is possible that this feature will be dropped in the next major release for a couple of reasons. One of those reasons will become apparent as we look at the functionality. The other reason is that it just doesn’t fit with the philosophy of the iBATIS framework, which is to make mapping queries to objects easier.
We will take a look at this feature, in case you have a system where you have to use it; but we will also show you some ways to transition away from it so that if it does disappear, you won’t be left hanging high and dry looking for a way to make your application work.