xdoclet.modules.hibernate
Class HibernateCfgSubTask

java.lang.Object
  extended by xdoclet.DocletSupport
      extended by xdoclet.SubTask
          extended by xdoclet.TemplateSubTask
              extended by xdoclet.XmlSubTask
                  extended by xdoclet.modules.hibernate.HibernateCfgSubTask
All Implemented Interfaces:
java.io.Serializable, xdoclet.modules.hibernate.HibernateProperties

public class HibernateCfgSubTask
extends XmlSubTask
implements xdoclet.modules.hibernate.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 $
Author:
Frederick N. Brier, David Channon
See Also:
Serialized Form
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(org.apache.tools.ant.types.Parameter jndiProperty)
          These elements allow you to add properties to the JNDI context.
 void addOtherMapping(org.apache.tools.ant.types.Parameter otherMapping)
          These elements allow you to add arbitrary mappings to cfg.xml file.
 void addOtherProperty(org.apache.tools.ant.types.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).
 java.lang.String getCacheProviderClass()
           
 java.lang.String getCglibUseReflectionOptimizer()
           
 java.lang.String getDataSource()
           
 java.lang.String getDefaultSchema()
           
 java.lang.String getDialect()
           
 java.lang.String getDriver()
           
 java.lang.String getHbm2ddl()
           
 java.lang.String getJdbcUrl()
           
 java.lang.String getJndiName()
           
 java.util.Collection getJndiProperties()
           
 java.util.Collection getOtherMappings()
           
 java.util.Collection getOtherProperties()
           
 java.lang.String getPassword()
           
 java.lang.String getPoolSize()
           
 boolean getShowSql()
           
 java.lang.String getTransactionManagerFactory()
           
 java.lang.String getTransactionManagerLookup()
           
 java.lang.String getTransactionManagerStrategy()
           
 boolean getUseOuterJoin()
           
 java.lang.String getUserName()
           
 java.lang.String getUserTransactionName()
           
 java.lang.String getVersion()
          Get the Hibernate configuration DTD version.
 void setCacheProviderClass(java.lang.String string)
          The classname of a custom CacheProvider.
 void setCglibUseReflectionOptimizer(java.lang.String string)
          Enables use of CGLIB instead of runtime reflection (System-level property, default is to use CGLIB where possible).
 void setDataSource(java.lang.String dataSource)
          JNDI name of data source to use in the session factory.
 void setDefaultSchema(java.lang.String string)
          Qualify unqualified tablenames with the given schema/tablespace in generated SQL.
 void setDialect(java.lang.String dialect)
          SQL dialect of the database.
 void setDriver(java.lang.String driver)
          JDBC Driver to make database connection.
 void setHbm2ddl(java.lang.String hbm2ddl)
          Automatically export schema DDL to the database when the SessionFactory is created.
 void setJdbcUrl(java.lang.String jdbcUrl)
          URL for the JDBC Driver to make the connection to the database.
 void setJndiName(java.lang.String jndiName)
          JNDI name to bind to the SessionFactory
 void setPassword(java.lang.String password)
          Use this password to login to the database
 void setPoolSize(java.lang.String poolSize)
          Hibernate connection pool size.
 void setShowSql(boolean showSql)
          Log sql statements.
 void setTransactionManagerFactory(java.lang.String string)
          The classname of a TransactionFactory to use with Hibernate Transaction API (defaults to JDBCTransactionFactory).
 void setTransactionManagerLookup(java.lang.String transactionManagerLookup)
          The fully qualified class name of the Hibernate TransactionFactory implementation.
 void setTransactionManagerStrategy(java.lang.String transactionManagerStrategy)
          Strategy for obtaining the JTA TransactionManager
 void setUseOuterJoin(boolean useOuterJoin)
          Whether to use outer join
 void setUserName(java.lang.String userName)
          Use this user name to login to the database
 void setUserTransactionName(java.lang.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()
          Called to validate configuration parameters.
 
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, 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, startProcessForAll, startProcessPerClass
 
Methods inherited from class xdoclet.SubTask
addConfigParam, getConfigParams, getConfigParamsAsMap, getContext, getDestDir, getMergeDir, getSubTaskName, getXJavaDoc, setDestDir, setMergeDir, setSubTaskName
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateCfgSubTask

public HibernateCfgSubTask()
Constructor for the HibernateSubTask object

Method Detail

getVersion

public java.lang.String getVersion()
Get the Hibernate configuration DTD version.

Returns:

getHbm2ddl

public java.lang.String getHbm2ddl()

getTransactionManagerLookup

public java.lang.String getTransactionManagerLookup()

getJndiProperties

public java.util.Collection getJndiProperties()
Specified by:
getJndiProperties in interface xdoclet.modules.hibernate.HibernateProperties

getOtherProperties

public java.util.Collection getOtherProperties()
Specified by:
getOtherProperties in interface xdoclet.modules.hibernate.HibernateProperties

getOtherMappings

public java.util.Collection getOtherMappings()
Specified by:
getOtherMappings in interface xdoclet.modules.hibernate.HibernateProperties

getTransactionManagerStrategy

public java.lang.String getTransactionManagerStrategy()
Specified by:
getTransactionManagerStrategy in interface xdoclet.modules.hibernate.HibernateProperties

getUserTransactionName

public java.lang.String getUserTransactionName()
Specified by:
getUserTransactionName in interface xdoclet.modules.hibernate.HibernateProperties

getUserName

public java.lang.String getUserName()
Specified by:
getUserName in interface xdoclet.modules.hibernate.HibernateProperties

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface xdoclet.modules.hibernate.HibernateProperties

getUseOuterJoin

public boolean getUseOuterJoin()
Specified by:
getUseOuterJoin in interface xdoclet.modules.hibernate.HibernateProperties

getShowSql

public boolean getShowSql()
Specified by:
getShowSql in interface xdoclet.modules.hibernate.HibernateProperties

getJndiName

public java.lang.String getJndiName()
Specified by:
getJndiName in interface xdoclet.modules.hibernate.HibernateProperties

getDataSource

public java.lang.String getDataSource()
Specified by:
getDataSource in interface xdoclet.modules.hibernate.HibernateProperties

getDialect

public java.lang.String getDialect()
Specified by:
getDialect in interface xdoclet.modules.hibernate.HibernateProperties

getDriver

public java.lang.String getDriver()
Specified by:
getDriver in interface xdoclet.modules.hibernate.HibernateProperties

getJdbcUrl

public java.lang.String getJdbcUrl()
Specified by:
getJdbcUrl in interface xdoclet.modules.hibernate.HibernateProperties

getPoolSize

public java.lang.String getPoolSize()
Specified by:
getPoolSize in interface xdoclet.modules.hibernate.HibernateProperties

getCacheProviderClass

public java.lang.String getCacheProviderClass()
Returns:

getCglibUseReflectionOptimizer

public java.lang.String getCglibUseReflectionOptimizer()
Returns:

getDefaultSchema

public java.lang.String getDefaultSchema()
Returns:

getTransactionManagerFactory

public java.lang.String getTransactionManagerFactory()
Returns:

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".

setHbm2ddl

public void setHbm2ddl(java.lang.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

setPoolSize

public void setPoolSize(java.lang.String poolSize)
Hibernate connection pool size.

Parameters:
poolSize -
ant.not-required

setJdbcUrl

public void setJdbcUrl(java.lang.String jdbcUrl)
URL for the JDBC Driver to make the connection to the database.

Parameters:
jdbcUrl -
ant.not-required

setTransactionManagerStrategy

public void setTransactionManagerStrategy(java.lang.String transactionManagerStrategy)
Strategy for obtaining the JTA TransactionManager

Parameters:
transactionManagerStrategy -
ant.not-required

setUserTransactionName

public void setUserTransactionName(java.lang.String userTransactionName)
The JNDI name of the JTA UserTransaction object

Parameters:
userTransactionName -
ant.not-required

setTransactionManagerLookup

public void setTransactionManagerLookup(java.lang.String transactionManagerLookup)
The fully qualified class name of the Hibernate TransactionFactory implementation.

Parameters:
transactionManagerLookup -
ant.not-required

setUseOuterJoin

public void setUseOuterJoin(boolean useOuterJoin)
Whether to use outer join

Parameters:
useOuterJoin -
ant.not-required
No.Defaultsto false.

setShowSql

public void setShowSql(boolean showSql)
Log sql statements. Defaults to false.

Parameters:
showSql -
ant.not-required

setJndiName

public void setJndiName(java.lang.String jndiName)
JNDI name to bind to the SessionFactory

Parameters:
jndiName -
ant.not-required

setDataSource

public void setDataSource(java.lang.String dataSource)
JNDI name of data source to use in the session factory.

Parameters:
dataSource -
ant.not-required

setDialect

public void setDialect(java.lang.String dialect)
SQL dialect of the database.

Parameters:
dialect -
ant.required
Yes.Usefully-qualified classname.

setDriver

public void setDriver(java.lang.String driver)
JDBC Driver to make database connection.

Parameters:
driver -
ant.not-required

setUserName

public void setUserName(java.lang.String userName)
Use this user name to login to the database

Parameters:
userName -
ant.not-required

setPassword

public void setPassword(java.lang.String password)
Use this password to login to the database

Parameters:
password -
ant.not-required

setCacheProviderClass

public void setCacheProviderClass(java.lang.String string)
The classname of a custom CacheProvider.

Parameters:
string -
ant.not-required

setCglibUseReflectionOptimizer

public void setCglibUseReflectionOptimizer(java.lang.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

setDefaultSchema

public void setDefaultSchema(java.lang.String string)
Qualify unqualified tablenames with the given schema/tablespace in generated SQL.

Parameters:
string -
ant.not-required

setTransactionManagerFactory

public void setTransactionManagerFactory(java.lang.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

execute

public void execute()
             throws XDocletException
Generate Hibernate Configuration file (hibernate.cfg.xml).

Overrides:
execute in class TemplateSubTask
Throws:
XDocletException

validateOptions

public void validateOptions()
                     throws XDocletException
Description copied from class: TemplateSubTask
Called to validate configuration parameters.

Overrides:
validateOptions in class TemplateSubTask
Throws:
XDocletException - Description of Exception

addConfiguredJndiProperty

public void addConfiguredJndiProperty(org.apache.tools.ant.types.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.

addOtherProperty

public void addOtherProperty(org.apache.tools.ant.types.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.

addOtherMapping

public void addOtherMapping(org.apache.tools.ant.types.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.

engineStarted

protected void engineStarted()
                      throws XDocletException
Called when the engine is started

Overrides:
engineStarted in class TemplateSubTask
Throws:
XDocletException - Thrown in case of problem

http://xdoclet.sourceforge.net/