Je sais que truncate
n'est pas supporté donc je fais un Delete from table
- cela fonctionne plutôt bien mais les tables de jointure ne sont pas nettoyées de cette façon. Exemple:JPA tables vides et tables jointes
Delete from Product;
Delete from Service;
à la fois vide, le tableau service_product
est toujours rempli. Est-il possible de nettoyer mes tables de jointure sans sql brut?
exemple entité
public class Service implements Serializable {
private static final long serialVersionUID = 4520872456865907866L;
// seam-gen attributes (you should probably edit these)
@EmbeddedId
private ServiceId id;
@Length(max = 255)
private String servicename;
@Column(columnDefinition = "text")
private String highlightsText;
@Column(columnDefinition = "text")
private String detailsText;
@Column(columnDefinition = "text")
private String productText;
@Column(columnDefinition = "text")
private String dataText;
@ManyToMany(mappedBy = "services")
private Set<Machine> machines;
@OneToMany(targetEntity = ServiceDownload.class, cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
private List<ServiceDownload> serviceDownloads;
@OneToMany(targetEntity = ProductSpecial.class, cascade = { CascadeType.ALL })
private List<ProductSpecial> productSpecials;
@OneToOne(cascade = { CascadeType.ALL })
private ServicePicture servicePicture;
...
}
duplication possible de [Comment supprimer par lots en utilisant bulkUpdate] (http://stackoverflow.com/questions/735201/how-to-batch-delete-using-bulkupdate) –