-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Unexpected Related Object behavior
PostPosted: Fri Feb 06, 2004 7:58 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 6:58 pm
Posts: 20
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 8:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well if there are get- and set-Methods in your mapped class, Hibernate uses them just like your application would ... probably thats the case here?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 8:06 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 6:58 pm
Posts: 20
Duh. Of course that is exactly what is happening. Mystery solved.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 8:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Ah, I like it if questions work out that way :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.