« H-1B | Main | Quality over Quantity »

January 8, 2006

Hibernate Entity Map

I had the simple task of analyzing one of my customer's Hibernate [hibernate.org] implementation, at least it sounded simple. I figured a good first step was to generate a graph of all the entities within to see the relationships and interdependencies. What was given to me was the Hibernate mappings (*.hbm.xml files) and the root hibernate configuration file (hibernate.cfg.xml). Now how can I visualize all this?

Read more after the jump.

First I tried Linguine Maps [softwaresecretweapons.com], but that didn't work for me beacuase I had something like 20 mapping files that all related to each other. Finally I settled on a combination of tools to generate different types of graphs. First, I installed Hibernate Tools for Eclipse [hibernate.org] and used this to generate the Java source files representing the mappings. Then I imported these into Poseidon for UML [gentleware.com] and generated a class diagram displaying everything. This was okay, but the diagram was a little cluttered.

My second method was to recreate the Schema in my test database from the mappings and use DBVisualizer [dbvisualizer.com] to check everything out that way. I tried using a MySQL backend first, but that didn't let Hibernate specify foreign keys for some reason. After that I switched to Oracle and let Hibernate do it's thing. Firing up DBVisualizer let me see all the tables and their relationships in a cleaner graph than Poseidon gave me. It also allowed me to choose different graph styles (Organic, Orthoganol, Hierarchical, etc.) that gave me a really good view of how things were layed out and their dependencies.

Posted by Guy at January 8, 2006 7:39 PM