>Consider that I have two classes Car and SportsCar where SportsCar extends
>Car. Now, the system has objects of both classes. I want to model this
>relationship in entity beans. How should I go about it? Can I have two
>entity bean classes.. CarBean and SportsCarBean?
You can use implementation inheritance to make SportsCarBean a subclass of
CarBean. You can also use interface inheritance for the remote interface.
The problem is with the Home interface:
public interface CarHome extends javax.ejb.EJBHome {
Car findByPrimaryKey(CarKey key)
}
public interface SportsCarHome extends CarHome {
SportsCar findByPrimaryKey(CarKey key);
}
>Ultimately both objects go to the database table(s), so how would the
mapping work? Can two >ejbeans map to same table?
They can. You need a discriminator column to store the object type so
you can find it again. You must deal with NULL attributes values of the
derived class when dealing with the base class.
Alternatively, you can map each class to a different table and have foreign
key
relationship from SportsCar to Car. This will probably cause problems if you
are
using CMP.
Regards
Hamid
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".