-->
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: Mapping an abstract property to different concrete classes
PostPosted: Thu Jan 15, 2009 6:00 am 
Beginner
Beginner

Joined: Thu Oct 26, 2006 4:45 am
Posts: 39
Hibernate version: 2.0

I do not know how to map this situation, who can help?

I have a class OrderLine with an abstract property Booking. The Booking can be of different concrete types (like Hotel, Flight, Car)

like this:

Code:


public abstract class ProductBooking
{
        /// <summary>
        /// Booking of the product. Must be implemented (overridden) in derived class
        /// </summary>
        /// <returns></returns>
        public abstract bool Book();
....
}


public class Orderline
{
        public virtual ProductBooking Booking
        {
          ....
}


From an OO perspective, this is pretty need because when an Order contains OrderLines, and all of the products must be booked, the Order does not care what KIND of products are on the order. We can book them all by a simple loop.

However I have the following database table:

Orderline with columns HotelBooking, FlightBooking, CarBooking

Those columns contain the primary key of the tables that contain the actual products (Hotel, Flight, Car). How should this be mapped?

That is, how can I map the property OrderLine.ProductBooking to different classes within the mapping file for the orderline class?

Is it possible to define subclasses for a PROPERTY of a class in a mapping file? If yes, how?


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.