SqlHelper is quite a primitive thing. it assumes that there is only ONE column in a selectio criteria. this means it cannot handle criteria like this:
oracle: upper(col1 || col2) = ? mysql: upper(concat(col1,col2)) = ?
in fact the whole selection criteria handling assumes only one column :(
i'm currently thinking about how i can get rid of this limitation. and i hope that we can also drop SqlHelper then.
jakob
shivaken wrote:
Thanks Armin,
But, that was another problem. That was caused by below line in my code.
query.addGroupBy("DATE_FORMAT(DATE, \"%Y/%m/%d\")");
# DATE_FORMAT() is mysql function
And SqlHelper.java: colName = betweenBraces.substring(colBegin + 1, colEnd);
colBegin is created by.. colBegin = betweenBraces.indexOf(" "); So, colBegin will be 5 with aPath="DATE_FORMAT(DATE, \"%Y/%m/%d\")" . And colEnd indicates ","'s place. then colEnd is 4.
SqlHelper will try substring with condition colBeling > colEnd. That is the problem.
Just for me, removing white space from above query is enough. But I want you to fix it. I wanted to write a patch, but I don't know expected work of SqlHelper.
Thanks.
On Friday 06 February 2004 20:14, Armin Waibel wrote:
Hi,
I think (but I'm not sure) this is fixed in CVS HEAD (not 1.0_branch). See http://www.mail-archive.com/ojb-user%40db.apache.org/msg07835.html
regards, Armin
shivaken wrote:
Hi,
At imigrating to rc5 from rc4, I got StringIndexOutOfBoundsException. I read SqlHelper.java. But I couldn't find any wrong thing.
Please help me.
# I'm using J2sdk1.4.2_03, db-ojb-rc5
# I did Criteria criteria = new Criteria(); String[] columns = { "sum(TIME)" }; QueryByCriteria query = new ReportQueryByCriteria(Call.class, columns, criteria); query.addGroupBy("DATE_FORMAT(DATE, \"%Y/%m/%d\")");
# stack trace java.lang.StringIndexOutOfBoundsException: String index out of range: -2 at java.lang.String.substring(String.java:1444) at org.apache.ojb.broker.util.SqlHelper.splitPath(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.getAttributeI\ nfo(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendColName\ (Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.ensureColumns\ (Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.getStatement\ (Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.getPrep\ aredSelectStatement(Unknown Source) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown\ Source) at org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(Unknown \ Source) at org.apache.ojb.broker.accesslayer.RsIterator.<init>(Unknown Source) at org.apache.ojb.broker.accesslayer.ReportQueryRsIterator.<init>(Unknow\ n Source) at org.apache.ojb.broker.core.ReportRsIteratorFactoryImpl.createRsIterat\ or(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQue\ ry(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getReportQueryIterat\ orFromQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getReportQueryIterat\ orByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getReportQuery\ IteratorByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getReportQuery\ IteratorByQuery(Unknown Source)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
