Hibernate约束已经存在

时间:2018-03-18 22:23:32

标签: oracle hibernate spring-boot

我需要帮助来解决这个hibernate错误所以每次我在我的实体中放置一个地图注释时我都会遇到这个错误,它会尝试重新创建一些现有的约束。

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ID_PAYS")
public PrmPays getPrmPays() {
return this.prmPays;
}
public void setPrmPays(PrmPays prmPays) {
    this.prmPays = prmPays;
}

这就是错误!

  alter table ref_entite 
   add constraint FK4xutpn4uffubj8bfw92mmk30f 
   foreign key (id_pays) 
   references prm_pays     
Caused by: java.sql.SQLSyntaxErrorException: ORA-02275: such a referential constraint already exists in the table

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:999) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1890) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1855) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:304) ~[ojdbc6-11.2.0.jar:11.2.0.2.0]
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) ~[HikariCP-2.7.8.jar:na]
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-2.7.8.jar:na]        

这是我在spring boot中的application.properties中的配置

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver  
hibernate.default_schema=db_default_schema_name
spring.jpa.hibernate.ddl-auto=update  
security.basic.enabled=true  


# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true 
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

0 个答案:

没有答案