Hi folks,
I wrote the following code to insert values into database. But it's
crazy, this is inserting the values twice. here are the code below.
if(activity.equalsIgnoreCase("
declineParticipation")){
if(isTokenValid(request)){
// Validate the supervisor Info..
TeleworkDelegate delegate = new TeleworkDelegate();
String[] supervisorInfo =
delegate.validateSupervisorEmail(theForm.getSupervisorEmail().toLowerCase());
String supervisorCustomerId = supervisorInfo[2];
String role = supervisorInfo[3];
// Update the supervisor info into database..
user.setSupervisorName(supervisorInfo[1]+ " " +
supervisorInfo[0]);
user.setSupervisorEmail(theForm.getSupervisorEmail());
delegate.updateSupervisorInfo(user,supervisorCustomerId );
// Generate unique agreement number..
int teleworkAgreementId =
delegate.generateTeleworkAgreementNumber();
// call the create agreement method to insert data
into DB..
createDeclineParticipation(user,teleworkAgreementId);
// update the decline participation info into DB
delegate.declineParticipation(user);
// 4
return mapping.findForward("logon");
}
else
{
request.setAttribute("errorKey", new
String("error.telework.teleworkagreement.duplicatesubmission"));
return mapping.findForward("logon");
}
}
private void createDeclineParticipation(UserInfoVO user, int
teleworkAgreementId ) throws DatabaseException, TeleworkException {
// TODO Auto-generated method stub
TeleworkDelegate teleworkDelegate = new TeleworkDelegate();
TeleworkScheduleVO scheduleVO = new TeleworkScheduleVO();
TeleworkAgreementVO agreementVO = new TeleworkAgreementVO();
scheduleVO.setTeleworkAgreementID(teleworkAgreementId);
agreementVO.setTeleworkAgreementId(teleworkAgreementId);
agreementVO.setDateCompletedTraining("07/21/2009");
agreementVO.setAgreementStatus(Constants.AGREEMENT_DECLINED);
teleworkDelegate.createDeclineTeleworkAgreement(user,
scheduleVO, agreementVO);
}
this code is generating 2 unique number and inserting values twice into
database. Means, when i hit a submit button, it has to get the max number
from the database and add 1 to it and insert the record. instead of it, it
is inserting twice. Ex when i hit the submit botton, it has to get the
number is 4, but it's inserting 4 and 5 into the database.
don't know why it's doing like, I would appreciate if you could help me
on this.
Thanks,
--
View this message in context:
http://www.nabble.com/code-inserting-data-into-database-twice-tp25231274p25231274.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]