Assuming a basic understanding of iBatis, and why it is such a great choice as a database framework, I will skip ahead to the topic of configuring the classes and sql map files that iBatis requires.
As simple as it is to configure and use iBatis, as your application grows and the data model expands, you will require a growing number of sql map files, and supporting java classes (the model class, and the dao classes).
This is where iBator comes to the rescue. This is an application (that can integrate with eclipse) that generates all of these iBatis assets for you!
I have uploaded a portion of my config file for your reference, and also to point out a few special cases: abatorConfig.xml
Special case #1: Defining CLOBS
As you can see in the config file, the 'business' table has a few CLOBs, but iBator doesn't recognize this field type, so you must override the column, and specify it as VARCHAR.
Special case #2: Changing the model object name
The normal process for iBator is to create model classes with the name matching the table name. For example, the 'User' table will be converted into 'User' a object.
But in my case, I have a table named "geolitecitylocation", and I wanted the object to simply be called "Location". The sample config file demonstrates how to do this.
Now, if you update a table by adding a new column, you simply need to re-execute the "Generate iBatis Artifacts" process, and the classes and sql maps will be updated automatically!
There are a couple of exceptions to this rule: If you add a new table, you must also update the SqlMapConfig file (to include the reference to the new sql map xml file).
Also, I have had to make some manual changes to the DAO Impl java files so that Spring can manage the DAOs as Spring managed beans.
| Powered by Nabble | See how NAML generates this page |