public class StatementCompilerTask extends Task (Code)
Compiles SQL query to interface and engine classes using metadata obtained
from the database.
SQLC uses BCEL and ANTLR
for code generation. If you have pvcommons.jar, bcel-5.1.jar and antlr.jar in
the system classpath
or in Ant lib directory then SQLC task can be defined as
Otherwise jars which are not in the classpath shall be specified in task definition
classpath. SQLC connects to the target database during generation,
therefore database driver shall also be present in the classpath
<sqlc script="src/com/pavelvlasov/jsel/impl/Hypersonic.sql" dir="sqlc_generated" docDir="sqlcDoc" package="biz.hammurapi.jsel.impl.sql" masterEngine="Engine" > <query name="CompilationUnit" singleRow="yes"> SELECT * FROM COMPILATION_UNIT WHERE ID=? </query>
<query name="CompilationUnitByStoreLevel"> SELECT * FROM COMPILATION_UNIT C WHERE REPOSITORY=? AND C.STORE_LEVEL=? AND EXISTS(SELECT * FROM COMPILATION_UNIT_SCAN S WHERE S.COMPILATION_UNIT_ID=C.ID AND S.REPOSITORY=C.REPOSITORY AND S.SCAN_ID=?) </query>
<update name="DeleteCompilationUnit"> DELETE FROM COMPILATION_UNIT WHERE ID=? </update> </sqlc>
setNameMap(boolean useNameMap) If this attribute is true then:
1) All queries and updates generated for tables will have table
and schema name enclosed into ${ and } e.g.
setSmartBase(String smartBase) Base class (fully qualified name) for generated smart implementations.
public void
setUseSqlTypes(boolean useSqlTypes) If true then generated classes will use setObject(int, Object, int) method
instead of setObject(int, Object) to set parameters of object type.
public void
setXmlDoc(boolean xmlDoc) If true documentation will be generated in XML format for
further styling.
Statements xml file. Top element should be 'statements', containing 'query' and 'update' elements which
have the same format as nested 'query' and 'update' elements.
Parameters: queries -
addConnection
public void addConnection(ConnectionEntry ce)(Code)
Directory to output HTML documentation.
Parameters: documentation -
setEngineMethodsVisibility
public void setEngineMethodsVisibility(String engineMethodsVisibility)(Code)
Visibility of engine methods. Valid values are "public" (default), "protected" and
"" (empty string for default/package visibility).
Parameters: engineMethodsVisibility -
setEngineVisibility
public void setEngineVisibility(String engineVisibility)(Code)
Visibility of engine class. Valid values are "public" (default), and
"" (empty string for default/package visibility).
Parameters: engineVisibility -
Documentation index file name.
Defaults to 'index.xml' for XML output
and 'index.html' for HTML output.
Parameters: indexName -
setInheritMetadata
public void setInheritMetadata(boolean inheritMetadata)(Code)
Use parent's metadata file if any.
Valid for nested tasks. Default is false.
Parameters: inheritMetadata -
setInterfaceImplVisibility
public void setInterfaceImplVisibility(String interfaceImplVisibility)(Code)
Visibility of interface implementation classes. Valid values are "public" (default), and
"" (empty string for default/package visibility).
setMasterEngine
public void setMasterEngine(String masterEngineName)(Code)
Class name for master engine. Set this attribute if you want
all engine methods be held in one class and avoid generation of
an engine class per statement.
Parameters: masterEngineName -
If this attribute is true then:
1) All queries and updates generated for tables will have table
and schema name enclosed into ${ and } e.g. ${BANK}.${ACCOUNT}
2) SQLProcessor used to obtain
This attribute creates blank name map, if you need a prepopulated name map use
Parameters: useNameMap -
setNameMapFile
public void setNameMapFile(File nameMapFile)(Code)
DDL script file. Statements shall be separated by semicolons.
If this attribute is set then in-memory Hypersonic database is created,
gets populated using script and query is compiled against this database.
If neither connection nor script is specified the uninitialized Hypersonic
in-memory database will be used. It can be useful if several sqlc tasks
are executed in a row against the same database.
Parameters: script -
Base class (fully qualified name) for generated smart implementations. Default is biz.hammurapi.sql.DatabaseObject
The base class is supposed to have same constructors and methods as DatabaseObject. The idea is
to subclass DatabaseObject to introduce additional qualities like audit, metrics, security, ... whithout
changing class' contract. This setting is not inherited from the parent task.
Parameters: smartBase - The smartBase to set.
setUseSqlTypes
public void setUseSqlTypes(boolean useSqlTypes)(Code)
If true then generated classes will use setObject(int, Object, int) method
instead of setObject(int, Object) to set parameters of object type.
Nested tasks inherit parent setting unless overriden.
Parameters: useSqlTypes -