0
I’d like Hibernate to not make any changes directly to the database, which means I’d like him to follow what’s in the database. Example : If in my entity I have the following situation
@ManyToOne
@JoinColumn(name="locacao_codcliente", foreignKey=@ForeignKey(name = "LO_CL_FK"))
private Cliente cliente;
@ManyToOne
@JoinColumn(name="locacao_codvendedor", foreignKey=@ForeignKey(name = "LO_VE_FK"))
private Vendedor vendedor;
Note that I would have two fields that are foreign key that will receive the names locao_codvendedor and locaca_codcliente.
I wish that if the DBA had not created these fields there in the database it would not create automatically. I’m starting now and prefer to follow the pattern that the fields are already created in the database.
The creation of my database is as below :
spring.datasource.url = jdbc:mysql://localhost:3306/sitiusdb?useTimezone=true&serverTimezone=UTC
spring.datasource.username = root
spring.datasource.password = root
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
It really worked. It doesn’t even create the table. I find it more comfortable to work like this than to let Hibernate dominate the database. I think it’s too risky and I’ve done some things wrong once.
– Josemar Sabino
I also prefer not to let Hibernate mess with the structure of the bank, but not to be managing the bank in hand use the liquibase, when you have a look time is an excellent tool to manage changes in the bank.
– rnd_rss
Good morning, create another question with this question, it is easier to help you and more organized
– rnd_rss