Changeset 6174

Show
Ignore:
Timestamp:
11/29/06 17:38:12
Author:
jan
Message:

simplified export schema task

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/example/example.iml

    r6049 r6174  
    22<module version="4" relativePaths="true" type="JAVA_MODULE"> 
    33  <component name="ModuleRootManager" /> 
    4   <component name="NewModuleRootManager"
     4  <component name="NewModuleRootManager" inherit-compiler-output="false"
    55    <output url="file://$MODULE_DIR$/classes" /> 
    66    <exclude-output /> 
     
    2929      </library> 
    3030    </orderEntry> 
     31    <orderEntry type="module-library"> 
     32      <library> 
     33        <CLASSES> 
     34          <root url="jar://$MODULE_DIR$/lib/hibernate-annotations.jar!/" /> 
     35        </CLASSES> 
     36        <JAVADOC /> 
     37        <SOURCES /> 
     38      </library> 
     39    </orderEntry> 
    3140    <orderEntryProperties /> 
    3241  </component> 
  • trunk/example/example.ipr

    r6049 r6174  
    44    <defaultAnt bundledAnt="true" /> 
    55  </component> 
     6  <component name="BuildJarProjectSettings"> 
     7    <option name="BUILD_JARS_ON_MAKE" value="false" /> 
     8  </component> 
     9  <component name="CodeStyleProjectProfileManger"> 
     10    <option name="PROJECT_PROFILE" /> 
     11    <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" /> 
     12  </component> 
    613  <component name="CodeStyleSettingsManager"> 
    714    <option name="PER_PROJECT_SETTINGS" /> 
     
    1017  <component name="CompilerConfiguration"> 
    1118    <option name="DEFAULT_COMPILER" value="Javac" /> 
    12     <option name="CLEAR_OUTPUT_DIRECTORY" value="false" /> 
    1319    <option name="DEPLOY_AFTER_MAKE" value="0" /> 
    1420    <resourceExtensions> 
     
    3339  </component> 
    3440  <component name="DependencyValidationManager" /> 
     41  <component name="EclipseCompilerSettings"> 
     42    <option name="DEBUGGING_INFO" value="true" /> 
     43    <option name="GENERATE_NO_WARNINGS" value="true" /> 
     44    <option name="DEPRECATION" value="false" /> 
     45    <option name="ADDITIONAL_OPTIONS_STRING" value="" /> 
     46    <option name="MAXIMUM_HEAP_SIZE" value="128" /> 
     47  </component> 
     48  <component name="EclipseEmbeddedCompilerSettings"> 
     49    <option name="DEBUGGING_INFO" value="true" /> 
     50    <option name="GENERATE_NO_WARNINGS" value="true" /> 
     51    <option name="DEPRECATION" value="false" /> 
     52    <option name="ADDITIONAL_OPTIONS_STRING" value="" /> 
     53    <option name="MAXIMUM_HEAP_SIZE" value="128" /> 
     54  </component> 
    3555  <component name="EntryPointsManager"> 
    3656    <entry_points /> 
     
    4262  </component> 
    4363  <component name="GUI Designer component loader factory" /> 
     64  <component name="IdProvider" IDEtalkID="3DEFDCA7E26A1BC38A63539E860BD2E6" /> 
     65  <component name="InspectionProjectProfileManager"> 
     66    <option name="PROJECT_PROFILE" value="Project Default" /> 
     67    <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" /> 
     68    <scopes /> 
     69    <profiles> 
     70      <profile version="1.0" is_locked="false"> 
     71        <option name="myName" value="Project Default" /> 
     72        <option name="myLocal" value="false" /> 
     73        <used_levels> 
     74          <error> 
     75            <option name="myName" value="ERROR" /> 
     76            <option name="myVal" value="400" /> 
     77          </error> 
     78          <warning> 
     79            <option name="myName" value="WARNING" /> 
     80            <option name="myVal" value="300" /> 
     81          </warning> 
     82          <information> 
     83            <option name="myName" value="INFO" /> 
     84            <option name="myVal" value="200" /> 
     85          </information> 
     86          <server> 
     87            <option name="myName" value="SERVER PROBLEM" /> 
     88            <option name="myVal" value="100" /> 
     89          </server> 
     90        </used_levels> 
     91      </profile> 
     92    </profiles> 
     93  </component> 
    4494  <component name="JavacSettings"> 
    4595    <option name="DEBUGGING_INFO" value="true" /> 
     
    63113    <option name="OTHER_OPTIONS" value="" /> 
    64114    <option name="HEAP_SIZE" /> 
     115    <option name="LOCALE" /> 
    65116    <option name="OPEN_IN_BROWSER" value="true" /> 
    66117  </component> 
     
    73124    <option name="ADDITIONAL_OPTIONS_STRING" value="" /> 
    74125  </component> 
     126  <component name="LogConsolePreferences"> 
     127    <option name="FILTER_ERRORS" value="false" /> 
     128    <option name="FILTER_WARNINGS" value="false" /> 
     129    <option name="FILTER_INFO" value="true" /> 
     130    <option name="CUSTOM_FILTER" /> 
     131  </component> 
    75132  <component name="Palette2"> 
    76133    <group name="Swing"> 
    77       <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false"
     134      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"
    78135        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> 
    79136      </item> 
    80       <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false"
     137      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"
    81138        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> 
    82139      </item> 
    83       <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false"
     140      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"
    84141        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> 
    85142      </item> 
    86       <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false"
     143      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"
    87144        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> 
    88145      </item> 
    89       <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false"
     146      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"
    90147        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> 
    91148        <initial-values> 
     
    93150        </initial-values> 
    94151      </item> 
    95       <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false"
     152      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"
    96153        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> 
    97154        <initial-values> 
     
    99156        </initial-values> 
    100157      </item> 
    101       <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false"
     158      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"
    102159        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> 
    103160        <initial-values> 
     
    105162        </initial-values> 
    106163      </item> 
    107       <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false"
     164      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"
    108165        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> 
    109166        <initial-values> 
     
    111168        </initial-values> 
    112169      </item> 
    113       <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false"
     170      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"
    114171        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> 
    115172          <preferred-size width="150" height="-1" /> 
    116173        </default-constraints> 
    117174      </item> 
    118       <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false"
     175      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"
    119176        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> 
    120177          <preferred-size width="150" height="-1" /> 
    121178        </default-constraints> 
    122179      </item> 
    123       <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false"
     180      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"
    124181        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> 
    125182          <preferred-size width="150" height="-1" /> 
    126183        </default-constraints> 
    127184      </item> 
    128       <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false"
    129         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
    130           <preferred-size width="150" height="50" /> 
    131         </default-constraints> 
    132       </item> 
    133       <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false"
    134         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
    135           <preferred-size width="150" height="50" /> 
    136         </default-constraints> 
    137       </item> 
    138       <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false"
    139         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
    140           <preferred-size width="150" height="50" /> 
    141         </default-constraints> 
    142       </item> 
    143       <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false"
     185      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"
     186        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
     187          <preferred-size width="150" height="50" /> 
     188        </default-constraints> 
     189      </item> 
     190      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"
     191        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
     192          <preferred-size width="150" height="50" /> 
     193        </default-constraints> 
     194      </item> 
     195      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"
     196        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
     197          <preferred-size width="150" height="50" /> 
     198        </default-constraints> 
     199      </item> 
     200      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"
    144201        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> 
    145202      </item> 
    146       <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false"
    147         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
    148           <preferred-size width="150" height="50" /> 
    149         </default-constraints> 
    150       </item> 
    151       <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false"
     203      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"
     204        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
     205          <preferred-size width="150" height="50" /> 
     206        </default-constraints> 
     207      </item> 
     208      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"
    152209        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> 
    153210          <preferred-size width="150" height="50" /> 
    154211        </default-constraints> 
    155212      </item> 
    156       <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false"
    157         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
    158           <preferred-size width="150" height="50" /> 
    159         </default-constraints> 
    160       </item> 
    161       <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false"
     213      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"
     214        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> 
     215          <preferred-size width="150" height="50" /> 
     216        </default-constraints> 
     217      </item> 
     218      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"
    162219        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> 
    163220          <preferred-size width="200" height="200" /> 
    164221        </default-constraints> 
    165222      </item> 
    166       <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false"
     223      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"
    167224        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> 
    168225          <preferred-size width="200" height="200" /> 
    169226        </default-constraints> 
    170227      </item> 
    171       <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false"
     228      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"
    172229        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> 
    173230      </item> 
    174       <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false"
     231      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"
    175232        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> 
     233      </item> 
     234      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> 
     235        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> 
     236      </item> 
     237      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> 
     238        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> 
     239      </item> 
     240      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> 
     241        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> 
     242          <preferred-size width="-1" height="20" /> 
     243        </default-constraints> 
     244      </item> 
     245      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> 
     246        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> 
     247      </item> 
     248      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> 
     249        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> 
    176250      </item> 
    177251    </group> 
     
    183257  </component> 
    184258  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" /> 
     259  <component name="ProjectRunConfigurationManager" /> 
    185260  <component name="RmicSettings"> 
    186261    <option name="IS_EANABLED" value="false" /> 
     
    189264    <option name="GENERATE_IIOP_STUBS" value="false" /> 
    190265    <option name="ADDITIONAL_OPTIONS_STRING" value="" /> 
     266  </component> 
     267  <component name="StarteamVcsAdapter" /> 
     268  <component name="VssVcs" /> 
     269  <component name="com.intellij.jsf.UserDefinedFacesConfigs"> 
     270    <option name="USER_DEFINED_CONFIGS"> 
     271      <value> 
     272        <list size="0" /> 
     273      </value> 
     274    </option> 
    191275  </component> 
    192276  <component name="com.sixrr.metrics.MetricsReloaded"> 
     
    205289    <option name="INSTRUMENT_CLASSES" value="true" /> 
    206290    <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" /> 
     291    <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" /> 
    207292  </component> 
    208293  <UsedPathMacros /> 
  • trunk/example/src/jerbil/example/JerbilEntity.java

    r6049 r6174  
    11package jerbil.example; 
     2 
     3import org.hibernate.annotations.Index; 
    24 
    35import javax.persistence.Entity; 
     
    2426    } 
    2527 
     28    @Index( name = "name_idx" ) 
    2629    public String getName() { 
    2730        return name; 
  • trunk/lib/jerbil/hibernate_task.rb

    r6145 r6174  
    77module Jerbil  
    88  module Hibernate  
    9     # Generates a SQL schema from EJB3/Hibernate-annotated classes using Hibernate's 
     9    # Generates a SQL schema from EJB3/Hibernate-annotated classes like Hibernate's 
    1010    # SchemaExport tool. Typically Jerbil::AptTask is used to compile source files and 
    1111    # gather a list of entities which then gets serialized to a YAML file. 
    12     # ExportSchemaTask then reads this file and uses Hibernate's schema exporter to  
    13     # generate SQL 
     12    # ExportSchemaTask then reads this file and uses Hibernate's schema exporting  
     13    # features to generate SQL 
    1414    # 
    1515    # == Example 
     
    2626      attr_accessor :schemafile 
    2727                         
    28       # A file containing a list of entities (<em>javax.persitence.Entity</em>), 
     28      # A file containing a list of entities (<em>javax.persistence.Entity</em>), 
    2929      # serialized as a list of strings (YAML format). 
    3030      attr_accessor :entities_yml 
     
    3636      # SQL statements to be executed before generated sql. 
    3737      attr_accessor :preamble 
     38      attr_accessor :epilogue 
    3839                         
    3940      # FQN of a package containing package-info.java to be used by 
     
    4142      attr_accessor :package 
    4243       
     44      # Pretty printing of generated SQL (default: true) 
     45      attr_accessor :prettyprint 
     46       
    4347      def initialize(name=:export_schema) 
    4448        @name = name 
    4549        @dependencies = [] 
    46         @package = nil 
    4750        @classfilter = nil 
     51        @prettyprint = true 
    4852        @schemafile = "schema.sql" 
    4953        @entities_yml = "entities.yml" 
     
    6569          entity_classes = entities.map {|klass| Rjb::import(klass)} 
    6670           
    67           schemaexporter = SchemaExporter.new( entity_classes, schemafile, dialect, package
    68           schemaexporter.export 
    69          
     71          cfg = get_config(entity_classes, package
     72          sql = cfg.generateSchemaCreationScript(Rjb::import(dialect).new) 
     73           
    7074          schema =  "# -- do not edit ---\n" 
    7175          schema << "# generated by Jerbil::Hibernate::ExportSchemaTask at #{Time.new}\n\n" 
     
    7377          schema << preamble if preamble 
    7478           
    75           schema << IO.read(schemafile) 
    76           schema = SqlBeautifier.beautify(schema) 
     79          sql.each do |s| 
     80            s = format(s) if prettyprint 
     81            schema << "#{s};" 
     82          end 
    7783           
    78           #apt.table_views.each do | table, sql | 
    79           #  schema << "\n\ncreate view #{table} AS #{sql};" 
    80           #end 
    81            
     84          schema << "\n\n#{epilogue}" if epilogue 
     85                              
    8286          File.open(schemafile, "w") {|file| file << schema } 
    8387        end 
     
    8791       
    8892      # Filters all entities. Useful to only export schema for a subset of classes. 
    89       # ==Example 
     93      # ====Example 
    9094      # Jerbil::Hibernate::ExportSchemaTask.new(:export_schema) do |t| 
    9195      #    t.filter { |classname| classname =~ /^foo/ }     
     
    9498          @classfilter = block 
    9599      end 
    96     end 
    97    
    98     # Turns the hibernate sql output into something readable. Only tested 
    99     # with the mysql dialect. 
    100     class SqlBeautifier 
    101       def SqlBeautifier.beautify(sql) 
    102         newsql = "" 
    103         sql.to_s.each do |line| 
    104           if line =~ /^create table (\w+) \((.+)\)$/  
    105             tablename = $1.strip 
    106             fields = $2.split(',') 
    107             newtabledef = "create table #{tablename} (\n"   
    108              
    109             fields.each_with_index do | definition, count | 
    110               newtabledef << "\  #{definition.strip}" 
    111               newtabledef << ",\n" if count < fields.length - 1 
    112             end 
    113             newtabledef << "\n);\n\n" 
    114             newsql << newtabledef 
    115           elsif line =~ /^alter table (\w+) ([^,]+),(.+)+$/ 
    116             tablename = $1.strip 
    117             index = $2.strip 
    118             constraint = $3.strip 
    119             newsql << "alter table #{tablename}\n  #{index},\n  #{constraint};\n\n"    
    120           else 
    121             newsql << line 
    122           end 
    123         end 
    124         newsql 
    125       end 
    126      end 
    127       
    128      # Wrapper class around  
    129      # {org.hibernate.tool.hbm2ddl.SchemaExport.}[http://www.hibernate.org/hib_docs/v3/api/org/hibernate/tool/hbm2ddl/SchemaExport.html] 
    130      class SchemaExporter 
    131        def initialize(classes, outputfile, dialect, package=nil) 
    132           @exporter = SchemaExporter.get_schema_exporter(classes, dialect, package) 
    133           @exporter.setOutputFile(outputfile) 
    134        end 
    135         
    136        def export 
    137           @exporter.execute(false,false,false,true) 
    138        end 
    139         
    140        private 
    141        def SchemaExporter.get_schema_exporter(classes, dialect, package=nil) 
    142         schemaexport = Rjb::import('org.hibernate.tool.hbm2ddl.SchemaExport') 
    143         cfg = get_config(classes, package) 
    144         cfg.getProperties.put('hibernate.dialect', dialect) 
    145             
    146         schemaexporter = schemaexport.new_with_sig 'Lorg.hibernate.cfg.Configuration;', cfg 
    147100         
    148         raise "could not create schemaexporter" if schemaexporter.nil? 
    149         schemaexporter 
    150       end 
    151      
    152       
    153       def SchemaExporter.get_config(classes, package=nil) 
     101      protected 
     102      def get_config(classes, package=nil) 
    154103        anncfg = Rjb::import('org.hibernate.cfg.AnnotationConfiguration') 
    155104        acfg = anncfg.new 
     
    164113        packages << package if package 
    165114        packages.each { |pkg| acfg.addPackage(pkg) } 
     115                 
    166116        acfg 
     117      end 
     118       
     119      def format(sql) 
     120        Rjb::import('org.hibernate.pretty.DDLFormatter').new(sql).format       
    167121      end 
    168122    end