openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: Help with StateManager relationships
Date Tue, 26 May 2009 21:28:30 GMT

Hi Craig,
> So in the case of the relationship field called "a" that refers to an
> instance of "A", the column is "a_id". 

  Let us say we are loading an instance of B called b. B has a one-to-one
relation to A expressed as a field B.a. B.a will be assigned a strategy (in
this case RelationFieldStrategy).

  1. In course of loading B, JDBCStoreManager has a StateManager(B) and some
data from database. JDBCStoreManager is loading field-by-field of B. 
  2. Now when JDBCStoreManager encounters field B.a, it will call that field
to load(1246). The field will delegate that call to its strategy. 
  3. The strategy will effectively call back to the JDBCStoreManager to
find(1234, A.class) -- because strategy knows that 1246 is a reference to an
instance of A. 
  4. JDBCStoreManager.find(1246) will resolve the reference 1246 as a real
instance by calling _ctx.find(1246,....). The _ctx is broker.  Let us say,
broker finds a1 - an instance of A - already in cache with id 1246.
   5. Now RelationFieldStreagy(B.a) can set
StateManager(b).storeObject(field.index(B.a), a1)

  I may have missed many a details and important points. But hope that helps
you to get a more accurate picture of how OpenJPA resolves references.

  Regards --

Pinaki



-----
Pinaki Poddar                      http://ppoddar.blogspot.com/
                                      
http://www.linkedin.com/in/pinakipoddar
OpenJPA PMC Member/Committer
JPA Expert Group Member
-- 
View this message in context: http://n2.nabble.com/Help-with-StateManager-relationships-tp2976437p2977345.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Mime
View raw message