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 ejbFindByPrimary method has a flaw ..... I think 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 "ejbFindByPrimary method has a flaw ..... I think" Watch "ejbFindByPrimary method has a flaw ..... I think" New topic

ejbFindByPrimary method has a flaw ..... I think

Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
First of all my question is this

Whether it is possible to use a entity bean with out using home.create() method

That is i want my entity bean to load a particular record based on the primary key i am passing. All the examples in the tutorial are given like they are inserting a row into the database by the way of calling home.create which means currently all the instance variables will be allocated then they are calling the Business method.

If you not getting what i am trying to say, follow the coding below



i am assuming that i have a remote and home and i am having accno and balance are instance variables. Then with out calling the home.create() method i want get the balance.

This is not working.

And probably i want to use session bean for this.

Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
When you're talking about entity beans (which you seem to be) you don't use create() to get an EjbObject stub unless you're actually inserting a new record in your datastore.

You use a finder or select method, of which findByPrimaryKey(Object pk) is the only required one.

If it's not working you have something wrong in your code. For example you may have a CMP bean where you implemented the finder method, something you should leave to the application server.
Or maybe there is no record with the key you supplied.

I agree. Here's the link:
subject: ejbFindByPrimary method has a flaw ..... I think
It's not a secret anymore!