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]