Hello, Rainer.

I believe that you misunderstand.  The behaviour that I described is
exactly the opposite of what you seem to suggest.  I don't suffer my
productCategory reference becoming null because I sleep for 50
milliseconds.  Just the opposite...  I have to sleep for 50 milliseconds
before my productCategory reference becomes valid.

"Rainer Klute" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hm, reminds me of the problem I encounter with the cache. Depending on
which cache implementation I use my application behaves differently. In
your case, could it be the garbage collector removes your ProductCategory
instance while your main thread is asleep?

Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  [EMAIL PROTECTED]
  K�rner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423

On Sat, 21 Feb 2004 00:18:55 -0700 "Sean Dockery"
<[EMAIL PROTECTED]> wrote:
> Hello there.
>
> I've had a curious experience recently with OJB, and I was wondering if
> someone could confirm my speculations about the behaviour.
>
> Suppose I have two objects...  Product and ProductCategory.  The Product
> object carries both a productCategoryId field as well as a reference
field
> productCategory which is declared as auto-retrieve in my class
descriptor.
>
> Consider the following code segment...
>
>     Transaction tx = implementation.newTransaction();
>     tx.begin();
>     PersistenceBroker broker = ((HasBroker) tx).getBroker();
>     Product template = new Product();
>     template.setId(productId);
>     Identity identity = new Identity(template, broker);
>     Product result = (Product) broker.getObjectByIdentity(identity);
>     tx.commit();
>
>     // Thread.sleep(50);
>
>     System.out.println(result.getProductCategory().getName());
>
> Curiously, I sometimes experience a null pointer exception because
> result.getProductCategory() return null.  When I uncomment the
> Threat.sleep() call, the null pointer exception never happens.
>
> This seems to suggest that the productCategory reference is being loaded
by
> another thread.  Is this the case or can someone explain why
> Product.getProductCategory returns null for me sometimes when I first
> retrieve the Product object?
>
> Thanks for your time...




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to