Will really appreciate if someone can answer. Thanks very much.
Your ejbFindByPrimaryKey should:
- SELECT to verify the PK being found exists
- return the PK
You should NOT populate your member fields.
Your ejbLoad will be called when you call a business method.
It looks like you are using JAWS, and JAWS is not very smart about loading (actually it can't be because of the spec). JBossCMP (CMP 2.0) is a lot smarter about loading, and can be configured to not force a load for this code.
Do u mean to say that with JBossCMP, we won't need to force the loading and data will be loaded once I find the entity bean? What does the EJB2.0 spec say? Shouldn't entity bean instance be loaded automatically (so we don't have to force ejbLoad) whenever we do a findByPrimaryKey??
> Shouldn't entity bean instance be loaded
> automatically (so we don't have to force ejbLoad)
> whenever we do a findByPrimaryKey??
No, the find just needs make sure that the database has the key. For EJB 2.0 the container is only required to load the data for a field the is required to satisfy a getter. This means that the container can load an entity field by field as requested by a user. On the other end, you can configure the container to load all of the data on-find. Usually somewhere in the middle is best.
I suggest you read the Optimized Loading chapter of the JBossCMP documentation.