Question

When querying with JDOQL is there a performance difference between using the declarative version and the Single-String version:

Example from the JDOQL doc:

//Declarative JDOQL :
Query q = pm.newQuery(org.jpox.Person.class, "lastName == \"Jones\" && age < age_limit");
q.declareParameters("double age_limit");
List results = (List)q.execute(20.0);

//Single-String JDOQL :
Query q = pm.newQuery("SELECT FROM org.jpox.Person WHERE lastName == \"Jones\"" +
                      " && age < :age_limit PARAMETERS double age_limit");
List results = (List)q.execute(20.0);

Other then performance, are there any reasons for which one is better to use then the other or is it just about the one with which we feel more comfortable.

Was it helpful?

Solution

No performance difference at all. The only thing that happens is that the single-string form is parsed into the components. Use which you find most convenient. Alternatively use QueryDSL's JDOQL. JDO3.x has slated the provision of a type-safe refactorable query API, but something that is usable (unlike JPA2 Criteria) akin to QueryDSL

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top