• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

BMP -last inserted record alone gets fetched

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I use JBoss and MySql. I am trying to run an entity bean (BMP). I have the following classes: ProdHome, ProdRem, ProdPK (Primary Key), ProdBean and ProdClient. Everything works fine, but the "findByName(String name)" always returns the last inserted row details.

ProdBean.java

ProdClient.java

The records get inserted in the DB. But it keeps printing the "Sams Learn Java" details for the findByName() method.
Please help me figure out where my mistake lies.

Regards,
Nandini
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It might be helpful to see your ejbLoad() method.

Kyle
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Here is the ejbLoad().


Regards,
Nandini
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your ejbLoad, where are you getting the prodID instance variable value from? Normally in a BMP wha happens is you go to the EntityContext to get the primary key object, and then use THAT value for the key value of your WHERE statement. My guess is since you're not doing that that prodID gets set once somewhere in your EJB class, and you keep using that same value.

I can't be certain because I don't see where you've set the prodID instance variable in your class.

Also -- you're eating all possible exceptions in your ejbLoad() method -- that will make it hard to debug problems -- print out the exception values instead of just dropping them.

Kyle
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kyle,
Thanks for your help. I don't know how I missed these lines in ejbLoad().

The problem is this - JBoss server requires to be re-started every time for the correct values to be fetched by the ejbFindByName() method.

Regards,
Nandini
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic