aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes BMP -last inserted record alone gets fetched Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "BMP -last inserted record alone gets fetched" Watch "BMP -last inserted record alone gets fetched" New topic
Author

BMP -last inserted record alone gets fetched

Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
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


Discipline, Dedication and Determination define Destiny.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
It might be helpful to see your ejbLoad() method.

Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Hello,
Here is the ejbLoad().


Regards,
Nandini
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
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

Joined: Jul 04, 2003
Posts: 132
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BMP -last inserted record alone gets fetched