• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BMP -last inserted record alone gets fetched

 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • 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
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hello,
Here is the ejbLoad().


Regards,
Nandini
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic