ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Can't Get Rollback (endTransaction) to Work
Date Mon, 07 Aug 2006 20:26:49 GMT
Somthing looks fishy to me...are you using the iBATIS DAO framework?  If so,
I would expect to see code like this:

try {
  daoManager.startTransation();
  SomeDAO someDao = (SomeDAO) daoManager.getDao(SomeDAO.class);
   AnotherDAO anotherDao = (AnotherDAO) daoManager.getDao(AnotherDAO.class);
  someDao.doSomething();
  anotherDao.doSomething();
  daoManager.commitTransaction();
} finally {
  daoManager.endTransaction();
}

I would also expect that the DAO implementations extend SqlMapDaoTemplate.

The DAO Framework's transaction support only works if you hook into the
other iBATIS classes as shown.

Seems like you might be trying to demarcate transactions with the DAO
framework, but aren't really using the framework properly.

Jeff Butler




On 8/7/06, Dunton Stephen - sdunto <Stephen.Dunton@acxiom.com> wrote:
>
>   Hi,
>
>
>
> I am using iBatis / Sql Maps with Cold Fusion 7 via java.  SQL Server DB.
>
>
>
> I have a number of sql statements executing that I need to act as an
> atomic transaction.  I can't get rollback via a call to endTransaction() to
> work properly though.  All statements are still committing.  To test I am
> dividing by zero and expecting all the previous statements to rollback but
> they're not.  I have the autocommit property set to false in the xml config
> file and I am starting a transaction with startTransaction().
>
>
>
> Any thoughts would be greatly appreciated.
>
>
>
> Code Below:
>
>
>
> Thanks,
>
>
>
> Stephen Dunton
>
> Acxiom-Insight
>
> http://www.acxiominsight.com/
>
> Stephen.Dunton@acxiom.com
>
> 303.785.3938
>
>
>
>
>
>
>
> <transactionManager type="JDBC" >
>
> <dataSource type="SIMPLE">
>
> <property name="JDBC.Driver" value="${driver}"/>
>
> <property name="JDBC.ConnectionURL" value="${url}"/>
>
> <property name="JDBC.Username" value="${username}"/>
>
> <property name="JDBC.Password" value="${password}"/>
>
> <property name="Autocommit" value="false" />
>
> </dataSource>
>
> </transactionManager>
>
>
>
> Also tried JDBC.DefaultAutoCommit false
>
>
>
>                                                 <cftry>
>
> DbIdObj = sf.getBean("InsightHireDbIds");
>
>                                                             // Start
>
>
> hireDaoMgr.startTransaction();
>
>
>
>
> if(firstApplication){
>
>                                                                         //
> Users
>
>
> usersid = DbIdObj.getNextIdRange("users", 1);
>
>
> usersDao = application.InsightHireDaoObj.getDao("HireDaoMgr", "UsersDao");
>
>
>
> usersBean = application.InsightHireDaoObj.getDto("Users");
>
>
> usersBean.setUsersid(usersid);
>
>
> usersBean.setUsertypeid(3);
>
>
> usersBean.setIsActive(1);
>
>
> usersBean.setUsername(arguments.event.getArg("username"));
>
>
> usersBean.setPassword(arguments.event.getArg("password"));
>
>
> usersBean = usersDao.insertUsers(usersBean);
>
>
>
>
>                                                                         //
> Applicant
>
>
> applicantid = DbIdObj.getNextIdRange("applicant", 1);
>
>
> applicantDao = application.InsightHireDaoObj.getDao("HireDaoMgr",
> "ApplicantDao");
>
>
> applicantBean = application.InsightHireDaoObj.getDto("Applicant");
>
>
> applicantBean.setApplicantid(applicantid);
>
>
>
> applicantBean.setApplicantstatusid(1);
>
>
> applicantBean.setUsersid(usersid);
>
>
> applicantBean.setFirstname(arguments.event.getArg("firstname"));
>
>
> applicantBean.setMiddlename(arguments.event.getArg("middlename"));
>
>
> applicantBean.setLastname(arguments.event.getArg("lastname"));
>
>
> applicantBean.setMaidenname(arguments.event.getArg("maidenname"));
>
>
> applicantBean.setSsn(arguments.event.getArg("ssn"));
>
>
> applicantBean.setDob(arguments.event.getArg("dob"));
>
>
> applicantBean.setPhone(arguments.event.getArg("phone"));
>
>
> applicantBean.setDlstate(arguments.event.getArg("dlstate"));
>
>
> applicantBean.setDlnum(arguments.event.getArg("dlnum"));
>
>
> applicantBean.setDlexpdate(arguments.event.getArg("dlexpdate"));
>
>
> applicantBean.setEmail(arguments.event.getArg("email"));
>
>
> applicantBean.setReleaseacknowledge(0);
>
>
> applicantBean.setBkgrdcopyrequested(0);
>
>
> applicantBean.setCreateusersid(usersid);
>
>
> applicantBean.setLastusersid(usersid);
>
>
> applicantBean = applicantDao.insertApplicant(applicantBean);
>
>                                                             } else { // A
> subsequent application for this applicant
>
>
>
>
>
>                                                             }
>
>
>
>
>                                                             // Application
>
>
>                                                             applicationid
> = DbIdObj.getNextIdRange("application", 1);
>
>                                                             applicationDao
> = application.InsightHireDaoObj.getDao("HireDaoMgr", "ApplicationDao");
>
>
> applicationBean = application.InsightHireDaoObj.getDto("Application");
>
>
>
> applicationBean.setApplicationid(applicationid);
>
>
> applicationBean.setApplicantid(applicantid);
>
>
> applicationBean.setRequisitionid(javaCast("int", arguments.event.getArg("requisitionid")));
>
>
>
> applicationBean.setEntrypointid(javaCast("int", arguments.event.getArg("entrypointid")));
>
>
>
> applicationBean.setApplicationstatusid(1);
>
>                                                             if(resumeid GT
> 0){
>
>
> applicationBean.setResumeid(resumeid);
>
>                                                             }
>
>
> applicationBean.setWassubmitted(0);
>
>
> applicationBean.setWashired(0);
>
>
> applicationBean.setCreateusersid(usersid);
>
>
> applicationBean.setLastusersid(usersid);
>
>
> applicationBean = applicationDao.insertApplication(applicationBean);
>
>
>
>                                                             if(resumeid GT
> 0){
>
>                                                             // Resume if
> one was uploaded
>
>
> resumeDao = application.InsightHireDaoObj.getDao("HireDaoMgr",
> "ResumeDao");
>
>
> resumeBean = application.InsightHireDaoObj.getDto("Resume");
>
>
> resumeBean.setResumeid(resumeid);
>
>
> resumeBean.setApplicantid(applicantid);
>
>
> resumeBean.setOriginalname(originalname);
>
>
> resumeBean.setExtension(extension);
>
>
> resumeBean.setFilesize(filesize);
>
>
> resumeBean.setIsindexed(0);
>
>
>
> resumeBean.setCreateusersid(usersid);
>
>
> resumeBean = resumeDao.insertResume(resumeBean);
>
>                                                             }
>
>
>
>                                                             //
> Applicantaddress (current)
>
>
> applicantaddressid = DbIdObj.getNextIdRange("applicantaddress", 1);
>
>
> applicantaddressDao = application.InsightHireDaoObj.getDao("HireDaoMgr",
> "ApplicantaddressDao");
>
>
> applicantaddressBean = application.InsightHireDaoObj.getDto("Applicantaddress");
>
>
>
> applicantaddressBean.setApplicantaddressid(applicantaddressid);
>
>
> applicantaddressBean.setApplicantid(applicantid);
>
>
> applicantaddressBean.setAddress(arguments.event.getArg("address"));
>
>
> applicantaddressBean.setApt(arguments.event.getArg("apt"));
>
>
> applicantaddressBean.setCity(arguments.event.getArg("city"));
>
>
> applicantaddressBean.setState(arguments.event.getArg("state"));
>
>
> applicantaddressBean.setZip(arguments.event.getArg("zip"));
>
>
> applicantaddressBean.setStartyear(javaCast("int", arguments.event.getArg("startyear")));
>
>
>
> applicantaddressBean.setIscurrentaddr(1);
>
>
> applicantaddressBean.setCreateusersid(usersid);
>
>
> applicantaddressBean.setLastusersid(usersid);
>
>
> applicantaddressBean = applicantaddressDao.insertApplicantaddress(applicantaddressBean);
>
>
>
>
>                                                             if(Len(Trim(
> arguments.event.getArg("prevstartyear"))) GT 0 AND Len(Trim(
> arguments.event.getArg("prevendyear")))){
>
>                                                             // Previous
> Address being entered
>
>
> applicantaddressid = DbIdObj.getNextIdRange("applicantaddress", 1);
>
>
> applicantaddressDao = application.InsightHireDaoObj.getDao("HireDaoMgr",
> "ApplicantaddressDao");
>
>
> applicantaddressBean = application.InsightHireDaoObj.getDto("Applicantaddress");
>
>
>
> applicantaddressBean.setApplicantaddressid(applicantaddressid);
>
>
> applicantaddressBean.setApplicantid(applicantid);
>
>
> applicantaddressBean.setAddress(arguments.event.getArg("prevaddress"));
>
>
> applicantaddressBean.setApt(arguments.event.getArg("prevapt"));
>
>
> applicantaddressBean.setCity(arguments.event.getArg("prevcity"));
>
>
> applicantaddressBean.setState(arguments.event.getArg("prevstate"));
>
>
> applicantaddressBean.setZip(arguments.event.getArg("prevzip"));
>
>
> applicantaddressBean.setStartyear(javaCast("int", arguments.event.getArg("prevstartyear")));
>
>
>
> applicantaddressBean.setEndyear(javaCast("int", arguments.event.getArg("prevendyear")));
>
>
>
> applicantaddressBean.setIscurrentaddr(0);
>
>
> applicantaddressBean.setCreateusersid(usersid);
>
>
> applicantaddressBean.setLastusersid(usersid);
>
>
> applicantaddressBean = applicantaddressDao.insertApplicantaddress(applicantaddressBean);
>
>
>                                                             }
>
>
>
>
>
>                                                             // leaveoff -
> testing out rollback capabilities
>
>
> bigbangvariable = 1 / 0;
>
>
>
>                                                 // insert activity and
> also send email if we have email address
>
>
>
>                                                             //
> End
>
>
> hireDaoMgr.commitTransaction();
>
>                                                 </cfscript>
>
>                                     <cfcatch type="any">
>
>                                                 <cfscript>
>
>
> hireDaoMgr.endTransaction();
>
>
> arguments.event.setArg("usermessage", "An error has occurred.  Please try
> your request again.");
>
>
> arguments.event.setArg("rePopForm", "Yes");
>
>
> announceEvent("Applicant.showApplicantApply1", arguments.event.getArgs());
>
>
>
>                                                 </cfscript>
>
>                                                 <cfreturn />
>
>                                     </cfcatch>
>
>                                     </cftry>
>
>
>
>
>
> *************************************************************************
> The information contained in this communication is confidential, is
> intended only for the use of the recipient named above, and may be
> legally privileged.
>
> If the reader of this message is not the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited.
>
> If you have received this communication in error, please resend this
> communication to the sender and delete the original message or any copy
> of it from your computer system.
>
> Thank you.
> *************************************************************************
>
>

Mime
View raw message