Like most answers this really depends on a lot of different factors.

For data integrity I prefer to use a database constraint.

Where is gets a little complicated is if you are using caching inside of ibatis.

A simple example might be a airline flight with many reservations.

If you have different caches for both the flights table and the reservations table you could run into problems with relying on the DB constraint. If you only told the flights cache to clear then you would have bad data in your reservations cache. iBatis does allow for you to have the reservations cache to clear when a change is made to the flights cache. I guess I defeated my own argument :)

I guess I don't really see a problem with using both. You never know when you will create a second or third client to connect to the same DB so the constraint should be use. But to keep the application and the DB loosely coupled I would also code this into the service layer of my app.

Hope this helps,
Nathan

On Dec 21, 2005, at 2:45 PM, Warren Bell wrote:

I have an object with a list. I want to delete the items in the list and the object too. Is it better to let a foreign key do this in the database or have IBATIS do it? If IBATIS, should I run two deletes for the object and
items, or does Ibatis have a better way?

Thanks,

Warren Bell
Systems Administrator
Clark's Nutritional Centers
4225 Market St.
Riverside, CA 92501
951-321-1960 ext. 142
909-645-8864 mobile


Reply via email to