com.triactive.jdo.jdbc
Interface SqlPostProcessor


public interface SqlPostProcessor

Provides a hook by which some of the SQL executed by TJDO can be altered before execution. This is termed post-processing because it occurs as a last step after any processing performed by TJDO itself, such as expansion of SQL identifier macros. Post-processing can be used, for example, to expand user-defined macros in the SQL text, or (more ambitiously) to alter syntax to accommodate differences among SQL vendors.

Post-processor classes are specified by name in a "sql-post-processor" extension of JDO metadata. Classes implementing this interface must have a no-arg constructor.

The only SQL eligible for post-processing is that which originates from user code in the first place, namely:

  1. The CREATE VIEW DDL provided as "view-definition" in a view class's metadata.
  2. A TJDOSQL query statement which uses the "candidate class" to define the result type. Those which use the "result class" are not post-processed, since in that style the result type is not necessarily a persistence-capable class and therefore would not have any JDO metadata in which to specify the post-processor.

Author:
Mike Martin

Method Summary
 java.lang.String processSql(java.lang.String stmts, SchemaManager schemaMgr, java.lang.Class pcClass)
          Called to perform optional post-processing of SQL statements prior to execution by TJDO.
 

Method Detail

processSql

public java.lang.String processSql(java.lang.String stmts,
                                   SchemaManager schemaMgr,
                                   java.lang.Class pcClass)
Called to perform optional post-processing of SQL statements prior to execution by TJDO. This method will be called after any SQL identifier macros have been expanded.

If processing fails this method may throw an unchecked exception, which will abort whatever operation was in progress and, in most cases, be propagated all the way back out to user code. If implementations do so it is recommended they throw a JDOUserException, or some subclass thereof.

Parameters:
stmts - The text of one or more SQL statements, separated by a semi-colon.
schemaMgr - The schema manager of the schema in which the SQL will be executed.
pcClass - The persistent-capable class for which the SQL is being performed, or null if the statements do not pertain to any particular class. When creating views, this is the view's PC class.
Returns:
The modified statements, or the original statements if no modifications are needed.


Copyright © 2001-2007 The TJDO Project All Rights Reserved.