禁用创建外键sql

This commit is contained in:
2023-08-28 12:10:15 +08:00
parent 858d0208e9
commit ab1461e0ea
3 changed files with 16 additions and 3 deletions

View File

@@ -12,4 +12,15 @@ public class MyPostgreSQLDialect extends PostgreSQLDialect {
}
return super.columnType(sqlTypeCode);
}
@Override
public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey) {
return " DROP CONSTRAINT IF EXISTS notexist ";
}
@Override
public String getAddForeignKeyConstraintString(String constraintName, String foreignKeyDefinition) {
return " DROP CONSTRAINT IF EXISTS notexist ";
}
}

View File

@@ -1,8 +1,8 @@
package cn.lihongjie.coal.entity;
import cn.lihongjie.coal.entity.base.CommonEntity;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import lombok.Data;
import org.hibernate.annotations.Comment;
@@ -15,7 +15,9 @@ import java.util.List;
public class PermissionEntity extends CommonEntity {
@ManyToMany(mappedBy = "permissions")
@ManyToMany()
@JoinTable(foreignKey = @jakarta.persistence.ForeignKey(name = "none" , value = jakarta.persistence.ConstraintMode.NO_CONSTRAINT),
inverseForeignKey = @jakarta.persistence.ForeignKey(name = "none" , value = jakarta.persistence.ConstraintMode.NO_CONSTRAINT))
private List<ResourceEntity> resources;

View File

@@ -17,7 +17,7 @@ import java.util.List;
@Slf4j
public class ResourceEntity extends CommonEntity {
@ManyToMany
@ManyToMany(mappedBy = "resources")
private List<PermissionEntity> permissions;