General J2EE: OR-Mapping question (Hibernate, JDO & the likes)
My question is about usage of OR mapping tools like Hibernate and JDO. Do these frameworks really allow me to freely design a domain model first (without worrying about tables and columns) and then map my java domain model to a persistent RDBMS schema (the design of which is not constrained in anyway to the OR mapper framework)?
- Posted by: aXe !
- Posted on: March 03 2005 16:32 EST
Say for e.g. I want to have a 'Recipe' object (class) that has a one-to-many relationship with another object called 'Ingredient'. Now the straight forward way to map this using Hibernate is to have two tables 'Tbl_Recipe' and 'Tbl_Ingredient'. But is this the only way or can I have a 'Tbl_Recipe_Master', Tbl_Ingredient_Master' and a third relationship mapper table 'Tbl_Recipe_Ingredients'!!
Does Hibernate or JDO support this kind (or even more complex) relationships?
- yes!! by Martin Del Cuadro on March 03 2005 22:15 EST
- Click of a button by Robert Greene on March 04 2005 02:36 EST
- OR-Mapping question (Hibernate, JDO & the likes) by David Tinker on March 04 2005 02:42 EST
- OR-Mapping question (Hibernate, JDO &amp; the likes) by aXe ! on March 04 2005 17:02 EST
i did that with hibernate without problem. But i`ve always started designing the database first. Hibernat can deal without problem with many to many raltionship.
Yes, this is exactly how both these technologies work. You can most easily start with any object model and auto generate the tables. Then, if you don't want the default mapping, using Versant Open Access changing from one data model pattern to another is simple the click of a button on the visual mapping tool. You will actually "see" the underlying tables created visually in front of your eyes. If you don't like our default naming, you are then free to customize everything to your liking.
Also, note that it is equally important, arguably more important, to be able to start with existing tables and perhaps also existing classes and then bring these together. This is where a good visual tool can make all the difference. Most JDO vendors provide this capability and certainly Versant Open Access does.
Most JDO implementations support generating the tables from classes (forward engineering), generating the classes from tables (reverse engineering) and mapping exiting classes to existing tables (meet in the middle mapping).
Versant Open Access maps one-to-many relationships like your example using an association table by default (your second option). Using our visual mapping workbench you just have to click one radio button to change to an inverse foreign key mapping (your first option). The tables involved are displayed and updated instantly as you make changes.
We support a lot of other more complex mappings all with complete support from our Workbench.
Versant Open Access
Thank you. Is Versant Open Access open source?