General J2EE: OR-Mapping question (Hibernate, JDO & the likes)

  1. OR-Mapping question (Hibernate, JDO & the likes) (4 messages)

    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)?

    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?
  2. yes!![ Go to top ]

    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.
  3. Click of a button[ Go to top ]

    Hi aXe,

    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.


    Robert Greene
    Versant Corporation
  4. Hi

    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
  5. Thank you. Is Versant Open Access open source?