db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject RE: BasePeer.doPSSelect with complex query fails.
Date Tue, 15 Mar 2005 08:28:20 GMT

Hi Thomas

Sorry for the late reply, I wanted to make sure I have some time to look
into this.

I could verify that a doPSSelect throws an error on joins where a DoSelect
works (using CVS HEAD version). However, the reason why it does not work
out is not anything in village code, it is because the select Coulumns are
not inserted into the Criteria object, leading to a invalid SQL query:
SELECT  FROM author LEFT JOIN torquetest.book ON
Note the absence of any columns to select from.

Subsequently, I get the following Exception
org.apache.torque.TorqueException: java.sql.SQLException: ORA-00936:
Ausdruck fehlt
      at org.apache.torque.util.BasePeer.doPSSelect(BasePeer.java:1451)
      at org.apache.torque.util.BasePeer.doPSSelect(BasePeer.java:1485)
      at org.apache.torque.DataTest.testJoins(DataTest.java:426)

To produce this error, I changed line 426 of DataTest.java(from CVS HEAD)
List authorList = AuthorPeer.doSelect(criteria);
List authorList = AuthorPeer.doPSSelect(criteria);

This  is definitely a bug.
However, if I change the code snippet to

List authorList = AuthorPeer.doPSSelect(criteria);

then it works.

Are we talking about the same error ? I would guess not. Probably you are
not using CVS HEAD; there have been quite allot changes in the meantime,
especially regarding joins....

Also, are you sure that doPSSelect reuses its statements (i.e. does it
really boost performance)? I am asking because doSelect() also uses
prepared statements to executeSQL, however, it throws away the prepared
statement instead of re-using it. From my glance into the Code of
doPSSelect in CVS HEAD, the prepared statement gets thrown away just as in
doSelect(). I have also looked into 3.1.0 code, same thing there.

This should definitely make its way into scarab. I am just not sure about
the action to take. In my opinion, one should call doSelect within
doPSSelect(), and deprecate the doPSSelect() methods, as they do not add
any functionality in my opinion.
As to re-using the prepared statement, this could also be done within
doSelect(). However, this would mean to replace village (how often did I
already write these words ???), which is not an easy task. Also, if the
statement is cached, appropriate action must be taken that the cache is
emptied if the criteria is modified in any way. This is also a lot of work.

Any other opinions ???


ORA-00936: Ausdruck fehlt

Thomas Vandahl <thomas.vandahl@tewisoft.de> schrieb am 11.03.2005 13:13:24:

> Hi folks,
> I was trying to use prepared statements in my application. My selects
> consist of joins over several tables and I thought this would help
> performance.
> Instead, I got a DataSetException which I could track down in the latest
> Village code. It says "This schema represents several tables."
>  From a deeper look into the code I saw that this one could never work.
> Reason: When the QueryDataSet(ResultSet) constructor is used,
> selectString is null and fetchRecords() tries to create one for no
> apparent reason:
> ---8<---
>          if (selectString == null)
>          {
>              selectString = new StringBuffer (256);
>              selectString.append ("SELECT ");
>              selectString.append (schema().attributes());
>              selectString.append (" FROM ");
>              selectString.append (schema().tableName());
>          }
> ---8<---
> In this piece of needless code schema().tableName() is called which
> throws the abovementioned exception if more than one table is referenced
> in the ResultSet. So this stuff cannot work for selects including joins.
> Call for comments:
> - Can this be verified by anyone else?
> - Is fixing Village a good option?
> - Does anyone know a workaround which we can put into BasePeer?
> Bye, Thomas.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org

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

View raw message