Example usage for org.hibernate.cfg AvailableSettings HBM2DDL_AUTO

List of usage examples for org.hibernate.cfg AvailableSettings HBM2DDL_AUTO

Introduction

In this page you can find the example usage for org.hibernate.cfg AvailableSettings HBM2DDL_AUTO.

Prototype

String HBM2DDL_AUTO

To view the source code for org.hibernate.cfg AvailableSettings HBM2DDL_AUTO.

Click Source Link

Document

Setting to perform SchemaManagementTool actions automatically as part of the SessionFactory lifecycle.

Usage

From source file:nl.rivm.cib.epidemes.geodb.jdbc.GeoJPAConfig.java

License:Apache License

@Key(AvailableSettings.HBM2DDL_AUTO)
@DefaultValue("validate")
HibernateSchemaPolicy hibernateSchemaPolicy();

From source file:nz.geek.caffe.hdb.hibernate.demo.TestEmployee.java

License:Apache License

/**
 *///ww  w.j  ava2s . c  o m
@Before
public void setUp() {
    final DataSource ds = new DriverManagerDataSource(
            System.getProperty("jdbc.url", "jdbc:sap://localhost:30115"),
            System.getProperty("jdbc.user", "hibernate"), System.getProperty("jdbc.password", "hibernate"));

    final LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(ds);
    builder.setProperty(AvailableSettings.DIALECT,
            System.getProperty("hibernate.dialect", HANAColumnStoreDialect.class.getName()));
    builder.setProperty(AvailableSettings.HBM2DDL_AUTO, "create-drop");
    builder.setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");

    builder.addAnnotatedClass(Employee.class);

    this.sessionFactory = builder.buildSessionFactory();

    final HibernateTemplate ht = new HibernateTemplate();
    ht.setSessionFactory(this.sessionFactory);

    ht.afterPropertiesSet();

    this.template = ht;

    final HibernateTransactionManager txnMgr = new HibernateTransactionManager();
    txnMgr.setDataSource(ds);
    txnMgr.setSessionFactory(this.sessionFactory);
    txnMgr.afterPropertiesSet();

    this.transactionTemplate = new TransactionTemplate(txnMgr);
}

From source file:org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.java

License:Apache License

private Map<String, Object> getAdditionalProperties(Map<String, String> existing, HibernateSettings settings) {
    Map<String, Object> result = new HashMap<>(existing);
    applyNewIdGeneratorMappings(result);
    applyScanner(result);/*from www.  j  a v a 2  s  .  c  om*/
    getNaming().applyNamingStrategies(result);
    String ddlAuto = determineDdlAuto(existing, settings::getDdlAuto);
    if (StringUtils.hasText(ddlAuto) && !"none".equals(ddlAuto)) {
        result.put(AvailableSettings.HBM2DDL_AUTO, ddlAuto);
    } else {
        result.remove(AvailableSettings.HBM2DDL_AUTO);
    }
    Collection<HibernatePropertiesCustomizer> customizers = settings.getHibernatePropertiesCustomizers();
    if (!ObjectUtils.isEmpty(customizers)) {
        customizers.forEach((customizer) -> customizer.customize(result));
    }
    return result;
}

From source file:org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.java

License:Apache License

private String determineDdlAuto(Map<String, String> existing, Supplier<String> defaultDdlAuto) {
    String ddlAuto = existing.get(AvailableSettings.HBM2DDL_AUTO);
    if (ddlAuto != null) {
        return ddlAuto;
    }//w w w . j ava2 s. co m
    return (this.ddlAuto != null) ? this.ddlAuto : defaultDdlAuto.get();
}

From source file:org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesTests.java

License:Apache License

private ContextConsumer<AssertableApplicationContext> assertDefaultDdlAutoNotInvoked(String expectedDdlAuto) {
    return assertHibernateProperties((hibernateProperties) -> {
        assertThat(hibernateProperties).containsEntry(AvailableSettings.HBM2DDL_AUTO, expectedDdlAuto);
        verify(this.ddlAutoSupplier, never()).get();
    });//from  w w w .j  a  v a  2  s .  co m
}