Home > Mobile >  How to create table in database for entity, using Spring JPA and Maven?
How to create table in database for entity, using Spring JPA and Maven?

Time:03-14

How to generate table in the Postgres database for the entity below? I'm using maven build.

Entity:

@Entity
@Table(name = "EMPLOYEE")
public class Employee {
   @Id @GeneratedValue
   @Column(name = "id")
   private int id;
}    

properties:

spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory         
spring.datasource.url=jdbc:postgresql://localhost:5433/con_db        
spring.datasource.username=postgres
spring.datasource.password=root        
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.default_schema=as2
spring.jpa.hibernate.naming.physical-strategy=com.ds.entity.strategy.EntityNamingStrategy
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true                
spring.jpa.show-sql=true        
spring.h2.console.enabled=true          
logging.level.org.hibernate.SQL=DEBUG  
logging.level.org.hibernate.type=TRACE

CodePudding user response:

Try to use hibernate default_schema to public instead of as2 like this: spring.jpa.properties.hibernate.default_schema=public then run your project.

CodePudding user response:

you have to run the spring boot app to build your database structure in the postgres database, there is no relation of maven with that. Thanks @Spartan for your help here.

  • Related