[jboss-jira] [JBoss JIRA] Commented: (HIBERNATE-73) @OneToOne with @PrimaryKeyJoinColumn does not work right
jian wang (JIRA)
jira-events at lists.jboss.org
Sun Dec 2 00:08:51 EST 2007
[ http://jira.jboss.com/jira/browse/HIBERNATE-73?page=comments#action_12390153 ]
jian wang commented on HIBERNATE-73:
------------------------------------
I have the same problem.
At last, I used foreign generator to solve it.
code:
@GenericGenerator(name = "generator", strategy = "foreign", parameters = { @Parameter(name = "property", value = "employee") })
@GeneratedValue(generator = "generator")
> @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