实体DSSchema:
@Entity
@Table(name = "DS_SCHEMA", schema = "DSUSER")
public class DSSchema {
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid2")
@GeneratedValue(generator = "idGenerator")
private String id;
}
实体DSTableRelation:
@Entity
@Table(name = "DS_TABLE_RELATION", schema = "DSUSER")
public class DSTableRelation {
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid2")
@GeneratedValue(generator = "idGenerator")
private String id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "SCHEMA_ID", nullable = false)
private DSSchema schema;
}
实体DSColumnRelation:
@Entity
@Table(name = "DS_COLUMN_RELATION", schema = "DSUSER")
public class DSColumnRelation {
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid2")
@GeneratedValue(generator = "idGenerator")
private String id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TABLE_RELATION_ID", nullable = false)
private DSTableRelation tableRelation;
}
存储库DSColumnRelationRepository:
public interface DSColumnRelationRepository extends JpaRepository<DSColumnRelation, String> {
@Modifying
@Query("delete from DSColumnRelation c where c.tableRelation.schema.id = ?1")
void deleteBySchemaId(String schemaId);
}
执行方法'deleteBySchemaId',并检查生成的sql:
delete
from
DSUSER.DS_COLUMN_RELATION cross
join
DSUSER.DS_TABLE_RELATION dstablerel1_
where
SCHEMA_ID=?
这个sql是错误的sql,请告诉我为什么使用spring数据jpa导致错误,谢谢。