[ 
https://issues.apache.org/jira/browse/OPENJPA-2604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Zowalla resolved OPENJPA-2604.
--------------------------------------
    Resolution: Won't Fix

Closing as obsolete during backlog cleanup: This is a usage question on 1.1.0, 
and the posted Parent mapping has @JoinColumn(name="O_ID", insertable=false, 
updatable=false) on the grandparent FK, which is a user mapping error rather 
than an OpenJPA defect. Please reopen if this still happens with OpenJPA 4.x.

> How to persist multi level associations
> ---------------------------------------
>
>                 Key: OPENJPA-2604
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2604
>             Project: OpenJPA
>          Issue Type: Question
>    Affects Versions: 1.1.0
>            Reporter: Nimisha Gupta
>            Priority: Major
>
> I am trying to persist a three level association 
> (i.e.Grandparent->Parents->Children)
> A grandparent can have multiple parents and each parent can have multiple 
> children.
> I am trying to leverage the CASCADE option but am failing to do so.
> Though I am able to persist in a two level association (i.e. Parent-> 
> Children).
> Could you please guide me as to what am I doing wrong in my entities?
> GrandParent.java
> --------------------------
> @Column(name="O_ID")
> private int oID;
> @OneToMany(mappedBy = "grandparent", cascade = CascadeType.ALL, fetch = 
> FetchType.EAGER, targetEntity = Parent.class)
>       private Set<Parent> parents;
> Parent.java
> -------------
>       @ManyToOne
>       @JoinColumn(name = "O_ID", insertable = false, updatable = false)
>       private Grandparent grandparent;
>       @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy 
> = "parent", targetEntity = Child.class)
>       private Set<Child> children;
> Child.java
> -------------
> @ManyToOne
>       @JoinColumns({ @JoinColumn(name = "O_ID", referencedColumnName = 
> "O_ID", insertable = false, updatable = false),
>                       @JoinColumn(name = "PRNT_ID", referencedColumnName = 
> "PRNT_ID", insertable = false, updatable = false) })
>       private Parent parent;
> Grandparent table-> PK- {O_ID}
> Parent table-> PK-{O_ID, PRNT_ID}
> Child table-> PK-{O_ID, PRNT_ID, CHILD_ID}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to