Hi,
thanks for the effort with answering my questions! To maybe better explain what I'm aiming at here:
- Using CMP and CMR I can have a nice EJB scenario with 1:n relationship Artist <1:n> Cd. My understanding is that container is responsible for handling the relationship code so that I can always trust that I'm getting valid references no matter how I use cd.getArtist(), cd.setArtist(), artist.getCds(), artist.getCds(). When implementing the beans, I do not have to worry about whether there is caching or not, what is the caching strategy, etc. That I can leave to container, which is the added value of EJB's.
- I believe same thing _should_ be reachable using BMP's. I should be able to create BMP entity beans that keep the references valid with any use of cd.getArtist(), artist.setCds() etc. I should not have to worry about caching, trascations etc. as long as I follow the rules regarding call-back methods ejbLoad(), ejbActivate() etc - that's what the container is there for! But how to do this?
Use CMP and keep the foreign keys in simple attributes. Manage the relationships yourself. Your code examples are a good start. Remember to clear references in ejbLoad. Design your beans to avoid direct db access. Only keep references to other entity beans.
Many people get scared off by BMP because of the need to do a bit of optimization inorder to get decent performance. If you're serious about BMP look for a good O-R mapping library. Especially one that handles optimistic locking and optimized updates. A good container design will handle clustering for you even if it has to fall back to commit option C.
- 1:n relationships are quite common in all designs so this should be a common and basic problem.
- If using remote interfaces is a problem, I think having only local interfaces to entity beans is perfectly acceptable.
Whether you use remote or local interfaces is a performance question. It won't effect the basic design. You'll find that some containers handle remote calls with about the same efficiency as calls to local interfaces. As always with performance issues, if it doesn't impact the design greatly, try it. Measure and look for bottlenecks. Then optimize. Don't waste time optimizing calls that are only called a few times.
--Victor
=========================================================================== 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".
