1
I’m using IDE Intellij. I have the following model:
@Entity(name = "carro")
@Data
public class Carro {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String nome;
private String tipo;
private String descricao;
private String urlFoto;
private String urlVideo;
private String latitude;
private String longitude;
}
I noticed that JPA does not recognize in the standard form, for example:
public class Carro {
When adding the annotation @Entity
I’d like him to understand that class Carro
would be the table carro
in the database
To function properly I had to add this way on @Entity
@Entity(name = "carro")
Just like with the columns urlFoto
for example, when performing the query Hibernate gave error saying that the field urlFoto
does not exist, that is, he did not convert to url_foto
database. But when using H2, it ran normally, ie, recognized and made the conversion to the database format
When mysql
I’ll always have to use the note @Column?
? or
I have to make some additional configuration?
[EDIT]
In my file application.properties
is like this:
# MySQL
spring.datasource.url=jdbc:mysql://localhost:3307/carros?useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=123
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
#SQL.
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.datasource.initialization-mode=always
spring.jpa.hibernate.ddl-auto=none
# logging
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=debug
That’s right... when I use the H2 database, it alone does this conversion for me
– adventistaam