Yep. The order of operations is:
  - call the no-arg constructor
  - populate the member fields
  - call the initialization method
  - populate the references

I typically use a lazy intitialization pattern where the first time the reference is 
requested I do any initialization required.

-----Original Message-----
From: Hal Arnold [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 21, 2003 7:29 PM
To: [EMAIL PROTECTED]
Subject: help for init problem


Folks,

I have an object; Advertiser that has an object; Account. The advertiser also has an 
AdvertiserState object (created on the fly, not in storage) that represents the status 
of the advertiser/account combo (the account actually holds the currentStatus as a 
string, for persistance. I'm using the persistanceBroker version of OJB. I'd like to 
'initialize' the advertiser with it's correct AdvertiserState on creation of the 
advertiser-account object. 

I note that pb has a class-descriptor attribute: initialization-method: 

 <class-descriptor
    class="com.proj.advertiser.model.Advertiser"
    table="ADVERTISER"
    initialization-method="init">
        .
        .
        .

   <reference-descriptor
        name="account"
        class-ref="com.proj.account.model.Account"
        auto-update="true"
        auto-delete="true"
        auto-retrieve="true"
        >
        <foreignkey field-ref="accountId"/>
    </reference-descriptor>
... etc />

that can get called on creation. My problem is that the account is created seemingly 
after the advertisement, and the whole object is then assembled. Which means that the 
account, which has the persistent value of the current object status can't be known 
when I want it (when the advertiser's init method would get called) to create my 
on-the-fly AdvertiserState association.

Anybody have an idea how I might solve this delemma? Some sort of lazy instatiation? 
I'm working around it at present, by creating the whole association and then 
programmatically calling an initialization() routine on the created advertiser.

cheers,

hba


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

Reply via email to