]
Sergey Klimenko commented on ANN-814:
-------------------------------------
Any resolutions?
OneToOne Unidirectional Support
-------------------------------
Key: ANN-814
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-814
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment: Oracle 10g, Java 1.5
Reporter: Rachit
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.
-
If you think it was sent incorrectly contact one of the administrators: