Re: Object references... Fetched in a separate thread?

2004-02-21 Thread Sean Dockery
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]



Re: Object references... Fetched in a separate thread?

2004-02-21 Thread Armin Waibel
Hi Sean,

I'm nearly sure that OJB never starts new threads by its own. AFAIK only 
the commons-DBCP api starts a new thread (if you enable it) to 
monitor/manage the used connections (used in a ConnectionFactory 
implementation, but per default OJB use it's own connection pool).

 maintaining uses an opaque persistence framework that extends OJB; it
Do this framework use unchanged OJB sources?
regards,
Armin
Sean Dockery wrote:
Unfortunately, I'm stuck on version 0.9.8.  The application that I'm
maintaining uses an opaque persistence framework that extends OJB; it
creates classes explicitly which have disappeared between 0.9.8 and 1.0RC4.
But because I'm using PB calls directly, I'm certain that this problem has
nothing to do with the opaque persistence framework.  (The value of this
software company's persistence framework is dubious; I'll be glad when we
can rid ourselves of it.)
Antonio Gallardo [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi Sean:

AFAIK, this would not happen. BTW, what version are you using?

Best Regards,

Antonio Gallardo

Sean Dockery dijo:

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]


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


Re: Object references... Fetched in a separate thread?

2004-02-21 Thread Sean Dockery
Armin Waibel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi Sean,

Hello, Armin.

 I'm nearly sure that OJB never starts new threads by its own. AFAIK only
 the commons-DBCP api starts a new thread (if you enable it) to
 monitor/manage the used connections (used in a ConnectionFactory
 implementation, but per default OJB use it's own connection pool).

I looked in the OJB.properties file and found the following...

ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryP
ooledImpl

...and the line with DBCP is commented out, so it doesn't look like DBCP is
the culprit.


   maintaining uses an opaque persistence framework that extends OJB; it
 Do this framework use unchanged OJB sources?

I can't know for sure, but I doubt it.  The framework was licensed with the
application that was produced by this consulting company (that is, the same
company that produced this framework wrote a custom software application
based on their framework).  Having worked with their source code for the
application, I don't think that they would be capable of that.

I've been working on this problem off and on for about a week now; if
anyone knows of a solution, please post it here.  If I find the solution,
I'll do the same.

Thanks.

 regards,
 Armin

 Sean Dockery wrote:
  Unfortunately, I'm stuck on version 0.9.8.  The application that I'm
  maintaining uses an opaque persistence framework that extends OJB; it
  creates classes explicitly which have disappeared between 0.9.8 and
1.0RC4.
  But because I'm using PB calls directly, I'm certain that this problem
has
  nothing to do with the opaque persistence framework.  (The value of
this
  software company's persistence framework is dubious; I'll be glad when
we
  can rid ourselves of it.)
 
  Antonio Gallardo [EMAIL PROTECTED] wrote in message
 
news:[EMAIL PROTECTED]
 
 Hi Sean:
 
 AFAIK, this would not happen. BTW, what version are you using?
 
 Best Regards,
 
 Antonio Gallardo
 
 Sean Dockery dijo:
 
 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]
 
 
 




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



Re: Object references... Fetched in a separate thread?

2004-02-20 Thread Antonio Gallardo
Hi Sean:

AFAIK, this would not happen. BTW, what version are you using?

Best Regards,

Antonio Gallardo

Sean Dockery dijo:
 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]



Re: Object references... Fetched in a separate thread?

2004-02-20 Thread Rainer Klute
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]