ch.sahits.codegen.generator
Class HibernateConfigurationCreator

java.lang.Object
  extended by ch.sahits.codegen.model.BasicModelGenerator
      extended by ch.sahits.codegen.generator.HibernateConfigurationCreator
All Implemented Interfaces:
IDBAccess, IGeneralFileGenerator, IGeneralGenerator

public final class HibernateConfigurationCreator
extends BasicModelGenerator
implements IGeneralFileGenerator, IDBAccess

This class generates a Hibernate XML configuration file. The input is based upon the a BasicDataBaseTable and a database definition. The output is a file that is something like this

 <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
        <property name="connection.url">jdbc:postgresql://localhost/firsthibernate</property>
        <property name="connection.username">postgres</property>
        <property name="connection.driver_class">org.postgresql.Driver</property>
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="connection.password">p</property>
 <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <!--  thread is the short name for
      org.hibernate.context.ThreadLocalSessionContext
      and let Hibernate bind the session automatically to the thread
    -->
    <property name="current_session_context_class">thread</property>
    <!-- this will show us all sql statements -->
    <property name="hibernate.show_sql">true</property>
        <!-- mapping files -->
        <mapping resource="de/laliluna/example/Honey.hbm.xml" />
</session-factory>
</hibernate-configuration>

Author:
Andi Hotz

Constructor Summary
HibernateConfigurationCreator()
           
 
Method Summary
 IGeneratedObject createModel(IProgressMonitor monitor, IOutputFileModel model)
          Create an arbitrary model for the generator class.
 IFile generate()
          Generate a Hibernate XML configuration file and return it as a String
 java.lang.String getAbsoluteOutputLoacation()
          Retrieve the absolute path to the file output location based on the initialized model
 void init(IOutputFileModel outputModel, IGeneratedObject model)
          Initialize the model this generators model The model must be an instance of IDBTable.
 boolean isGeneratedOutputFile()
          This generator class generate() method returns an IFile instance
 
Methods inherited from class ch.sahits.codegen.model.BasicModelGenerator
createModelWithDBInputFile, createModelWithoutDB, initModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateConfigurationCreator

public HibernateConfigurationCreator()
Method Detail

init

public void init(IOutputFileModel outputModel,
                 IGeneratedObject model)
Initialize the model this generators model The model must be an instance of IDBTable. If the model is not of this type a ClassCastException is thrown

Specified by:
init in interface IGeneralGenerator
Parameters:
outputModel - IOutputFileModel that defines the setup of the generation
model - IDBTable

generate

public IFile generate()
Generate a Hibernate XML configuration file and return it as a String

Specified by:
generate in interface IGeneralFileGenerator
Returns:
Hibernate XML configuration file as String

isGeneratedOutputFile

public boolean isGeneratedOutputFile()
This generator class generate() method returns an IFile instance

Specified by:
isGeneratedOutputFile in interface IGeneralGenerator
Returns:
true

createModel

public IGeneratedObject createModel(IProgressMonitor monitor,
                                    IOutputFileModel model)
Create an arbitrary model for the generator class. Create an IDBTable from the object model.

Specified by:
createModel in interface IGeneralGenerator
Parameters:
monitor - to monitor the progress
model - Model of the data of the wizard
Returns:
Object model that is passed as the second parameter to init(IOutputFileModel, IGeneratedObject)

getAbsoluteOutputLoacation

public java.lang.String getAbsoluteOutputLoacation()
Retrieve the absolute path to the file output location based on the initialized model

Specified by:
getAbsoluteOutputLoacation in interface IGeneralFileGenerator
Returns:
Absolut path to the output location