Hey (great subject line ;-)
Peter Delahunty wrote:
> I have a complex database structure containing lots of many to many
> relations. As a result I have a lot of link tables.
>
> How well do EJB's handle this structure. As far as I am aware an EJB can
> only map to a single row in a single table. Is this true ? and if so is this
> a bit limited.
That is true and untrue. There is nothing in the EJB specification that
limits EB's (EntityBeans) to be single row/single table. This is a
common misconception, and is a problem with knowing what's in the spec
and what are limitations of a specific implementation. I would advise
you to look at for example TOPLink or similar O/R tools for more
advanced implementations.
> What about inheritance as well. ( EJB 2.0 seem to support this correct ?)
It all depends on what you mean by inheritance. There have been lots
(no, make that LOTS) of discussions on this topic, and there is good
info available in the archives of this list (see archives.java.sun.com
for search and browse functions).
> Has anyone created EJB's that represent say an order. This would encapsulate
> the order info then all the products for that order (e.g. from a link
> table). If so, how ?
Take a look at the components from Theory Center for example
(www.theorycenter.com).
One popular way of creating 1-many and many-many relationships is to use
finders. For example: A Customer may have several Accounts. So in the
Customer interface you may have a "Enumeration getAccounts()" method
which returns these accounts. How would you implement this? Example
(i.e. Customer bean impl.):
public Enumeration getAccounts()
{
return accountHome.findByCustomer(ctx.getPrimaryKey());
}
.. and the finder in the Account home is fairly selfexplanatory.
/Rickard
--
Rickard �berg
@home: +46 13 177937
Email: [EMAIL PROTECTED]
http://www.dreambean.com
Question reality
===========================================================================
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".