Imagine I am doing a findByXXX that returns a Collection of possibly thousands of PKs. I think this is a classic problem.
Imagine you do not want to use session bean with JDBC code because it breaks your design.
You can go then for
1. CMP EB
2. BMP EB.
1. If you use a tool like toplink, it can manage a cache for you when calling findByXXX (and do a SELECT * instead of a SELECT PK_ID, then cache all the data you get from the DB), then the next time you call a method on this entity you go to the cache and no ejbLoad is done.
2. The spec says (for both CMP and BMP) that the bean that performs the findXXX MUST stay in the pooled state. So if you code your findXXX with JDBC even if you get back a Collection of PK or a SELECT * then assigning the fields, if you call a method on the remote interface, an there will be an ejbLoad.... so if you have 1000 PKs, you go through these 1000 PKs, it implies 1000 ejbLoad ....
- Am I right?
- How to improve that for BMP (if possible) without session bean?