This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic