Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EntityBean

 
Maria George
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34179
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maria George
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic