Richtn�r Fredrik wrote:
I'm using Castor on DB2. The thing is that DB2 sorts the resultset differently than other databases (MySQL, Oracle) for OUTER JOINs. The hint I got from IBM is to add ORDER BY to the SQL query. So my question to the list is if it is possible to configure Castor to add ORDER BY clauses to the SQL generated?
Fredrik,
This would actually be very easy to do via the DB2QueryExpression.getStatement method. The ORDER BY clause would just be appended to the query if, for example, the query contains the text OUTER JOIN. Maybe something similar to the following would work:
getStatement( boolean lock )
{
StringBuffer sql;sql = getStandardStatement( lock, false );
if ( lock )
{
sql.append( " FOR UPDATE" );
}if ( sql.toString().matches( ".*OUTER JOIN.*" ) )
{
sql.append( " ORDER BY " + getTableName() + "." + getColumnName() );
}
return sql.toString();
}If this or something similar works for your situation I am certainly interested in in patching the codebase to add this functionality (with some Javadoc explaining why this is necessary. Also, below is some info on contributing source code to the project:
http://www.castor.org/cvs.html#Guidelines-For-Code-Contribution
Bruce
--
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\\"F9E<G)E=\\$\\!F<FEI+F-O;0\\`\\`");'
The Castor Project http://www.castor.org/
Apache Geronimo http://incubator.apache.org/projects/geronimo.html
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
