openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pawel Veselov <>
Subject Auto-deleting referenced entities.
Date Wed, 15 Jul 2015 18:34:18 GMT

Is it possible in JPA to reference entities from another, and have them
automatically delete if the reference is just removed?

I.e. if the entity is:

public class E_Campaign implements Accounted {

    private long id;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "campaign")
    private Collection<E_VehicleAssociation> vehicles;


And the dependent entity is:

public class E_VehicleAssociation {

    private long id;

    private E_Campaign campaign;


Is it possible to do something like this, and have that delete the
dependent entity:


I.e., I'm removing the reference to an element of campaign.vehicles() would
remove that entity from the VehicleAssociation table? More specifically,
I'm interested in auto-deleting all entities that are references by a
particular campaign, and want to avoid iterating and deleting.

Thank you!

P.S. Any idea when JPA2.1 will be implemented by OpenJPA? :)

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message