Development Strategies for Applications

One way to develop an O/R solution is to set up the needed database tables with all the primary and foreign keys that express the relationships, and then turn the crank with the O/R tools, and thus obtain a set of configuration files, usually in XML, and sources for the objects. In the example, you end up with Java or C# source files for domain objects of types PizzaOrder, Topping, PizzaSize, and SysTable. The business logic involves operations on these domain objects and specialized operations in the objects. The original domain object classes created by the O-R mapping tools of course do not yet have any specialized methods--these need to be added.

Another way to develop an O/R solution is to start from the needed domain objects and mark up their sources to show entity and relationship information with annotations or parallel XML files, and then use a O-R mapping tool to generate the create tables, etc., i.e. the DDL script, to create the needed database. This method is fully supported in Hibernate, but is not yet available (it is in development) for MS EDM.

A third way to develop an O/R solution is to start in the middle, at the entity model level. In Hibernate you can write the mapping files, which express this entity model, then create the objects with one tool, and the database DDL with another tool. In MS EDM, the EDM editor (GUI) allows you to add entities and relationships, so you can build up a model, but you need to write and execute DDL for the new tables to make it all work at present.

Reference: Bauer and King, Java Persistence with Hibernate, pg. 40.