Example usage for org.hibernate.tool.hbm2ddl SchemaExport setDelimiter

List of usage examples for org.hibernate.tool.hbm2ddl SchemaExport setDelimiter

Introduction

In this page you can find the example usage for org.hibernate.tool.hbm2ddl SchemaExport setDelimiter.

Prototype

public SchemaExport setDelimiter(String delimiter) 

Source Link

Document

Set the end of statement delimiter

Usage

From source file:sk.lazyman.gizmo.SpringApplicationContextTest.java

License:Apache License

private void createSQLSchema(String fileName) throws Exception {
    org.hibernate.cfg.Configuration configuration = new Configuration();
    Properties properties = new Properties();
    properties.putAll(sessionFactoryBean.getJpaPropertyMap());
    configuration.setProperties(properties);
    configuration.setNamingStrategy(new GizmoNamingStrategy());

    System.out.println("Dialect: " + properties.getProperty("hibernate.dialect"));

    addAnnotatedClasses("sk.lazyman.gizmo.data", configuration);

    SchemaExport export = new SchemaExport(configuration);
    export.setOutputFile(fileName);/*from  ww  w.jav  a 2s  .c  o m*/
    export.setDelimiter(";");
    export.execute(true, false, false, true);
}

From source file:uk.co.modularaudio.util.hibernate.generator.GeneratorHelper.java

License:Open Source License

/**
 * Method to configure necessary hibernate properties and generate DDL for a supplied configuration
 * @param dialectName Which hibernate dialect should be used
 * @param destinationDirectory The output directory
 * @param outputFileName The output filename
 * @param configuration The hibernate configuration setup with the appropriate schema objects
 *//*from w  w w. j a  v  a 2 s.co  m*/
private void configureAndGenerate(final String dialectName, final String destinationDirectory,
        final String outputFileName, final Configuration configuration) {
    final Properties dialect = new Properties();
    dialect.setProperty("hibernate.dialect", dialectName);
    configuration.addProperties(dialect);

    final SchemaExport se = new SchemaExport(configuration);
    se.setOutputFile(destinationDirectory + outputFileName);
    se.setDelimiter(";\n");
    se.create(true, false);
}

From source file:util.HibernateDDLGenerator.java

private void execute(Dialect dialect, Class<?>... classes) {
    AnnotationConfiguration configuration = new AnnotationConfiguration();
    configuration.setProperty(Environment.DIALECT, dialect.getClassName());
    for (Class<?> entityClass : classes) {
        configuration.addAnnotatedClass(entityClass);
    }/* w ww .  j a  v a2s  .  c  o  m*/
    configuration.configure("hibernate.cfg.xml");
    SchemaExport schemaExport = new SchemaExport(configuration);
    schemaExport.setDelimiter(";");
    schemaExport.setOutputFile(
            String.format("%s_%s.%s ", new Object[] { "ddl", dialect.name().toLowerCase(), "sql" }));
    boolean consolePrint = true;
    boolean exportInDatabase = true;
    schemaExport.create(consolePrint, exportInDatabase);
}