Example usage for org.hibernate.cfg AvailableSettings PHYSICAL_NAMING_STRATEGY

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

Introduction

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

Prototype

String PHYSICAL_NAMING_STRATEGY

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

Click Source Link

Document

Used to specify the org.hibernate.boot.model.naming.PhysicalNamingStrategy class to use.

Usage

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

License:Apache License

@Test
public void noCustomNamingStrategy() {
    this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> {
        assertThat(hibernateProperties).doesNotContainKeys("hibernate.ejb.naming_strategy");
        assertThat(hibernateProperties).containsEntry(AvailableSettings.PHYSICAL_NAMING_STRATEGY,
                SpringPhysicalNamingStrategy.class.getName());
        assertThat(hibernateProperties).containsEntry(AvailableSettings.IMPLICIT_NAMING_STRATEGY,
                SpringImplicitNamingStrategy.class.getName());
    }));/*from w ww .  j a  v  a 2 s. com*/
}

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

License:Apache License

@Test
public void hibernate5CustomNamingStrategies() {
    this.contextRunner
            .withPropertyValues("spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit",
                    "spring.jpa.hibernate.naming.physical-strategy:com.example.Physical")
            .run(assertHibernateProperties((hibernateProperties) -> {
                assertThat(hibernateProperties).contains(
                        entry(AvailableSettings.IMPLICIT_NAMING_STRATEGY, "com.example.Implicit"),
                        entry(AvailableSettings.PHYSICAL_NAMING_STRATEGY, "com.example.Physical"));
                assertThat(hibernateProperties).doesNotContainKeys("hibernate.ejb.naming_strategy");
            }));//from  ww w.j  ava 2 s.  c  o m
}

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

License:Apache License

@Test
public void hibernate5CustomNamingStrategiesViaJpaProperties() {
    this.contextRunner
            .withPropertyValues("spring.jpa.properties.hibernate.implicit_naming_strategy:com.example.Implicit",
                    "spring.jpa.properties.hibernate.physical_naming_strategy:com.example.Physical")
            .run(assertHibernateProperties((hibernateProperties) -> {
                // You can override them as we don't provide any default
                assertThat(hibernateProperties).contains(
                        entry(AvailableSettings.IMPLICIT_NAMING_STRATEGY, "com.example.Implicit"),
                        entry(AvailableSettings.PHYSICAL_NAMING_STRATEGY, "com.example.Physical"));
                assertThat(hibernateProperties).doesNotContainKeys("hibernate.ejb.naming_strategy");
            }));/*from  www  .j  av a 2s  . c o  m*/
}

From source file:org.wallride.tools.Hbm2ddl.java

License:Apache License

public static void main(String[] args) throws Exception {
    String locationPattern = "classpath:/org/wallride/domain/*";

    final BootstrapServiceRegistry registry = new BootstrapServiceRegistryBuilder().build();
    final MetadataSources metadataSources = new MetadataSources(registry);
    final StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(registry);

    registryBuilder.applySetting(AvailableSettings.DIALECT,
            ExtendedMySQL5InnoDBDialect.class.getCanonicalName());
    registryBuilder.applySetting(AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, true);
    registryBuilder.applySetting(AvailableSettings.PHYSICAL_NAMING_STRATEGY,
            PhysicalNamingStrategySnakeCaseImpl.class);

    final PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
    final Resource[] resources = resourcePatternResolver.getResources(locationPattern);
    final SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    for (Resource resource : resources) {
        MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
        AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
        if (metadata.hasAnnotation(Entity.class.getName())) {
            metadataSources.addAnnotatedClass(Class.forName(metadata.getClassName()));
        }/*ww w .j  ava2  s . c om*/
    }

    final StandardServiceRegistryImpl registryImpl = (StandardServiceRegistryImpl) registryBuilder.build();
    final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder(registryImpl);

    new SchemaExport().setHaltOnError(true).setDelimiter(";").create(EnumSet.of(TargetType.STDOUT),
            metadataBuilder.build());
}