You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Thomas Dudziak <to...@gmail.com> on 2005/06/17 14:59:42 UTC
Bug in SqlHelper
Hi folks,
just found a bug in SqlHelper (I would add a bug entry in JIRA but the
server seems to be down).
Assume that I have an persistent class with two Timestamp columns, say
'startTime' and 'endTime', and I want to query for all instances that
happen after a certain time, say 10 o'clock, regardless of the day.
With PostgreSQL, I'd use a criteria like:
criteria.addGreaterOrEqualThan(
"DATE_TRUNC('minute', endTime) - DATE_TRUNC('day', endTime) + TIME '00:00'",
startTimeToQueryFor);
However, this fails with a StringIndexOutOfBoundsException in the
SqlHelper (1.0 branch from CVS):
java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(String.java:1768)
at org.apache.ojb.broker.util.SqlHelper.splitPath(SqlHelper.java:112)
at org.apache.ojb.broker.util.SqlHelper.cleanPath(SqlHelper.java:65)
at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.buildJoinTreeForColumn(SqlQueryStatement.java:1646)
at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.buildJoinTree(SqlQueryStatement.java:1628)
at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.splitCriteria(SqlQueryStatement.java:1705)
at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.<init>(SqlQueryStatement.java:145)
at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.<init>(SqlQueryStatement.java:97)
at org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.<init>(SqlSelectStatement.java:51)
at org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.getPreparedSelectStatement(SqlGeneratorDefaultImpl.java:150)
at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImpl.java:318)
at org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(RsQueryObject.java:72)
at org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator.java:185)
at org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(RsIteratorFactoryImpl.java:58)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(PersistenceBrokerImpl.java:2047)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(PersistenceBrokerImpl.java:1605)
at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:116)
at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:255)
at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:275)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1461)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:366)
at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:366)
any ideas ?
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Bug in SqlHelper
Posted by Thomas Dudziak <to...@gmail.com>.
> we already have class path hints. what is the path hint supposed to do ?
It would allow the user to explicitly specify which paths are used in
the criteria. Obviously its usage would require the specification of
all paths, but then it would make matters a lot easier for OJB as it
would only have to replace these paths rather than having to search
for possible paths.
But I could also create a slightly more sophisticated SQL expression
recognizer - I have to deal with the SQL specifics of the various
databases anyway in DdlUtils - if that's any help ?
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Bug in SqlHelper
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi tom,
we already have class path hints. what is the path hint supposed to do ?
jakob
Thomas Dudziak schrieb:
>>SqlHelper provides primitive parsing only. however in ojb 1.1 this
>>problem should be solved.
>
>
> Mhmm, Problem is that I'm required to use OJB 1.0.x for the time
> being. Any chance of a backport ?
> As a side note, what do you think about optional path hints ? E.g. for
> the example query that I gave, a call like:
>
> criteria.addPathHint("endTime");
>
> could be used to tell OJB exactly what to look for without having to
> parse the condition at all. This should be fairly easy to add ?
>
> regards,
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Bug in SqlHelper
Posted by Thomas Dudziak <to...@gmail.com>.
> SqlHelper provides primitive parsing only. however in ojb 1.1 this
> problem should be solved.
Mhmm, Problem is that I'm required to use OJB 1.0.x for the time
being. Any chance of a backport ?
As a side note, what do you think about optional path hints ? E.g. for
the example query that I gave, a call like:
criteria.addPathHint("endTime");
could be used to tell OJB exactly what to look for without having to
parse the condition at all. This should be fairly easy to add ?
regards,
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Bug in SqlHelper
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi tom,
SqlHelper provides primitive parsing only. however in ojb 1.1 this
problem should be solved.
jakob
Thomas Dudziak schrieb:
> Hi folks,
>
> just found a bug in SqlHelper (I would add a bug entry in JIRA but the
seems to be down).
> Assume that I have an persistent class with two Timestamp columns, say
> 'startTime' and 'endTime', and I want to query for all instances that
> happen after a certain time, say 10 o'clock, regardless of the day.
> With PostgreSQL, I'd use a criteria like:
>
> criteria.addGreaterOrEqualThan(
> "DATE_TRUNC('minute', endTime) - DATE_TRUNC('day', endTime) + TIME '00:00'",
> startTimeToQueryFor);
>
> However, this fails with a StringIndexOutOfBoundsException in the
> SqlHelper (1.0 branch from CVS):
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: -2
> at java.lang.String.substring(String.java:1768)
> at org.apache.ojb.broker.util.SqlHelper.splitPath(SqlHelper.java:112)
> at org.apache.ojb.broker.util.SqlHelper.cleanPath(SqlHelper.java:65)
> at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.buildJoinTreeForColumn(SqlQueryStatement.java:1646)
> at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.buildJoinTree(SqlQueryStatement.java:1628)
> at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.splitCriteria(SqlQueryStatement.java:1705)
> at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.<init>(SqlQueryStatement.java:145)
> at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.<init>(SqlQueryStatement.java:97)
> at org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.<init>(SqlSelectStatement.java:51)
at org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.getPreparedSelectStatement(SqlGeneratorDefaultImpl.java:150)
> at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImpl.java:318)
> at org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(RsQueryObject.java:72)
> at org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator.java:185)
> at org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(RsIteratorFactoryImpl.java:58)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(PersistenceBrokerImpl.java:2047)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(PersistenceBrokerImpl.java:1605)
> at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:116)
> at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:255)
> at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:275)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1461)
> at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:366)
> at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:366)
>
>
> any ideas ?
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org