db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramesh Sabeti" ...@reazon.com>
Subject RE: Oracle, Torque and PreparedStatements - Potential Patch of Peer.vm
Date Fri, 05 Dec 2003 18:23:40 GMT
Hi Siegfried,

> ad 1. doSelect()
> 
> I don't think that a global manual replace on generated code is a
> convenient thing to do. Having said that the mail includes "Potential
> Patch" since I'm clueless on TORQUE and ORACLE ... :-)

I'm not familiar with patches, so I don't know how yours work or how to
use it in my app :)  Can you point me to the right references on the
web?   I'll be able to have a more educated conversation :) 

> The doSelect() is called 4 times in the generated BaseXXXPeer - I
think a
> refactoring of the code would result into one single function wich in
turn
> decides to use  a prepared statement or not - 

Definitly.

> ad 2.) doUpdate()
> 
> I had a quick look at the source code but I can't find the offending
peace
> of code. Any idea where it happens?! I definitely need a testcase for
> that.

If you can check the SQL statements that are sent to your database, you
can test this with any database.  Make a doUpdate() call with an addIn()
criteria to do something like this: 

	"UPDATE employee SET salary=1000 WHERE emp_id in (1, 3, 5, 7)".


Of course, do that using Torque by creating the criteria and so on.

Check the SQL statements sent to your database.  It'll be something like
this:
SELECT * FROM employee WHERE emp_id in (1, 3, 5, 7)
UPDATE employee SET salary=1000 WHERE emp_id = ?  (this one is done for
times with different parameters)

Torque does a nice job preparing statements for the UPDATE operation,
but it always issues that literal SELECT first.

Thanks for looking into this problem,

Ramesh.


> -----Original Message-----
> From: Ramesh Sabeti [mailto:rs@reazon.com]
> Sent: Friday, December 05, 2003 6:01 PM
> To: 'Apache Torque Users List'
> Subject: RE: Oracle, Torque and PreparedStatements - Potential Patch
of
> Peer.vm
> 
> 
> Siegfried,
> 
> Out of curiosity, how do you use your patch?
> 
> There are two separate issues that need a solution.
> 
> 1.  doSelect():  This is what you tried to solve in your patch.  An
> easier solution is to replace all calls to doSelect with doPSSelect in
> Base*Peer.java :)  A patch is not really needed for this case :(
> 
> 2.  doUpdate():  this method issues a non-parameterized SELECT first,
> and that one is buried deep in the API.  I'm still looking for a
> solution for that.  Want to give that a try?
> 
> Cheers to all the patch-makers,
> 
> Ramesh.
> 
> > -----Original Message-----
> > From: Göschl,Siegfried [mailto:Siegfried.Goeschl@drei.com]
> > Sent: Friday, December 05, 2003 8:17 AM
> > To: torque-user@db.apache.org
> > Subject: Oracle, Torque and PreparedStatements - Potential Patch of
> > Peer.vm
> >
> > Hi folks,
> >
> > we recently had a discussion about Torque and problems with Oracle -
> it
> > seems to have problems with ad-hoc SQL statements filling up an
> internal
> > buffer. There is BasePeer.doPSSelect() which returns a List of
Village
> > Records.
> >
> > The following patch could return "proper" TORQUE objects. Have a
look
> at
> > it since it is a quick hack and I already had a cup of mulled wine
...
> ;-)
> > ... and will have a second one before I do more patches ... :-O
> >
> > Cheers,
> >
> > Siegfried Goeschl
> >
> > ===============================================================
> >
> > PEER.VM
> >
> >   ## ------------------------------------------------------------
> >   ## Patch by Siegfried Goeschl
> >   ## ------------------------------------------------------------
> >
> >     /**
> >      * Do a Prepared Statement select according to the given
criteria
> >      *
> >      * @param criteria
> >      * @return Result as Torque generated objects and NOT Village
> Records
> >      * @throws TorqueException Any exceptions caught during
processing
> > will be
> >      *         rethrown wrapped into a TorqueException.
> >      */
> >     public static List doPSSelectEx(Criteria criteria) throws
> > TorqueException
> >     {
> >      	List v = null;
> >      	List temp = null;
> >
> >     	// add the columns to the criteria
> >     	$basePrefix${table.JavaName}Peer.addSelectColumns(
criteria );
> >     	// invoke the BasePeer to get the list of Village
Records
> >     	temp = $basePrefix${table.JavaName}Peer.doPSSelect(
criteria
> );
> >     	// convert the VillageRecords into Torque objects
> > 	v = $basePrefix${table.JavaName}Peer.populateObjects( temp );
> > 	return v;
> >     }
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message