Rein Reezigt wrote:

> Hello all,
>
> I've been doing some research on how to implement inheritance using CMP. So
> far I only found out that I couldn't do it. The spec. model has an Account
> Object and 2 classes that inherit this object, the SavingsAccount and the
> CheckingsAccount. My datamodel has 3 tables, the account
> (accountID,balance), the Savings (accountID,minAmount) and the Checking
> (accountID,overdraftAmount). I would like to know if this is possible using
> CMP. What I :
>
> - Create AccountBean (EB) and don't specify it in the xml file. Create the
> checkingsAccountBean (EB) which remote class extends the remote interface
> from the acc.bean  and the bean class itself which extends the acc.bean. In
> the checkingbean I set the overdraftAmountfield and I then call the
> super.ejbCreate(accountID, balance). This doesn't work because I think the
> Acc.bean isn't mapped to the db. It works when I put all the members from
> the acc.bean in the checkingaccountbean. But what is the use for inheritance
> then?
I'm doing something similiar, but I had to make some concessions in my
data model: each table backing an entity bean has all required
attributes. Really, this is the other classic way of mapping an object
hierarchy onto a relational database. There are arguments for either
way. The thing isn't that you haven't mapped the Account bean: it's that
you haven't mapped the fields that checkingAccountBean inherits from
AccountBean into the database. Mapping the derived classes onto
updatable views would be something to look into, but you'd need a lot of
cooperation between the container's persistence manager and the database.

Another issue with inheritence and EJB comes in when you need to treat
the class hierarchy polymorphically: in EJB, you can't because you need
to know which specific Home to call, and therefore must know which
specific subclass is required. There are ways to reduce the need for the
client to know the entire hierarchy, but it's still at least a little
bit ugly.

> Is there a way to do this 'elegantly' in CMP?

>
> I also have a non-ejb question which relates to this scenario. I tried to
> use (updatable?) views in Oracle to store the data over 2 tables (account
> and checking). I think this doesn't work because I use the accountID in both
> tables (and only one time in the virtual table CheckingAccount (WHERE
> Account.accountID = Checking.AccountID). Is someone familiar with doing
> something similar.
>
> Thanks in advance..
>
> Rein Reezigt
> Student computer science
> Hogeschool Enschede, The Netherlands
>
> ===========================================================================
> 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".
>
> ===========================================================================
> 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".

===========================================================================
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".

Reply via email to