This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

remote=home.ejbFindByPrimaryKey("SB101");

remote.getBalance();

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.


Thanks
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!