File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes EntityBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EntityBean" Watch "EntityBean" New topic
Author

EntityBean

Maria George
Greenhorn

Joined: Dec 25, 2006
Posts: 3
Hi to all,
This is my first post to the forum..I'll appreciate if someone help me out on this..My question is:
Can an EntityBean's Finder methods(defined with prefix ejbFind) access instance variables of the bean ??
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

Maria,
Welcome to JavaRanch!

The finder methods are on the home interface and help to find the requested beans. They do not have access to the bean at all while doing their job. Therefore, they would not have access to instance variables on the bean.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

The finder methods are on the home interface and help to find the requested beans. They do not have access to the bean at all while doing their job. Therefore, they would not have access to instance variables on the bean.


Jeanne Boyarsky,

Correct me, If I'm wrong.

For BMP(Bean Managed Persistence) beans, ejbFind..() methods are implemented by Bean developer, so he can access Beans instance variable. But for CMP(Container Managed Persistence) beans, ejbFind..() methods are implemented by container.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Maria George
Greenhorn

Joined: Dec 25, 2006
Posts: 3
Thanks for replies..but i'm still confused ... i can't differentiate clearly between ejbHome and ejbFind methods...
According to the sun tutorials:
The Home Methods
A home method contains the business logic that applies to all entity beans of a particular class. In contrast, the logic in a business method applies to a single entity bean, an instance with a unique identity. During a home method invocation, the instance has neither a unique identity nor a state that represents a business object. Consequently, a home method must not access the bean's persistence state (instance variables). (For container-managed persistence, a home method also must not access relationships.)

The Finder Methods
The finder methods allow clients to locate entity beans.

Does that mean finder methods are only used to fetch some beans without doing any transactions on them and that home methods are meant to do some transactions on some particular beans??
Also I'm not clear on my above question yet as the tutorial doesn't say anything about it..
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Correct me, If I'm wrong.

For BMP(Bean Managed Persistence) beans, ejbFind..() methods are implemented by Bean developer, so he can access Beans instance variable. But for CMP(Container Managed Persistence) beans, ejbFind..() methods are implemented by container.


The finders run when the bean is pooled so I guess it wont make much sense to use their instance variables when one instance is trying to represent all other instances in the pool. However with home business methods and ejbSelect methods, they can run when the bean has full beaness and is out of the pool. So I think it might make more sense there. The home business methods and ejbSelect methods can run when the bean is pooled also.

I think you "can" access the instance variables but they would not have any persistence state, which kinda defeats the whole purpose of using them.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EntityBean