Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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.
 
Attractive, successful people love this tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!