|
Not sure of the exact relationship yet, but this may be related to a change I made to org.hibernate.metamodel.spi.binding.EntityIdentifier.SimpleAttributeIdentifierBindingImpl to accept any singular attribute. Before it would not accept to-one attributes. Consider this mapping (from testsuite):
@Entity
public class MedicalHistory implements Serializable {
@Id
@JoinColumn(name = "FK")
@OneToOne
Person patient;
...
}
@Entity
public class Person implements Serializable {
@Id
String ssn;
...
}
Note sure what Binder was expecting here before I started my "annotation source" surgery. But atm what I build here in the "annotation source" is such that:
-
Person has a simple identifier of StringType (ssn)
-
MedicalHistory has a simple identifier of "association type" (person)
The changes to get Binder to understand this were not major. Mainly changing a few references from being typed as SingularNonAssociationAttributeBinding to SingularAttributeBinding, and then a minor change in determining where the identifier of MedicalHistory depends on another hierarchy. It all binds ok. Where it gets into trouble is in trying to load at runtime via a call like:
session.load( MedicalHistory.class, "111-11-1111" );
Aka, trying to load by the simple derived id value (Person's ssn). I remember having to specifically add code to handle this case in Persister. Looking at that code now on master I see it only kicks in when there is an IdClass for the entity. Maybe the old code (legacy AnnotationBinder stuff) wrapped this case in a "virtual composite"? Gail Badner Does that ring any bells?
|