PDA

View Full Version : Where to put business logic with DAO pattern



sniederb
May 19th, 2006, 01:00 PM
Hi

I'm familiar with the DAO pattern and can read everywhere that it enables to separate data access from business logic. I'm now designing an application with some heavy business logic and encouter the following dilemma:

Given an OrderDataTransferObject (OrderDto) and a OrderWithBusinessLogic (OrderLogic), how do I link these two? I'd actually like OrderLogic to extend OrderDto, as this will automatically give getter / setter methods for all relevant attributes, of which I can override those which trigger some business logic.

Using hibernate however, my DAO implementation will deliver a OrderDto, not an OrderLogic. I find some patterns where OrderLogic contains an OrderDto as delegate, but I find this solution inferior, as adding a new DB field will require changing both OrderDto and OrderLogic.

What is the "Spring-way" to do this?

Thanks
Simon

Costin Leau
May 19th, 2006, 03:24 PM
See the architecture forum. If you want some in-depth discussion I strongly recommend to read at least of the books on Spring (you can find some of them here: http://www.springframework.org/bookreview).