• Post Reply Bookmark Topic Watch Topic
  • New Topic

WHAT HAPPENS IF FINDER METHD IN CMP BEANS HAVE AN INVALID ENTRY

 
Sharad Naithani
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
A PROBLEM IS CROPING UP.. I M USING FINDBYPRIMARYKEY METHOD IN CMP BEANS...NOW WHEN A INVALID ENTRY IS GIVEN THAT IS NOT PRESENT IN THE DATABASE IT GIVES AN EXCEPTION OF OBJECT NOT FOUND.....WELL BUT WHY IS IT SO THAT AFTER WARDS WHEN I GIVE A RIGHT ENTRY IT'S AGAIN GIVING AN EXCEPTION
REGARDS
 
Venkataramu Pendiyala
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the in the database commit command is not given and you invoke findByXXX() methods ObjectNotFoundException is thrown.
i,e.
1. Table is created
2. record is inserted.
3. commit
in this case ObjectNotFoundException will not be thrown.
If step 3 is avoided then ObjectNotFoundException is thrown.
 
Sharad Naithani
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Venkataramu Pendiyala:
If the in the database commit command is not given and you invoke findByXXX() methods ObjectNotFoundException is thrown.
i,e.
1. Table is created
2. record is inserted.
3. commit
in this case ObjectNotFoundException will not be thrown.
If step 3 is avoided then ObjectNotFoundException is thrown.

Hi
what do u mean by giving a commit command...pls specify....
actually my problem is in my database i have 1 entry for id=31125

1>so in findbyprimarykey(int id) if i give id=31125...it fecthes me the record details
2>now if i give id=as 31126 any wrong entry..it throws an exception of objectnotfound coz there is no record as such....
3>but again if i give id=31125..this time it doesn't work some sqlpersistence excpetion is there
what to do please help>>>

 
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!