[jboss-jira] [JBoss JIRA] Created: (HIBERNATE-73) @OneToOne with @PrimaryKeyJoinColumn does not work right

Tim McCune (JIRA) jira-events at lists.jboss.org
Mon Oct 8 04:03:03 EDT 2007


@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