You might want to report this problem to OpenJPA community. On Wed, Nov 24, 2010 at 5:42 PM, LiWenQin (JIRA) <[email protected]> wrote: > JPA-cannot insert record relates with Foreign key writes with "mappedBy". > ------------------------------------------------------------------------- > > Key: GERONIMO-5714 > URL: https://issues.apache.org/jira/browse/GERONIMO-5714 > Project: Geronimo > Issue Type: Bug > Security Level: public (Regular issues) > Components: persistence > Affects Versions: 3.0 > Reporter: LiWenQin > Fix For: 3.0 > > > I find foreign key relationship cannot resolved used the code like below: > > Student.java//entity > @Entity > @Table(name="Student") > public class Student implements Serializable { > ... > @OneToMany(mappedBy="owner") > �...@ordercolumn(name="indexno") > private List<Course> courses; //student can choose more than one courses, > this is a one-to many mapping, and has foreign key > ... > } > =============================================================== > > However, foreign key can be created in the style below: > > Student.java > @Entity > @Table(name="Student") > public class Student implements Serializable { > ... > �...@onetomany(cascade={CascadeType.MERGE, CascadeType.PERSIST, > CascadeType.REFRESH},fetch=FetchType.EAGER ) > �...@jointable(name="Student_Course", > joinColumns={ > �...@joincolumn(name="studentId", > referencedColumnName="id") > }, > inverseJoinColumns={ > �...@joincolumn(name="courseId", > referencedColumnName="cid") > } > ) > private List<Course> courses=null; > ... > } > > This problem also exists in JPA1.0 with Geronimo server. > > -- > This message is automatically generated by JIRA. > - > You can reply to this email to add a comment to the issue online. > >
-- Shawn
