我尝试使用hibernate和jpa在PostgreSQL中生成表但是这不起作用,控制台中没有错误。
spring.datasource.platform=org.hibernate.dialect.postgres
spring.datasource.url=jdbc:postgresql://localhost:5433/pfeDb
spring.datasource.username=postgres
spring.datasource.password=Nstg_Correlation
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
这就是实体
@Entity
@Getter @Setter @NoArgsConstructor @AllArgsConstructor
public class Catalogue implements Serializable{
@Id
private Long id_catalogue;
private String nom_catalogue;
private String description;
private String sujet_catalogue;
private boolean nouveau_catalogue;
private boolean edition_en_cours;
private String commentaire_catalogue;
}
这是主要的课程:
package pfe.app.PFE_DelphiToJav;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;
@SpringBootApplication
@Component
public class PfeDelphiToJavApplicationTests {
public static void main(String[] args) {
SpringApplication.run(PfeDelphiToJavApplication.class, args);
}
}
尝试将@Table
注释添加到您的实体。
@Entity
@Table
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Catalogue implements Serializable{
@Id
private Long idCatalogue;
private String nomCatalogue;
private String description;
private String sujetCatalogue;
private boolean nouveauCatalogue;
private boolean editionEnCours;
private String commentaireCatalogue;
}
对于java字段,变量等,请使用驼峰案例代替蛇案例。