Confusion about the differences between finder and select method

Dear all,

I discovered the following statement in the "J2EE 1.4 Tutorial - Chapter 27 Container_Managed Persistence Examples" (http://java.sun.com/j2ee/1.4/docs/tutorial/doc/CMP3.html#wp79761).

"A select method can return a persistent field (or a collection thereof) of a related entity bean. A finder method can return only a local or remote interface (or a collection of interfaces)."

What makes me confused is that, how come it states that a finder method can return only a local or remote interface (or a collection of interfaces)? I have not done CMP bean but in a BMP Bean class I can return a Collection of primary keys other than the interfaces.

So is the statement only true for CMP bean but not BMP bean?

Thanks in advance.

[770 byte] By [HELLOOOOa] at [2007-11-26 23:01:38]
# 1

Hi,

The confusion comes from the difference between what the bean developer returns in the bean and what the container returns to the client. Example:

MyBeanImpl.ejbFindByName

returns Collection of PKs

MyBeanHome.findByName

returns Collection of references to MyBean EJBObjects.

Since the client calls the method onthe home object, from this point of view, a collection of References is returned. From the bean developers point of view, a collection of Primary keys must be returned. The ejb container is resonsible for the conversion.

The is no difference between CMP and BMP, only the way you define the implementation of returning the PKs. For CMP with a EJBQL, for BMP by implementing the query yourself.

Hope this makes it more clear (EJB 3.0 makes life much more easy)

robert@javixa at 2007-7-10 13:26:32 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Thanks a lot for clarifying me.
HELLOOOOa at 2007-7-10 13:26:32 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...