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 Sy...@swisscom.com on 2003/05/23 10:53:09 UTC

problem with Criteria.addSql() method

Hello,

I have another strange probem:

This code works fine:
----code----
String sqlQuery = "select distinct(workstationName) from Workstation w, WntWorkstation t where (w.workstationName like '%' or w.workstationName is NULL) order by w.workstationName";
Query query = QueryFactory.newQuery(Workstation.class, sqlQuery);

int numberOfWorkstations = 0;
numberOfWorkstations = broker.getCount(query);
----code----

But this code produces the error below:
----code----
Criteria crit = new Criteria();
crit.addSql(sqlQuery);

Query query = QueryFactory.newQuery(Workstation.class, crit);

int numberOfWorkstations = 0;
numberOfWorkstations = 
----code----

ERROR:
[org.apache.ojb.broker.accesslayer.JdbcAccess] DEBUG: executeCount : Query from class wocconfigdb400.data.Workstation where select distinct(workstationName) from Workstation w, WntWorkstation t where (w.workstationName like '%' or w.workstationName is NULL) order by w.workstationName
[org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR: error executing count: String index out of range: 144
String index out of range: 144
java.lang.StringIndexOutOfBoundsException: String index out of range: 144
	at java.lang.String.substring(Unknown Source)
	at org.apache.ojb.broker.accesslayer.SqlStatement.buildJoinTreeForColumn(Unknown Source)
	at org.apache.ojb.broker.accesslayer.SqlStatement.buildJoinTree(Unknown Source)



Is someone has an idea?

Thanks
Sylvain