You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Alice <as...@yahoo.com> on 2014/02/28 01:01:58 UTC

Possible bug: Issue with annotation based /cascade delete in nested relation - openJPA 2.2.2 with Oracle 11g

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.

Re: Possible bug: Issue with annotation based /cascade delete in nested relation - openJPA 2.2.2 with Oracle 11g

Posted by Alice <as...@yahoo.com>.
Hello,

I see that a bug was opened on  cascade delete with foreign key
<https://issues.apache.org/jira/browse/OPENJPA-39>   and it has been marked
as 'Wont Fix' with 'minor' priority. I believe this is a common use case.
Are there any plans to provide a fix for this?

best,

Alice



--
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-tp7586036p7586039.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.