File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes why finder method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "why finder method" Watch "why finder method" New topic

why finder method

sasmit sahu

Joined: Apr 12, 2002
Posts: 9
can somebody explain me why we use the finder method in entity bean.and when i am writing two finder method i.e. suppose by name and by primary key as per the example in Ed Roman book in the client program first i am searching it by name then from that i am getting the primary key object and doing the search by primary key .can i give only one finder method i.e. by primary key?
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
Hi sasmit,
We have a naming policy here at JavaRanch where all publicly displayed names take the form, "Firstname Surname". Could you please edit your profile to bring it into line?
Thanks in advance and we hope that you enjoy your stay at the ranch!
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

Entity beans represent shared data. There must be some mechanism to access shared data ..this is done by using finder methods. Finder methods allow u to access the enity that is already present..Only one finder method is mandatory in enity i.e. findByPrimaryKey..

Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1868
Let us say you want to change the quantity available field of the Product EJB. This ejb instance is already there.
To udate the quantity you need to get to the Remote Interface of the bean. The question now is how do you get to the remote interface.
You cannot use create as create creates a record and if you try to create the product again it will fail.
In such a scenario you will write a finder which will help you get access to a reference to the remote interface through which you can do your Product.
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
And its not as if there are only finder methods in an entity ejb.....there can be other methods in the remote interface.......but of course there should be no DB calls for EB's do we try to keep them only on a need basis ........

sasmit sahu

Joined: Apr 12, 2002
Posts: 9
this is for the first time i put a que on this forum and nice to see the kind of response i got for my que.i'll come with more doubts soon.thnk you all.
I agree. Here's the link:
subject: why finder method
It's not a secret anymore!