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.

Reply via email to