-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Select Extended Class Type? Does Hibernate Handle this?
PostPosted: Sat Dec 24, 2005 3:47 pm 
Newbie

Joined: Tue Nov 25, 2003 4:31 pm
Posts: 12
Location: Minnesota
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.