org.hibernate.tool.hbm2ddl
Class SchemaExport

java.lang.Object
  extended by org.hibernate.tool.hbm2ddl.SchemaExport

public class SchemaExport
extends Object

Commandline tool to export table schema to the database. This class may also be called from inside an application.


Nested Class Summary
static class SchemaExport.Type
           
 
Constructor Summary
SchemaExport(Configuration configuration)
          Create a schema exporter for the given Configuration
SchemaExport(Configuration configuration, Connection connection)
          Create a schema exporter for the given Configuration, using the supplied connection for connectivity.
SchemaExport(Configuration configuration, Properties properties)
          Deprecated. properties may be specified via the Configuration object
SchemaExport(ConnectionHelper connectionHelper, String[] dropSql, String[] createSql)
           
SchemaExport(MetadataImplementor metadata)
           
SchemaExport(ServiceRegistry serviceRegistry, Configuration configuration)
           
 
Method Summary
 void create(boolean script, boolean export)
          Run the schema creation script; drop script is automatically executed before running the creation script.
 void create(Target output)
          Run the schema creation script; drop script is automatically executed before running the creation script.
 void drop(boolean script, boolean export)
          Run the drop schema script.
 void drop(Target output)
           
 void execute(boolean script, boolean export, boolean justDrop, boolean justCreate)
           
 void execute(Target output, SchemaExport.Type type)
           
 List getExceptions()
          Returns a List of all Exceptions which occured during the export.
static void main(String[] args)
           
 SchemaExport setDelimiter(String delimiter)
          Set the end of statement delimiter
 SchemaExport setFormat(boolean format)
          Should we format the sql strings?
 SchemaExport setHaltOnError(boolean haltOnError)
          Should we stop once an error occurs?
 SchemaExport setImportSqlCommandExtractor(ImportSqlCommandExtractor importSqlCommandExtractor)
          Set import.sql command extractor.
 SchemaExport setOutputFile(String filename)
          For generating a export script file, this is the file which will be written.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaExport

public SchemaExport(ServiceRegistry serviceRegistry,
                    Configuration configuration)

SchemaExport

public SchemaExport(MetadataImplementor metadata)

SchemaExport

public SchemaExport(Configuration configuration)
Create a schema exporter for the given Configuration

Parameters:
configuration - The configuration from which to build a schema export.
Throws:
HibernateException - Indicates problem preparing for schema export.

SchemaExport

@Deprecated
public SchemaExport(Configuration configuration,
                               Properties properties)
             throws HibernateException
Deprecated. properties may be specified via the Configuration object

Create a schema exporter for the given Configuration, with the given database connection properties.

Parameters:
configuration - The configuration from which to build a schema export.
properties - The properties from which to configure connectivity etc.
Throws:
HibernateException - Indicates problem preparing for schema export.

SchemaExport

public SchemaExport(Configuration configuration,
                    Connection connection)
             throws HibernateException
Create a schema exporter for the given Configuration, using the supplied connection for connectivity.

Parameters:
configuration - The configuration to use.
connection - The JDBC connection to use.
Throws:
HibernateException - Indicates problem preparing for schema export.

SchemaExport

public SchemaExport(ConnectionHelper connectionHelper,
                    String[] dropSql,
                    String[] createSql)
Method Detail

setOutputFile

public SchemaExport setOutputFile(String filename)
For generating a export script file, this is the file which will be written.

Parameters:
filename - The name of the file to which to write the export script.
Returns:
this

setDelimiter

public SchemaExport setDelimiter(String delimiter)
Set the end of statement delimiter

Parameters:
delimiter - The delimiter
Returns:
this

setFormat

public SchemaExport setFormat(boolean format)
Should we format the sql strings?

Parameters:
format - Should we format SQL strings
Returns:
this

setImportSqlCommandExtractor

public SchemaExport setImportSqlCommandExtractor(ImportSqlCommandExtractor importSqlCommandExtractor)
Set import.sql command extractor. By default SingleLineSqlCommandExtractor is used.

Parameters:
importSqlCommandExtractor - import.sql command extractor.
Returns:
this

setHaltOnError

public SchemaExport setHaltOnError(boolean haltOnError)
Should we stop once an error occurs?

Parameters:
haltOnError - True if export should stop after error.
Returns:
this

create

public void create(boolean script,
                   boolean export)
Run the schema creation script; drop script is automatically executed before running the creation script.

Parameters:
script - print the DDL to the console
export - export the script to the database

create

public void create(Target output)
Run the schema creation script; drop script is automatically executed before running the creation script.

Parameters:
output - the target of the script.

drop

public void drop(boolean script,
                 boolean export)
Run the drop schema script.

Parameters:
script - print the DDL to the console
export - export the script to the database

drop

public void drop(Target output)

execute

public void execute(boolean script,
                    boolean export,
                    boolean justDrop,
                    boolean justCreate)

execute

public void execute(Target output,
                    SchemaExport.Type type)

main

public static void main(String[] args)

getExceptions

public List getExceptions()
Returns a List of all Exceptions which occured during the export.

Returns:
A List containig the Exceptions occured during the export


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.