I'm looking for guidance on best practices for persisting dependent
objects.
I've read the threads on dependent objects and they talk mostly about
when and why to use them, but not how to actually get them in and out of
a db.
As a simple example, suppose we have a Person entity bean using
CMP and an Address which is implemented as a dependent object of
the Person entity.
My question is how one whould persist the Address object.
Should the fields from Address be duplicated in Person as CMP fields
that are automatically persisted when the Person is persisted (either
loaded or stored)? This seems extremely ugly to me because of the need
to maintain the fields for Address in 2 separate places, the
Address object and the Person entity.
Unfortunately, I don't see any other "standard" way to accomplish this
using CMP. Using BMP, of course, the Address object can be persisted by
the appropriate EntityBean methods, e.g. create(), load(), store(),
remove(),
but the general consensus seems to be that CMP is the preferred way to
manage persistence, assuming your container's CMP implementation can
meet
the specific needs of your application.
It seems to me, a self-confessed newbie to ejb, that a good solution
would be to have the container map non-entity bean fields to db table
columns in the same manner as the CMP fields of an entity object This
would allow the transactional boundaries for the dependent object to be
managed by the container, dictated by the transactional boundaries of
its controlling entity, would obviate the overhead of using an entity
bean for what should be a dependent object, and would eliminate the
need to maintain mirrored fields for the dependent object in its
controlling
entity bean.
Are there container vendors who do something like this? Is this
something
that will be in the ejb 2.0 specification? When is that spec due out,
btw?
I'd love to hear comments from those more knowledgeable than I about
this.
I've found this to be a confusing issue, and have not seen it discussed
anywhere that I've looked.
Cheers,
Rick Horowitz
===========================================================================
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".