Table names in Hibernate are created with lower case letters

Asked

Viewed 171 times

1

I am trying to turn 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 lowercase characters.

I am using a class as helper 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();
  • This may help you: https://stackoverflow.com/questions/8605566/hibernate-ignores-tablename-for-extended-classes-created-tablenames

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.