ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Morone, Bill" <Morone.B...@pennmutual.com>
Subject RE: Can't Get Rollback (endTransaction) to Work
Date Mon, 07 Aug 2006 22:30:06 GMT
Hey-hey Good Folks,
 
iBATIS rocks is our motto here!
 
Anyway I don't know if I am chasing a phantom or not. I am using the "select statement to
xml" approach and I am trying to do a simple multiplication of columns (see code below) and
I keep getting the Oracle :
ORA-00923: FROM keyword not found where expected

is it possible the multiplication OP is screwing me up? Can I not do this? 

CURRNUMUNITS * UNITVALUE as TOTVALUE 

I also tried:

sub_acct.units * unit_val.unit_val as TOTVALUE

Is there something I am missing? Can anybody out there help?

Thanks,

Bill Morone

 
 
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="ClientholdingApp">

<statement id="getSubaccounts" parameterClass="java.lang.String" resultClass="xml" xmlResultName="subaccount">

select 

sub_acct.units as CURRNUMUNITS,

sub_acct.allctn_pct as ALLOCPERCENT,

<!-- sub_acct TYPE -->

sub_acct.dca as VALUE, 

sub_acct.dca_src_acct_flg as FROMACCOUNT, 

prod_fund.undrlyg_cusip_nmbr as CUSIPNUM,

prod_fund.prod_fund_nm as PRODUCTFULLNAME, 

<!-- AAR --> 

<!-- this complicates matters greatly --> 

unit_val.unit_val as UNITVALUE,

CURRNUMUNITS * UNITVALUE as TOTVALUE 

from 

acct, sub_acct, prod_fund, unit_val 

where

acct.acct_nmbr=#accountId#

and acct.acct_id = sub_acct.acct_id 

and sub_acct.prod_cd = prod_fund.prod_cd 

and sub_acct.fund_id = prod_fund.fund_id 

and prod_fund.fund_id = fund.fund_id

and fund.fund_id 

= (select unit_val.fund_id 

where max(unit_val.val_dt)) 

</statement> 

</sqlMap>

-----Original Message-----
From: Dunton Stephen - sdunto [mailto:Stephen.Dunton@acxiom.com]
Sent: Monday, August 07, 2006 6:21 PM
To: user-java@ibatis.apache.org
Subject: RE: Can't Get Rollback (endTransaction) to Work



Well I tried creating an alternative version of getDao with the first argument being an actual
object (the dao manager) being passed in instead of the name of the object and although it
ran fine still no rollbacks.  I actually put writes to a system log file of the hashCode of
the java object I'm doing my start, commit, ends on and the one that got into the getDao method
and they are the same.

 

Are there other configuration variables I may be overlooking or is JDBC.defaultAutoCommit
= false the only thing I should need?  This is just a straight sql server datasource that
I have done CF commit/rollback processing on before without any issues so I don't think it
is the datasource.

 

Thanks, 

 

Stephen Dunton

Acxiom-Insight

http://www.acxiominsight.com/

Stephen.Dunton@acxiom.com

303.785.3938

 

  _____  

From: Jeff Butler [mailto:jeffgbutler@gmail.com] 
Sent: Monday, August 07, 2006 2:47 PM
To: user-java@ibatis.apache.org
Subject: Re: Can't Get Rollback (endTransaction) to Work

 

This is the line that looks fishy to me:

 

applicantDao = application.InsightHireDaoObj.getDao("HireDaoMgr", "ApplicantDao"); 

 

Are you sure that this is getting the DAO from the same instance of the daoManager where you
did the startTransaction (i.e. - is hireDaoManager a singleton or some other type of global
object?) 

 

Jeff Butler

 

 

On 8/7/06, Dunton Stephen - sdunto < Stephen.Dunton@acxiom.com> wrote: 

Hi Jeff, 

 

Thanks for your reply.

 

Yes I am using the framework and all that code is there, it just looks a bit different as
it is being invoked from Cold Fusion script. 

 

Attached is my SqlMapUsersDao where you can see the extension and implementation occurring.

 

Drawing comparisons between your email and my posted code, your daoManager equates to my hireDaoManager.


 

In the next line you see me calling a getDao method to get specific (by entity) instances
of Daos.  

 

I modeled everything I'm doing from the iBatis sample code some I'm pretty sure this is a
configuration problem.  Also - other aspects are working for me such as inserts, updates,
deletes, calls to stored procedures. 

 

Are there other properties that I need to set besides the JDBC.defaultAutoCommit?  And it
should be false correct? 

 

Thanks, 

 

Stephen Dunton

Acxiom-Insight

http://www.acxiominsight.com/  <http://www.acxiominsight.com/> 

Stephen.Dunton@acxiom.com

303.785.3938

 

  _____  

From: Jeff Butler [mailto: jeffgbutler@gmail.com] 
Sent: Monday, August 07, 2006 2:27 PM 
To: user-java@ibatis.apache.org
Subject: Re: Can't Get Rollback (endTransaction) to Work

 

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 <  <mailto:Stephen.Dunton@acxiom.com> 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.
*************************************************************************

 




 


This message, including any attachments, is intended only for the recipient(s) 
named above. It may contain confidential and privileged information. If you have 
received this communication in error, please notify the sender immediately and 
destroy or delete the original message. Also, please be aware that if you are not 
the intended recipient, any review, disclosure, copying, distribution or any 
action or reliance based on this message is prohibited by law.  

Mime
View raw message