I encountered this issue as well, however, with the JPA / Hibernate 3.2.4 Core annotations:
The following code allows two tables to share the same primary key and still identify a parent-child relationship. The child entity also uses the primary key as a foreign key to the parent entity.
The code in the child entity references the parent entity (CompanyBean) and has a reference to it:
Code:
@OneToOne(optional=false, fetch=FetchType.LAZY)
@PrimaryKeyJoinColumn(name="invlvd_co_serl")
private CompanyBean companyBean;
/** represents the invlvdCoSerl */
@Id
@GeneratedValue(generator="foreign")
@GenericGenerator(name="foreign", strategy="foreign", parameters={
@Parameter(name="property", value="company")}
)
@Column (name="invlvd_co_serl", length=32)
private String invlvdCoSerl;
Unfortunately, the code in the annotations causes the "org.hibernate.HibernateException: Unable to resolve property: company". The @Parameter(...) annotation contains the problem: it is supposed to refer to the field in the child class whose type is the owner of the primary key, in this case, the CompanyBean. The error is the value attribute: changing company to companyBean (the correct name of the field) solves this problem.
Lesson we learned: be cautious with rename refactorings to include textual occurrences.
dan wilkin