Do ORMs enable the creation of rich domain models?

Posted by Augusto on Programmers See other posts from Programmers or by Augusto
Published on 2012-03-21T10:41:47Z Indexed on 2012/03/21 11:38 UTC
Read the original article Hit count: 280

Filed under:
|
|
|
|

After using Hibernate on most of my projects for about 8 years, I've landed on a company that discourages its use and wants applications to only interact with the DB through stored procedures.

After doing this for a couple of weeks, I haven't been able to create a rich domain model of the application I'm starting to build, and the application just looks like a (horrible) transactional script.

Some of the issues I've found are:

  • Cannot navigate object graph as the stored procedures just load the minimum amount of data, which means that sometimes we have similar objects with different fields. One example is: we have a stored procedure to retrieve all the data from a customer, and another to retrieve account information plus a few fields from the customer.
  • Lots of the logic ends up in helper classes, so the code becomes more structured (with entities used as old C structs).
  • More boring scaffolding code, as there's no framework that extracts result sets from a stored procedure and puts it in an entity.

My questions are:

  • has anyone been in a similar situation and didn't agree with the store procedure approch? what did you do?
  • Is there an actual benefit of using stored procedures? appart from the silly point of "no one can issue a drop table".
  • Is there a way to create a rich domain using stored procedures? I know that there's the posibility of using AOP to inject DAOs/Repositories into entities to be able to navigate the object graph. I don't like this option as it's very close to voodoo.

© Programmers or respective owner

Related posts about java

Related posts about design