Hibernate, force table name in low case

3

I am using Hibernate 5.2.1.Finally as implementation to handle MySQL database. The problem is that tables are being generated with the first letter in high box, I would force to be all in the box via file of persistence. Currently my file is this:

<persistence-unit name="testeUP" transaction-type="RESOURCE_LOCAL">
    <properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://192.168.56.100:3306/locadora"/>
        <property name="javax.persistence.jdbc.user" value="root"/>
        <property name="javax.persistence.jdbc.password" value="1QAZxsw2"/>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>

        <property name="hibernate.hbm2ddl.auto" value="update"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.diaLect" value="org.hibernate.diaLect.MySQLDiaLect"/>
    </properties>
</persistence-unit>

Is it possible to force this behavior? If so, how?

    
asked by anonymous 16.08.2016 / 17:58

1 answer

5

In your entities, use the @Table annotation. Here's an example:

@Entity
@Table(name = "tabela_caixa_baixa")
public class MinhaTabela implements Serializable {
    // ...
}

When the @Table annotation is missing, it is understood that the table name will default to default ). The default is to let the persistence provider (in your case, Hibernate) give the name it finds the best.

Because what you want is behavior other than the default (do not let Hibernate name it any way you want it), then you specify the desired behavior by using the annotation.

    
16.08.2016 / 18:15