Hi JohnE,
johne wrote:
In response to below, it worked in 1.0.3 and then 1.0.4. When I
tried 1.0.5 it failed. I backed off to 1.0.4 again and it works. In
all cases I use the same latest MySql database driver. No other
changes other then the change in OJB version.
It's weird! I try to reproduce your issue without success. The query
include a class 'Person' and looks like this:
Criteria crit = new Criteria().addLike("firstname", "%o%")
.addAndCriteria(new Criteria().addLike("lastname", name));
ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
q.setAttributes(new String[]{"id", "firstname", "count(id)"});
q.addGroupBy(new String[]{"id", "firstname"});
q.addOrderByAscending("firstname");
The field 'id' is mapped as Integer in the Person class-descriptor.
In the result set array the 'count(id)' column is returned as Integer
and NOT as String (using hsql and mysql). Could you give me a hint how
to reproduce your issue?
regards,
Armin
JohnE
Armin Waibel wrote:
johne wrote:
In first testing the 1.0.5 RC, I get the error below. This
worked as is in 1.0.4. Something different with the count use in
the RC?
Caused by: java.lang.ClassCastException: java.lang.String cannot
be cast to java.lang.Long which comes from this line as shown in
more detail below: count = new
Integer(((Long)obj[2]).intValue());
This came out of getting a count out of a ReportByCriteria result
set.
Where the columns look like: private static final String[]
crColumns = new String[]{"countryId", "regionId",
"count(countryId)","count(regionId)"}; ReportQueryByCriteria
query = new
ReportQueryByCriteria(specificActiveServiceLocationQueryVO,
crColumns, crit, true); ..... ..... obj = (Object[])
resultsIt.next(); count = new Integer(((Long)obj[2]).intValue());
This could be jdbc-driver issue. If OJB doesn't know the field
(detect a not mapped field), in your case the count(...) field, the
jdbc-type is resolved by using the ResultSet metadata
(rsMetaData.getColumnType(...)) of the jdbc-driver.
You can try to use the query.setJdbcTypes method to specify the
sql-types, then OJB resolves the proper java-jdbc-types
http://db.apache.org/ojb/docu/guides/jdbc-types.html
int types[] = new int[]{Types.DECIMAL, Types.VARCHAR,
Types.BIGINT}; ReportQueryByCriteria q =
QueryFactory.newReportQuery(Person.class, crit);
q.setAttributes(new String[]{"id", "firstname", "count(*)"});
q.setJdbcTypes(types);
This should work for all none mapped query fields. If the field is
mapped the type setting will be ignored - this is a bug and will
be fixed in 1.0.5rc2.
regards, Armin
----- JohnE
http://jobbank.com/ jobbank.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For
additional commands, e-mail: [EMAIL PROTECTED]
----- JohnE
http://jobbank.com/ jobbank.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]