KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am having trouble working out how to do a bulk delete of a Person object using JPA, when the Person objects contain data stored using an @ElementCollection . Any ideas on how to do this would be much appreciated. @Entity @Table(name="at_person") public class Person implements Comparable<Person> { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") private long id = 0; @Column(name="name", nullable = true, length = 128) private String name = ""; @ElementCollection @Column(name = "email") @CollectionTable(name = "person_email", joinColumns = @JoinColumn(name = "person_id")) private Set<String> email = new HashSet<String>(); } What I am doing at the moment is this, and it fails with a foreign key constraint error: Query query=em.createQuery("DELETE FROM Person"); Caused by: java.sql.SQLException: integrity constraint violation: foreign key no action; FKCEC6E942485388AB table: PERSON_EMAIL If it can be a pure JPA annotation rather than a Hibernate annotation that would be a bonus!
Tags (comma-separated)
Save Edits
Cancel