I may be posting a bit prematurely on this subject since I haven't traced all the way through the Hibernate code at this point, but I am hoping that someone can confirm a behavior that I am seeing (and did not expect):
I have a pretty standard business object (java-bean compliant), the only anomaly is the fact that I do not have an attribute holding the identifier for that object (I have a separate mechanism for this).
Where it differs is how related objects are referenced. Rather than having an explicit reference to a related object, i.e.:
Code:
public class Person {
private IReference address = new SingletonReference("address", Address.class);
...
}
where the IReference is a placeholder for the related object. I won't go into all of the reasons why it is there, but that is how it works.
Now the IReference interface looks a lot like the WeakReference class. In other words, there is a get() method that returns the related object (if it exists), and a set(Object o) method allowing you to set the reference.
Now to the unexpected behavior. I am in the process of integrating Hibernate with my existing framework, and I was running some tests on retrieving related objects. When I first coded the test, I set up the classes to relate the "standard" way, i.e.:
Code:
public class Person {
private Address myAddress;
...
}
After fiddling with the mapping I was able to store and retrieve the the primary and the related objects.
Then I switched the reference to use the IReference as described above, and much to my surprise, the test still ran.
I don't even have a theory as to why this is working, but it does. I'd like to call it good and move on, but I need to know if this is expected behavior or if I have something strange going on.
Any insight into this matter would be greatly appreciated - I'm planning on tracing through the code later this weekend so if I don't get any answers here I'll find out in the code.
Regards,
Jonathan House