The Iterative Reference Model: A new approach to OO

http://www.zenbi.nl/en/blog_the_iterative_reference_model.php

 

In this article the author suggests a new way to model the objects of the system such that it is easier to create their database schema in an iterative way (adding new objects/tables as the project moves forward).

 

I wonder if there's a way in Hibernate to make retrieving such reverse relations easy?

 

 

Comments

Hibernate do support this model, and actually the model implies the most basic relationship mapping between two entities - it's called "many-to-one" (instead of the one-to-many in his first UML). So for example the association from Contact to Company can be done :

@Entity public class Contact{

  ...

  @ManyToOne 
  @JoinCoulmn(name="CompanyId")
  private Company company;

  ...

}

 

Generally, I think that life is NOT always that easy as in his example. In many cases you want to reuse the model to other layers (and NOT to duplicate different views of it), including the service layer, and sometimes even to the client (i.e. the client is GWT). This means, you need to re-consider the entities relationship's access methods. Sometimes different layer requires the one-to-many, and you can't run away from it. More than that, in some cases you need to map both sides – For example , the company has a list of contacts, and the contact yet needs to refer back to its company. This is called bi-directional association (also supported by Hibernate) and you have to maintain it very carefully.

One more note - Despite what the author says, the first UML, could have been mapped just to the same ERD tables as in the 2nd UML. The JoinColumn annotation (as described above) can also be set on the one-to-many.

 

This artical has no real added value.

  • Patterns of Enterprise Application Architecture [Martin Fowler]
  • Domain Driven Design [Eric Evans]
  • Hibernate in Action / Java Persitence with Hibernate [Christian Bauer, Gavin King]

These books already discuss this subject.

As Yanai wrote - things aren't so simple... I'm afraid Mr. Schouten is a bit naive...