Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.rmi.RemoteException: No database row for primary key

 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have written an entity bean with local interfaces say EntityBean1. I refer EntityBean1 in itself i.e. EntityBean1. Reason for doing this is to invoke findByPrimary key on EntityBean1 to check that the row I am going to insert in the table does not have a duplicate primary key. But I am getting the error java.rmi.RemoteException: No database row for primary key when I am inserting a row which does not have a duplicate primary key. Below is the relevant code:
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. I figured out the problem. I was trying to get a row from database which did not have the specified primary key. All's well now.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
findByPrimaryKey() will return ObjectNotFoundException and NOT null when the record can't be found.

If you want to test whether the primary key already exists, you can do this simple test:
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, then you can ignore my post above
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!