[jboss-jira] [JBoss JIRA] Commented: (HIBERNATE-73) @OneToOne with @PrimaryKeyJoinColumn does not work right
David Klotz (JIRA)
jira-events at lists.jboss.org
Mon May 5 10:23:07 EDT 2008
[ http://jira.jboss.com/jira/browse/HIBERNATE-73?page=comments#action_12411740 ]
David Klotz commented on HIBERNATE-73:
--------------------------------------
This behaviour is clearly NOT expected. The example given in this bug-report (classes Employee and EmployeeInfo "sharing" the same primary key) is taken DIRECTLY from the JPA JavaDoc, see example 2 at:
http://java.sun.com/javaee/5/docs/api/javax/persistence/OneToOne.html
So @OneToOne and @PrimaryKeyJoinColumn clearly do not work as described in the JPA documentation.
Regards,
David
> @OneToOne with @PrimaryKeyJoinColumn does not work right
> --------------------------------------------------------
>
> Key: HIBERNATE-73
> URL: http://jira.jboss.com/jira/browse/HIBERNATE-73
> Project: Hibernate
> Issue Type: Bug
> Environment: JBoss 4.2.1
> Reporter: Tim McCune
> Assigned To: Steve Ebersole
>
> Given the following code:
> @Entity
> public class Employee {
> @Id Integer id;
>
> @OneToOne @PrimaryKeyJoinColumn
> EmployeeInfo info;
> ...
> }
> @Entity
> public class EmployeeInfo {
> @Id Integer id;
> ...
> }
> Hibernate creates EMPLOYEE and EMPLOYEEINFO tables, but does not create a foreign key relationship from EMPLOYEEINFO to EMPLOYEE.
> Furthermore, Hibernate does not set the EmployeeInfo's id correctly when persisting it. The following code:
> EmployeeInfo info = new EmployeeInfo();
> employee.setInfo(info);
> does insert a new row into EMPLOYEEINFO, but it has an id of "1" when it should have an id that is the same as the corresponding Employee.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list