frsv9
frsv9

Reputation: 11

Disable mysql automatic table creation from hibernate

i'm creating a simple spring-boot application with mySql and Hibernate links. When i call some standard JpaRepository methods (for example findAll() ), Hibernate automatically creates a new table into my schema and consequently, my methods return empty list. I've tried to change my application.property, but the problem still remain.

application.properties:

> spring.datasource.url=jdbc:mysql://localhost:3306/carrello?&serverTimezone=UTC
> spring.datasource.username=root spring.datasource.password=root
> spring.jpa.show-sql=true hibernate.hbm2ddl.auto=none

Entity:

>     @Entity
>     @Table(name = "ARTICOLI", schema="carrello")
>     public class Articolo {
>       
>       @Id
>       @Column(name="ID_ARTICOLO")
>       private int idArticolo;
>       
>       @Column(name="NOME_ARTICOLO")
>       private String nomeArticolo;
>       
>       @Column(name="DESCRIZIONE_ARTICOLO")
>       private String descrizioneArticolo;
>       
>       @Column(name="CATEGORIA_ARTICOLO")
>       private String categoriaArticolo;
>       
>       @Column(name="PREZZO_ARTICOLO")
>       private int prezzoArticolo;
>     
>     getters /setters

SQL:

>       create table carrello.ARTICOLI (
>       ID_ARTICOLO INT,
>       NOME_ARTICOLO varchar(70),
>       CATEGORIA_ARTICOLO varchar(50),
>       DESCRIZIONE_ARTICOLO varchar (100),
>       PREZZO_ARTICOLO int,
>       primary key(ID_ARTICOLO)
>     );

How can i disable this automatic table creation?

Upvotes: 0

Views: 1833

Answers (1)

skryvets
skryvets

Reputation: 3039

Since you use Spring Boot, it abstracts the Hibernate part through Spring Data JPA. Therefore you can try spring.jpa.hibernate.ddl-auto=none to prevent "automatic table creation". Under the hood it would instruct hibernate to take a proper action.

Source

Upvotes: 1

Related Questions