Hello,

There's the following bug in Castor JDO:

If you created an object of class C and later in the same transaction you query the number of objects of class C (select count(*)), the second query throws a QueryException "query timeout".

Please verify the bug with the following code snippet you can run on the example database supplied by Castor. Please let me know if You get the same result.

My system configuartion:
Castor JDO 0.9.5
SAP DB 7.4
JVM 1.4.2

Regards,
michael

- - - snippet - - -

import java.io.PrintWriter;

import org.exolab.castor.jdo.Database;
import org.exolab.castor.jdo.JDO;
import org.exolab.castor.jdo.OQLQuery;
import org.exolab.castor.jdo.QueryResults;
import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.util.Logger;

public class Main {

public static final String DatabaseFile = "database.xml";
public static final String MappingFile = "mapping.xml";
public static final String myDatabaseName = "POTATO"; // please change this to name YOUR database.
private Mapping     _mapping;
private JDO         _jdo;
private PrintWriter _writer;

public static void main(String[] args) {
PrintWriter writer;
writer =
new Logger(System.out).setPrefix("TEST");
try {
new Main(writer).run();
}
catch (Exception except) {
except.printStackTrace(writer);
}
}

public Main(PrintWriter writer) throws Exception {
// Load the mapping file
_mapping = new Mapping(getClass().getClassLoader());
_mapping.setLogWriter(writer);
_mapping.loadMapping(getClass().getResource(MappingFile));

// Load JDO
_jdo = new JDO();
_jdo.setLogWriter(writer);
_jdo.setConfiguration(getClass().getResource(DatabaseFile).toString());
_jdo.setDatabaseName(myDatabaseName);
_writer = writer;
}

public void run() throws Exception {
Database db = _jdo.getDatabase();

db.begin();
{
OQLQuery qry = db.getOQLQuery(
"select g from ProductGroup g where id=$1");
qry.bind(
new Long(3));
QueryResults results = qry.execute();
if (results.hasMore()) {
ProductGroup pg = (ProductGroup) results.next();
qry = db.getOQLQuery (
"select count(*) from "
+ ProductDetail.class.getName()
+
" d where d.product.group=$1");
qry.bind(pg);
results = qry.execute();
if (results.hasMore()) {
java.math.BigDecimal num = (java.math.BigDecimal) results.next();
_writer.println(
"count = " + num);
}

Product p = (Product) db.load(Product.
class, new Integer(586));
ProductDetail detail =
new ProductDetail();
detail.setName(
"Bibifax");
detail.setProduct(p);
db.create(detail);
qry = db.getOQLQuery (
"select count(*) from "
+ ProductDetail.class.getName()
+
" d where d.product.group=$1");
qry.bind(pg);
results = qry.execute(); 
// !! This is where you get a request time out !!
if (results.hasMore()) {
java.math.BigDecimal num = (java.math.BigDecimal) results.next();
_writer.println(
"count = " + num);
}
}
}
db.commit();

db.close();
_writer.println(
"Test complete");
}

}

Reply via email to