views:

56

answers:

1

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.

+2  A: 

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

DataNucleus
Here is the missing link to Querydsl : http://source.mysema.com/display/querydsl/Querydsl
Timo Westkämper