xdoclet.modules.hibernate

Class HibernateCfgSubTask

Implemented Interfaces:
HibernateProperties, Serializable

public class HibernateCfgSubTask
extends xdoclet.XmlSubTask
implements HibernateProperties

Generate the hibernate.cfg.xml file. It lists all of the properties as well as a property for each hbm.xml file. This file can be used for creating and installing a SessionFactory in JNDI as well as launching Hibern8IDE.
Version:
$Revision: 1.10 $
Authors:
Frederick N. Brier
David Channon
ant.element
name = "hibernatecfg" display-name = "Hibernate Configuration File Generation" parent = "xdoclet.modules.hibernate.HibernateDocletTask"
created
February 6, 2004

Nested Class Summary

static class
HibernateCfgSubTask.HibernateCFGVersion
Based on Matt Raible's code for the Hibernate sub-task.

Nested classes/interfaces inherited from class xdoclet.TemplateSubTask

TemplateSubTask.ExtentTypes, TemplateSubTask.OfType

Field Summary

Fields inherited from class xdoclet.DocletSupport

currentClassTag, currentFieldTag, currentMethodTag

Constructor Summary

HibernateCfgSubTask()
Constructor for the HibernateSubTask object

Method Summary

void
addConfiguredJndiProperty(Parameter jndiProperty)
These elements allow you to add properties to the JNDI context.
void
addOtherMapping(Parameter otherMapping)
These elements allow you to add arbitrary mappings to cfg.xml file.
void
addOtherProperty(Parameter otherProperty)
These elements allow you to add arbitrary properties to cfg.xml file.
protected void
engineStarted()
Called when the engine is started
void
execute()
Generate Hibernate Configuration file (hibernate.cfg.xml).
String
getCacheProviderClass()
String
getCglibUseReflectionOptimizer()
String
getDataSource()
String
getDefaultSchema()
String
getDialect()
String
getDriver()
String
getHbm2ddl()
String
getJdbcUrl()
String
getJndiName()
Collection
getJndiProperties()
Collection
getOtherMappings()
Collection
getOtherProperties()
String
getPassword()
String
getPoolSize()
boolean
getShowSql()
String
getTransactionManagerFactory()
String
getTransactionManagerLookup()
String
getTransactionManagerStrategy()
boolean
getUseOuterJoin()
String
getUserName()
String
getUserTransactionName()
String
getVersion()
Get the Hibernate configuration DTD version.
void
setCacheProviderClass(String string)
The classname of a custom CacheProvider.
void
setCglibUseReflectionOptimizer(String string)
Enables use of CGLIB instead of runtime reflection (System-level property, default is to use CGLIB where possible).
void
setDataSource(String dataSource)
JNDI name of data source to use in the session factory.
void
setDefaultSchema(String string)
Qualify unqualified tablenames with the given schema/tablespace in generated SQL.
void
setDialect(String dialect)
SQL dialect of the database.
void
setDriver(String driver)
JDBC Driver to make database connection.
void
setHbm2ddl(String hbm2ddl)
Automatically export schema DDL to the database when the SessionFactory is created.
void
setJdbcUrl(String jdbcUrl)
URL for the JDBC Driver to make the connection to the database.
void
setJndiName(String jndiName)
JNDI name to bind to the SessionFactory
void
setPassword(String password)
Use this password to login to the database
void
setPoolSize(String poolSize)
Hibernate connection pool size.
void
setShowSql(boolean showSql)
Log sql statements.
void
setTransactionManagerFactory(String string)
The classname of a TransactionFactory to use with Hibernate Transaction API (defaults to JDBCTransactionFactory).
void
setTransactionManagerLookup(String transactionManagerLookup)
The fully qualified class name of the Hibernate TransactionFactory implementation.
void
setTransactionManagerStrategy(String transactionManagerStrategy)
Strategy for obtaining the JTA TransactionManager
void
setUseOuterJoin(boolean useOuterJoin)
Whether to use outer join
void
setUserName(String userName)
Use this user name to login to the database
void
setUserTransactionName(String userTransactionName)
The JNDI name of the JTA UserTransaction object
void
setVersion(HibernateCfgSubTask.HibernateCFGVersion version)
Sets the hibernate configuration DTD version to use.
void
validateOptions()

Methods inherited from class xdoclet.XmlSubTask

