[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-4293) OneToOne Unidirectional Support

Gail Badner (JIRA) noreply at atlassian.com
Wed Aug 24 13:50:07 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner resolved HHH-4293.
------------------------------

    Resolution: Rejected
      Assignee: Gail Badner

Please use the user forum for help.

> OneToOne Unidirectional Support
> -------------------------------
>
>                 Key: HHH-4293
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4293
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: annotations
>         Environment: Oracle 10g, Java 1.5
>            Reporter: Rachit
>            Assignee: Gail Badner
>            Priority: Blocker
>
> I tried hard for unidirectional OneToOne mapping as below:
> @Entity
> @Table(name = "PARTY")
> public class Party{
>    private Person person;
>    private String key;
>    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL,)
>     @PrimaryKeyJoinColumn(name = "PARTY_ID", referencedColumnName = "PERSON_PARTY_ID")
>     public Person getPerson() {
>         return person;
>     }
>    
>     public void setPerson(Person person) {
>         this.person = person;
>     }
>     @Id
>     @GeneratedValue(generator = "system-uuid")
>     @GenericGenerator(name = "system-uuid", strategy = "uuid")
>     @Column(name = "PARTY_ID", nullable = false)
>     public String getKey() {
>         return key;
>     }
>    
>     private void setKey(String key) {
>         this.key = key;
>     }
> }
> and it is one-to-one mapped to Person as:
> @Entity(name = "Person")
> @Table(name = "PERSON")
> public class Person {
>    private String key;
>      @Id
>      @Column(name = "PERSON_PARTY_ID")
>     public String getKey() {
>         return key;
>     }
>    
>     public void setKey(String key) {
>         this.key = key;
>     }
>    
> }
> Now in Person, I deliberately dont have sysUUID as generated as then it generates a unique value for person and the association gets lost. With this mapping hibernate throws the following exception :
> Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): Person.
> I read and saw constrained="true" being used in mapping files, which I couldnt use as there is no attribute like it in OneToOne annotation.
> Please help me out on this

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list