Dave Johnson on open web technologies, social software and software development
« Neward on Persistenc... | Main | Ultimate Weblogging... »
I've been thinking about Java persistence and O/R mapping a lot over the last year or two, so I was excited to see Ted Neward's latest items from his upcoming book Effective Enterprise Java. According to Ted, there are four approaches to Java persistence: object-first, relational-first, procedural-first, and hierarchical-first. I really like the way Ted introduces the approaches, exploring the history and the developer motivations behind each, but I do think there is room for improvement. Here are the short-comings from my point-of-view.
The approaches need more differentiation. Apart from the hierarchical-first approach, which I will ignore because it involves using XML rather than a relational database, the approaches, in the end, are very similar. When you get right down to it, they all involve building an encapsulation layer that stores and retrieves objects. The approaches differ only in the extent to which either the underlying database schema is exposed or the overarching object model is preserved.
More guidance is needed on choosing an approach. How do you know when to use each of these different approaches? For example, if you have an existing database schema, possibly one that is imposed upon you by your database administrator, does that mean you have to use the relational-first approach and use JDBC, RowSets, or SQLJ as Ted shows? I would say no, but Ted does not really make this clear. Conversely, if you start with a nice object model, does that mean you have to use the object-first approach and use O/R mapping, JDO, or EJB? I think the answer is no here too, but Ted does not explain this. How do you choose an approach and how do you know when circumstances have imposed an approach on you?
Characterizing the approaches as procedural-first, relational-first, and object-first is useful from the story-telling historical perspective, but I think it might be lacking for the practical how-to perspective. For an alternative, take a look at the way the Hibernate guys break it down, cookbook style. The Hibernate site describes four approaches to O/R mapping: top-down, bottom-up, middle-out, and meet-in-the-middle. These terms/approaches are useful even if you are not using Hibernate. Here are my summaries of the four approaches (from an earlier post of mine):
I was kind of hoping that I would read Ted's new chapters and realize "damn, I'm doing it all wrong" but that didn't happen and I guess that is not all bad. The chapters and the talk I attended this week by Ken Hygh both confirmed that the Persistence Manager/DAO encapsulation layer approach is a good approach to take in a database-driven web application. All of that being said, I think Ted's book is going to be a great resource for Java developers and I'm looking forward to buying a copy.
Dave Johnson in Java
03:55AM May 03, 2003
Comments [0]
Tags:
Java
This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog
Below are the most recent entries in the category Java, some may be related to this entry.