ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Hibernate Your Data
Subject:   Class/operation definitions don't make sense to me
Date:   2004-09-02 14:53:30
From:   john_skelton
I'm currently of the impression that Hibernate persists/materialises object graphs. So, using the example(s) here, I would have Order and OrderItem where Order could have a Collection attribute that holds Order ItemS and OrderItem could have an attribute of type Order that holds it's containing order.


Taken 'as is' this description would be the 'pure' OO model. However, I'm struggling to get Hibernate working like this. I note that the example here appears to use a string representation of the PK of Order in the ...Item. In effect this is making the FKs apparent in an OO model and therefore(-ish) my OO model becomes a relatonal model.


This isn't good IMHO.


Am I missing something?


Thanks in anticipation of enlightenment.


Just to be clear - I'd expect the only 'relationship' in my OO model to be either a collection to members link from Order (Order.getItems():Set), a member to collection link from OrderItem (item.getOrder():Order), or both (op sit, as per UML association navigation). I would not expect to have to make the FKs visible in the classes - only in the Hibernate mappings.


I know I'm missing something, but I can't see what.