geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shawn Jiang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GERONIMO-5714) JPA-cannot insert record relates with Foreign key writes with "mappedBy".
Date Mon, 27 Jun 2011 13:37:47 GMT

    [ https://issues.apache.org/jira/browse/GERONIMO-5714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13055543#comment-13055543
] 

Shawn Jiang commented on GERONIMO-5714:
---------------------------------------

If you could provide an app to recreate the problem, it would be helpful to debug this issue.


> 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
>            Assignee: Shawn Jiang
>            Priority: Minor
>             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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message