I'm working on mapping Header/Detail information as it relates to Order management. In many cases, I've just pull the Header/Detail as normal-- but when I'm operating with the Header as an Order, I would like to use alternate behavior that is based only in Java.
public class Header { ... }
public class Order extends Header { /* override methods */ }
The reason for taking this approach is that I would like aggregate values for the Header fetched from the DB, but when I'm working with it as an Order, I would like to force calculations across the bag of Details.
I would think this case would come up a lot, instead of managing multiple states, internally, for different behaviors, I would just like to select over the same data (parent Header) but pass in the alternate behavior (Order).
There is no discriminator or anything, just that hibernate would know that it has Header mapped, and Order extends Header.
Make sense? :-)
Hibernate version: 3.1
Mapping documents: Header.hbm.xml & Detail.hbm.xml
Code between sessionFactory.openSession() and session.close():
Code:
Order ord = session.get(Order.class, new Long(000));
Thanks everyone!