4.7. Setting the SQL Join Syntax

JDO queries often involve using SQL joins behind the scenes. You can configure Kodo to use either SQL 92-style join syntax, in which joins are placed in the SQL FROM clause, the traditional join syntax, in which join criteria are part of the WHERE clause, or a database-specific join syntax mandated by the DBDictionary. Kodo only supports outer joins when using SQL 92 syntax or a database-specific syntax with outer join support.

The kodo.jdbc.DBDictionary plugin accepts the the JoinSyntax property to set the system's default syntax. Syntax can be changed on a per persistence manager, query, or extent basis using the fetch configuration API, which is described in the JDO Runtime Extensions chapter.

Example 4.5. Specifying the Join Syntax Default

kodo.jdbc.DBDictionary: JoinSyntax=sql92

Example 4.6. Specifying the Join Syntax at Runtime

import kodo.query.*;          // for KodoQuery
import kodo.jdbc.runtime.*;   // for JDBCFetchConfiguration


KodoQuery kq = (KodoQuery) pm.newQuery (MyClass.class, "foo == bar");
JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) 
    kq.getFetchConfiguration ();
fetch.setJoinSyntax (fetch.JOIN_SYNTAX_SQL92);
Collection results = (Collection) kq.execute ();