Make JPA name the tables in capital letters

1

I am using JPA with spring boot, hibernate and sql server, it works fine, but I would like the names of the tables and their fields in the database to write them in lowercase, how can I make it uppercase?

This is how I have my properties:

    logging.level.org.hibernate.SQL=DEBUG
    logging.level.org.hibernate.type=TRACE
    spring.datasource.url=jdbc:sqlserver://blablabla;
    spring.datasource.username=usuario
    spring.datasource.password=password
    spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
    spring.jpa.show-sql=true
    spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
    spring.jpa.hibernate.ddl-auto=create-drop
    
asked by gibran alexis moreno zuñiga 23.08.2018 в 19:29
source

2 answers

1

Example:

Class User:

@Entity
@Table(name="usr")
public class User {

    @Id
    @GeneratedValue
    @Column(name="id")
    private Long id;
    @Column(name="username")
    private String username;

    public User(){
        //Empty
    }

    //Getters & setters
}

With the @Table (name="usr") you indicate in name the name you want for the table. And with @Column (name="username") you indicate in name the name you want for the attribute or field.

    
answered by 23.08.2018 / 19:35
source
2

First remember that the entity (Object that represents a table in the database) you can make the changes you think necessary and with respect to your question you must take into account the annotations used to configure your entity object. Then a table from a database can be mapped with the annotations.

Cited by Java EE 7

@Entity
@Table(name="CUST", schema="RECORDS")
public class Customer { ... } 

Quoted by java EE 5

Example 1:
@Column(name="DESC", nullable=false, length=512)
public String getDescription() { return description; }

Example 2:
@Column(name="DESC",columnDefinition="CLOB NOT NULL",table="EMP_DETAIL")
@Lob
public String getDescription() { return description; }

Example 3:
@Column(name="ORDER_COST", updatable=false, precision=12, scale=2)
public BigDecimal getCost() { return cost; }

In conclusion in the attributes of the annotations the data is described as you left it in the database and the properties of the class can assign the name you think is necessary.

    
answered by 23.08.2018 в 20:46