Table names in Hibernate are created with lowercase letters

1

I'm trying to transform the following Entity into a table in Postgre using Hibernate

@Entity
@Table(name="Usuarios")
public class Usuario implements Serializable { ... }

The problem is that when the table is created, its name is created with all the characters in lower case.

I'm using a helper class to configure:

        Properties props = new Properties();

        props.put("hibernate.temp.use_jdbc_metadata_defaults", "false");
        props.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
        props.put("hibernate.connection.driver_class", "org.postgresql.Driver");
        props.put("hibernate.provider_class", "org.hibernate.connection.C3P0ConnectionProvider");
        props.put("hibernate.transaction.factory_class", "org.hibernate.transaction.JDBCTransactionFactory");
        props.put("hibernate.current_session_context_class", "thread");
        props.put("hibernate.hbm2ddl.auto", "create");
        props.put("hibernate.show_sql", "true");
        props.put("spring.jpa.hibernate.naming.physical-strategy", "org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl");

        URI dbUri = new URI("postgres://*user*:*senha*@localhost:5432/*bd*");

        String username = dbUri.getUserInfo().split(":")[0];
        String password = dbUri.getUserInfo().split(":")[1];
        String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath();

        props.put("hibernate.connection.url", dbUrl);
        props.put("hibernate.connection.username", username);
        props.put("hibernate.connection.password", password);

        props.put("c3p0.min_size", 5);
        props.put("c3p0.max_size", 15);
        props.put("c3p0.timeout", 300);
        props.put("c3p0.acquire_increment", 1);
        props.put("c3p0.max_statements", 50);
        props.put("c3p0.idle_test_period", 3000);

        cfg.addProperties(props);

        sessionFactory = cfg.buildSessionFactory();
    
asked by anonymous 06.06.2017 / 15:07

1 answer

0

I believe that this "problem" is not with Hibernate, but with PostgreSQL. By default PostgreSQL converts everything to lowercase internally.

You can see more here: link

You can even create tables in PostgreSQL with a capital, but you have to put quotation marks around them:

createdb "Usuarios"
    
07.06.2017 / 01:06