What Exactly is the Point of O/R Mappers ?
I had a recent email exchange with someone that was observing that they still had to be at least somewhat aware of the workings of the O/R Mapper and their database design when they designed their entity classes. “To me, this is too intrusive since I have to incorporate a lot of persistence knowledge into my design whilst I'm still designing rather than being able to play around with the design and then add on the persistence.” This actually made me think a lot of Andrew Conrad's blog postings, as well as a lot of conversations I've had with some of my architect, developer, and DBA friends over the last couple of years.
So what exactly is the point of using an O/R Mapper if its not completely “transparent”? For me the main point is freedom -- freedom to focus on the design and not the implementation. The architect and developers should gain time when using an O/R Mapper, since they don't have to write and maintain all the repetitious and boring persistence code. Yes they still have to think about persistence, but they have more time to focus on better understanding the real business needs. Similarly for the DBA -- the point is not to get rid of the DBA -- instead the DBA should be freed to better focus on the database design instead of writing stored procs.
There are other types of benefits of O/R Mappers too -- but they are also mostly about freedom. For instance, one of the main selling points of O/R Mappers to management is that you will be able to easily target multiple database platforms. That sounds like vendor freedom -- you can have your product work equally well with MS SQL, Oracle, MySql, or whatever database you want -- even the lowly Access. Another feature of O/R Mappers is greater flexibility in your search and sort functionality -- which sounds like freedom from the fixed APIs of stored procedures, without however having to write and maintain your own dynamic sql.
I think all this additional freedom is well worth it -- as long as the O/R Mapper does not itself take away too much of your freedom by forcing you into its framework any more than necessary. Some “vendor lockin” is to be expected with any library, and O/R Mappers are certainly no different, but it should be as minimal as possible. In other words, yes you do need to realize that you are creating entities that are going to be persisted, but you shouldn't have to worry too much about the how your particular mapper accomplishes that persistence. Of course, I think my WilsonORMapper minimizes that lockin, while maximizing the freedom.