Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating record using ejb gives error

 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I get DuplicateKeyException exception whenever i try to insert record using EJB. Although i checked the value of primary key. They all are seems to be fine. I am giving you snapshot of error message.

 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code for insert

 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Not very sure of the scenario in which you are using report_master table but check if the report_id that is returned is the next valid value and not the maximum value in that table. Your function name is findMax() which makes me think so.
If it is the max value then you will need to increment it to get next value.

Regds,
amit
 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amit punekar wrote:Hi,
Not very sure of the scenario in which you are using report_master table but check if the report_id that is returned is the next valid value and not the maximum value in that table. Your function name is findMax() which makes me think so.
If it is the max value then you will need to increment it to get next value.

Regds,
amit






Hi Amit,

I checked it. Both next value comes from findmax and 'select max(report_id) from report_master' are same.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you please share the table details for "format" and "report_master" ? what are the primary keys there?
That might give some clue.

regards,
Amit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic