对于具有FK约束的elementcollection,JpaRepository deleteall()失败

时间:2016-04-28 18:07:34

标签: java hibernate spring-data spring-data-jpa cascading-deletes

我正在为我的ORM使用JpaRepository。

@Entity
@DiscriminatorValue(value = "L")
@Table(name = "LARGEPROJECT")
public class LargeProject extends Project {

LargeProject() { // jpa only
}

public String description;

@ElementCollection
public Map<String, String> params = new HashMap<>();

@ElementCollection
public Map<String, String> anotherSet = new HashMap<>();

}

我正在尝试使用以下api进行批量删除: this.largeProjectRepository.deleteAllInBatch();

public interface LargeProjectRepository extends JpaRepository<LargeProject, Long> {
}

我得到了一个例外:

  

org.springframework.dao.DataIntegrityViolationException:无法执行语句; SQL [不适用];约束[&#34; FK_K8XLJ5LKC9IK2E39EK06MWUM7:PUBLIC.LARGE_PROJECT_PARAMS FOREIGN KEY(LARGE_PROJECT_PROJECT_ID)REFERENCES PUBLIC.LARGEPROJECT(PROJECT_ID)(1)&#34 ;; SQL语句:   从bigproject中删除(project_id)IN(从HT_largeproject中选择project_id)[23503-176]];

我研究了一下,发现了以下内容: How to do bulk delete in JPA when using Element Collections?

How can I cascade delete a collection which is part of a jpa entity?

我想知道JPA是否支持基于API的删除,如@ElementCollection的这些帖子中所述?如果不是最好的方法是什么?

0 个答案:

没有答案
相关问题