Hello,

We are running into issues with annotation based deletes in nested
relations. It displays a very random behavior. It does not delete all the
nested classes and delete fails. In the example below: if we have such a
relation the delete fails. It fails to delete either XYZ_WAY, XYZ_CON or
XYZ_POS randomly. Below is the code snippet. Many people ran into the same
issue. As a workaround, we ended up removing cascadetype.ALL and adding
cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE }. We
added DELETE ON CASCADE for the foreign keys in the DB, replying on database
to do the deletes. I want to know if this is a bug or just how we used it.
Any pointers are greatly appreciated.

Best,

Alice 

@Entity

@Table(name = "abc.xyz_map")

public class XyzMap implements DTOConverter<XyzMapDTO, XyzMap>, Serializable
{

@OneToMany(targetEntity = def.class, mappedBy="xyzMap", cascade =
CascadeType.ALL)

    private Set<Def> defs;

---------------------------------------------------------------------------
@Entity
@Table(name = "abc.def")
public class Def implements DTOConverter<DefDTO, def>, Serializable {

@OneToMany(mappedBy = "def", cascade = CascadeType.ALL)
private Set<Pqr> pqrs;
@ManyToOne(cascade = CASCADE.ALL)
@JoinColumn(name = "XYZ_ID")
private XyzMap xyzMap;
---------------------------------------------------------------------------
@Entity
@Table(name="abc.XYZ_COMPS")
@Inheritance(strategy=InheritanceType.JOINED)
public  class Pqr implements Serializable {

@ManyToOne
@JoinColumn(name="Def_ID")
private Def def;

---------------------------------------------------------------------------
@Entity
@Table(name = "abc.XYZ_POS")
@PrimaryKeyJoinColumn(name="XYZ_POS_ID",
referencedColumnName="XYZ_COMPS_ID")
public class Pos extends Pqr implements DTOConverter<PosDTO, Pos>,
Serializable {

@OneToOne(mappedBy = "pos", cascade = CascadeType.ALL)
private Mark mark;
---------------------------------------------------------------------------
@Entity
@Table(name = "abc.XYZ_CON")
@PrimaryKeyJoinColumn(name="XYZ_CON_ID",
referencedColumnName="XYZ_COMPS_ID")
public class Con extends MapElement implements DTOConverter<ConDTO, Con>,
Serializable {

---------------------------------------------------------------------------
@Entity
@Table(name = "abc.XYZ_WAY")
@PrimaryKeyJoinColumn(name="XYZ_WAY_ID",
referencedColumnName="XYZ_COMPS_ID")
public class Way extends pqr implements DTOConverter<WayDTO, Way>,
Serializable {


---------------------------------------------------------------------------
@Entity
@Table(name="abc.MARK")
public class Mark implements DTOConverter<MarkDTO, Mark>, Serializable {

@OneToOne  
@JoinColumn(name="XYZ_POS_ID")
private XYZ_POS pos;




--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Possible-bug-Issue-with-annotation-based-cascade-delete-in-nested-relation-openJPA-2-2-2-with-Oracleg-tp7586036.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to