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

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

Introduction

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

Prototype

public SchemaExport setManageNamespaces(boolean manageNamespaces) 

Source Link

Usage

From source file:com.imos.sample.service.HibernateService.java

/**
 * Hibernate configuration.// w w w . j a v  a 2s. c  o  m
 *
 * @throws RepositoryException
 */
public void config() throws RepositoryException {
    try {
        StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();
        if (filePath == null || filePath.isEmpty()) {
            registryBuilder = registryBuilder.configure();
        } else {
            registryBuilder = registryBuilder.configure(filePath);
        }
        registry = registryBuilder.build();

        MetadataSources metaData = new MetadataSources(registry);
        sessionFactory = metaData.buildMetadata().buildSessionFactory();
        session = sessionFactory.openSession();

        SchemaExport schemaExport = new SchemaExport();
        schemaExport.setDelimiter(";");
        schemaExport.setFormat(true);
        schemaExport.setManageNamespaces(true);
        schemaExport.setOutputFile("./ddl_skilldb.sql");
        schemaExport.execute(EnumSet.of(TargetType.SCRIPT, TargetType.DATABASE, TargetType.STDOUT),
                SchemaExport.Action.CREATE, metaData.buildMetadata(registry), registry);

        log.info("Configuration succeed");
    } catch (HibernateException e) {
        StandardServiceRegistryBuilder.destroy(registry);
        log.error("Configuration failed : {}", e);
    }
}