copyAttributesFrom, engineFinished, getDtdURL, getPublicId, getSchema, getSchemaURL, getSystemId, getUseIds, getXmlencoding, isValidateXML, setDtdURL, setPublicId, setSchema, setSchemaURL, setSystemId, setUseIds, setValidateXML, setXmlencoding, startProcess

Methods inherited from class xdoclet.TemplateSubTask

addOfType, addOfType, addPackageSubstitution, copyAttributesFrom, engineFinished, engineStarted, execute, generateForClass, getAcceptAbstractClasses, getAcceptInterfaces, getDestinationFile, getEngine, getExtent, getGeneratedFileName, getGenerationManager, getHavingClassTag, getOfType, getPackageSubstitutions, getSubTaskClassName, getTemplateURL, init, isPackageSubstitutionInheritanceSupported, isPrefixWithPackageStructure, javaFile, matchesGenerationRules, processInnerClasses, setAcceptAbstractClasses, setAcceptInterfaces, setDestinationFile, setEngine, setExtent, setExtentValue, setGenerationManager, setHavingClassTag, setOfType, setPackageSubstitutionInheritanceSupported, setPackageSubstitutions, setPrefixWithPackageStructure, setSubTaskClassName, setTemplateFile, setTemplateURL, startEngine, startProcess, startProcessForAll, startProcessPerClass, validateOptions

Methods inherited from class xdoclet.SubTask

addConfigParam, copyAttributesFrom, execute, getConfigParams, getConfigParamsAsMap, getContext, getDestDir, getMergeDir, getSubTaskName, getXJavaDoc, init, setDestDir, setMergeDir, setSubTaskName, validateOptions

Methods inherited from class xdoclet.DocletSupport

getCurrentClass, getCurrentClassTag, getCurrentConstructor, getCurrentField, getCurrentFieldTag, getCurrentMethod, getCurrentMethodTag, getCurrentPackage, getCurrentTag, isDocletGenerated, popCurrentClass, pushCurrentClass, setCurrentClass, setCurrentClassTag, setCurrentConstructor, setCurrentField, setCurrentFieldTag, setCurrentMethod, setCurrentMethodTag, setCurrentPackage

Constructor Details

HibernateCfgSubTask

public HibernateCfgSubTask()
Constructor for the HibernateSubTask object

Method Details

addConfiguredJndiProperty

public void addConfiguredJndiProperty(Parameter jndiProperty)
These elements allow you to add properties to the JNDI context. For instance, if you do not want Weblogic clustering to replicate the Hibernate SessionFactory, add a jndiProperty element with a "name" attribute of "weblogic.jndi.replicateBindings" and a "value" attribute of "false".
Parameters:
jndiProperty -
ant.not-required
No.Emptyarray ofelements.

addOtherMapping

public void addOtherMapping(Parameter otherMapping)
These elements allow you to add arbitrary mappings to cfg.xml file. For instance, if you want to specify that a jar contains /example/myHibernate.hbm.xml file then specify a other mapping with the name="resource" and the value being the path to the mapping.
Parameters:
otherMapping - The feature to be added to the OtherMapping attribute
ant.not-required
No.Emptyarray ofelements.

addOtherProperty

public void addOtherProperty(Parameter otherProperty)
These elements allow you to add arbitrary properties to cfg.xml file. For instance, if you want to provide your own "connection.provider_class" class then add a property called connection.provider_class with a value of whatever you want passed in.
Parameters:
otherProperty - The feature to be added to the OtherProperty attribute
ant.not-required
No.Emptyarray ofelements.

engineStarted

protected void engineStarted()
            throws xdoclet.XDocletException
Called when the engine is started
Overrides:
engineStarted in interface xdoclet.TemplateSubTask
Throws:
xdoclet.XDocletException - Thrown in case of problem

execute

public void execute()
            throws xdoclet.XDocletException
Generate Hibernate Configuration file (hibernate.cfg.xml).
Overrides:
execute in interface xdoclet.TemplateSubTask
Throws:
xdoclet.XDocletException -

getCacheProviderClass

public String getCacheProviderClass()
Returns:

getCglibUseReflectionOptimizer

public String getCglibUseReflectionOptimizer()
Returns:

getDataSource

public String getDataSource()

getDefaultSchema

public String getDefaultSchema()
Returns:

getDialect

public String getDialect()

getDriver

public String getDriver()

getHbm2ddl

