I am using a JpaRepository for my ORM.
@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<>();
}
I am trying to do a batch delete using the following api:
this.largeProjectRepository.deleteAllInBatch();
public interface LargeProjectRepository extends JpaRepository<LargeProject, Long> {
}
I am getting an exception of the form:
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint ["FK_K8XLJ5LKC9IK2E39EK06MWUM7: PUBLIC.LARGE_PROJECT_PARAMS FOREIGN KEY(LARGE_PROJECT_PROJECT_ID) REFERENCES PUBLIC.LARGEPROJECT(PROJECT_ID) (1)"; SQL statement: delete from largeproject where (project_id) IN (select project_id from HT_largeproject) [23503-176]];
I have researched a bit and found the following: 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?
I am wondering if API based delete is not supported by JPA as stated in these posts for @ElementCollection? If not what is the best way to do this?