Entity DSSchema:
@Entity
@Table(name = "DS_SCHEMA", schema = "DSUSER")
public class DSSchema {
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid2")
@GeneratedValue(generator = "idGenerator")
private String id;
}
Entity 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;
}
Entity 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;
}
Repository DSColumnRelationRepository:
public interface DSColumnRelationRepository extends JpaRepository<DSColumnRelation, String> {
@Modifying
@Query("delete from DSColumnRelation c where c.tableRelation.schema.id = ?1")
void deleteBySchemaId(String schemaId);
}
Excute the method 'deleteBySchemaId', and check the generated sql:
delete
from
DSUSER.DS_COLUMN_RELATION cross
join
DSUSER.DS_TABLE_RELATION dstablerel1_
where
SCHEMA_ID=?
this sql is wrong sql, please tell me why using spring data jpa cause error,thanks.