public String getHbm2ddl()

getJdbcUrl

public String getJdbcUrl()

getJndiName

public String getJndiName()

getJndiProperties

public Collection getJndiProperties()

getOtherMappings

public Collection getOtherMappings()

getOtherProperties

public Collection getOtherProperties()

getPassword

public String getPassword()

getPoolSize

public String getPoolSize()

getShowSql

public boolean getShowSql()

getTransactionManagerFactory

public String getTransactionManagerFactory()
Returns:

getTransactionManagerLookup

public String getTransactionManagerLookup()

getTransactionManagerStrategy

public String getTransactionManagerStrategy()

getUseOuterJoin

public boolean getUseOuterJoin()

getUserName

public String getUserName()

getUserTransactionName

public String getUserTransactionName()

getVersion

public String getVersion()
Get the Hibernate configuration DTD version.
Returns:

setCacheProviderClass

public void setCacheProviderClass(String string)
The classname of a custom CacheProvider.
Parameters:
string -
ant.not-required

setCglibUseReflectionOptimizer

public void setCglibUseReflectionOptimizer(String string)
Enables use of CGLIB instead of runtime reflection (System-level property, default is to use CGLIB where possible). Reflection can sometimes be useful when troubleshooting.
Parameters:
string -
ant.not-required

setDataSource

public void setDataSource(String dataSource)
JNDI name of data source to use in the session factory.
Parameters:
dataSource -
ant.not-required

setDefaultSchema

public void setDefaultSchema(String string)
Qualify unqualified tablenames with the given schema/tablespace in generated SQL.
Parameters:
string -
ant.not-required

setDialect

public void setDialect(String dialect)
SQL dialect of the database.
Parameters:
dialect -
ant.required
Yes.Usefully-qualified classname.

setDriver

public void setDriver(String driver)
JDBC Driver to make database connection.
Parameters:
driver -
ant.not-required

setHbm2ddl

public void setHbm2ddl(String hbm2ddl)
Automatically export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitely. eg. update | create | create-drop
Parameters:
hbm2ddl -
ant.not-required

setJdbcUrl

public void setJdbcUrl(String jdbcUrl)
URL for the JDBC Driver to make the connection to the database.
Parameters:
jdbcUrl -
ant.not-required

setJndiName

public void setJndiName(String jndiName)
JNDI name to bind to the SessionFactory
Parameters:
jndiName -
ant.not-required

setPassword

public void setPassword(String password)
Use this password to login to the database
Parameters:
password -
ant.not-required

setPoolSize

public void setPoolSize(String poolSize)
Hibernate connection pool size.
Parameters:
poolSize -
ant.not-required

setShowSql

public void setShowSql(boolean showSql)
Log sql statements. Defaults to false.
Parameters:
showSql -
ant.not-required

setTransactionManagerFactory

public void setTransactionManagerFactory(String string)
The classname of a TransactionFactory to use with Hibernate Transaction API (defaults to JDBCTransactionFactory). eg. classname.of.TransactionFactory
Parameters:
string -
ant.not-required

setTransactionManagerLookup

public void setTransactionManagerLookup(String transactionManagerLookup)
The fully qualified class name of the Hibernate TransactionFactory implementation.
Parameters:
transactionManagerLookup -
ant.not-required

setTransactionManagerStrategy

public void setTransactionManagerStrategy(String transactionManagerStrategy)
Strategy for obtaining the JTA TransactionManager
Parameters:
transactionManagerStrategy -
ant.not-required

setUseOuterJoin

public void setUseOuterJoin(boolean useOuterJoin)
Whether to use outer join
Parameters:
useOuterJoin -
ant.not-required
No.Defaultsto false.

setUserName

public void setUserName(String userName)
Use this user name to login to the database
Parameters:
userName -
ant.not-required

setUserTransactionName

public void setUserTransactionName(String userTransactionName)
The JNDI name of the JTA UserTransaction object
Parameters:
userTransactionName -
ant.not-required

setVersion

public void setVersion(HibernateCfgSubTask.HibernateCFGVersion version)
Sets the hibernate configuration DTD version to use. Legal values are "2.0" and "3.0".
Parameters:
version -
ant.not-required
No.Defaultis "2.0".

validateOptions

public void validateOptions()
            throws xdoclet.XDocletException
Overrides:
validateOptions in interface xdoclet.TemplateSubTask