Here's what's happening: The certificate objects do indeed point back to the 
customer, but without customer.addCertificate(), the customer doesn't know about 
the certificates.

When you commit the transaction, the FK is copied into the certificates and 
everything is written to the database as expected.  At this point, the OJB cache 
contains the customer (with no certificates) and the certificates (each pointing 
to the customer).

When you do the query, a SELECT is run against the db (this always happens).  It 
finds that, e.g., customer ID 10 matches.  OJB then goes to materialize this 
customer object.  The first thing it does is to check the cache, where it finds 
the customer object from the previous transaction, which has no certificates.  
Because the object was found in the cache, we are done.  If the 'refresh' 
attribute on the 'certificates' collection-descriptor were set, then this 
collection would be refetched at this point and you'd see the certificates.

Now, let's suppose customer ID 10 was added in a prior run and we've just now 
added customer ID 11 in the current run.  Now our query finds two matching 
customers, 10 and 11.  10 is not in the cache yet, because we haven't touched it 
in this run.  So when OJB goes to materialize it, it ends up fetching the whole 
object from the db.  In contrast, 11 is already in the cache and has no 
certificates.  This is why "old" customers are displayed correctly while "new" 
ones are not.

Hope this helps,
-steve

Steve Clark
Technology Applications Team
Natural Resources Research Center/USGS
[EMAIL PROTECTED]
(970)226-9291

>To: [EMAIL PROTECTED]
>From: Gunnar Hilling <[EMAIL PROTECTED]>
>Subject: RE: odmg/caching problem?
>Date: Fri, 10 Oct 2003 02:47:05 +0200
>
>OK, now I hope I know ho to do this. I assume the behaviour is related to
>Caching? Because in some other Thread I think Thomas Mahler said, every
>Query would be executed on the Database. So I thought the results should
>be the same, no matter if written some Minutes before or immediately after
>tx.commit().
>
>Perhaps You could help me understand this behaviour?
>
>Thanks a lot,
>
>-Gunnar



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

Reply via email to