I am no expert, but I will try to help (use my advice at your own risk!)

assumptions:
payment
        contains ref to Account

insert
        account
                insert payment


assumes Account row exists in DB by the time the payment gets inserted. 
is that true? (I guess, if you didn't get DB FK error when account ref
commented out)
are you inserting the Account row in this operation? (is auto-update=true on
ref descriptor)

Do you have an account object inside of Payment, that has a valid ID? (this
may be your issue)
how is the ID generated? (DB? then you may need a sequenceManager)

if you are using RC6 you may want to look into the auto-XXX settings and
determine which value is best for you. I think that you can set the value to
look at your payment class var "fromAccountId" instead of looking at the
account ID in the Account object (inside of the Payment obj)

hmmm, more questions than answers, sorry about that :) 

Maybe someone else can jump in with better direction





-----Original Message-----
From: Joe Latty [mailto:[EMAIL PROTECTED]
Sent: Monday, May 17, 2004 8:05 PM
To: OJB Users List
Subject: PersistenceBroker Store not working


Please excuse my ignorance (newbie) but I have a class Payment with a
field "fromAccountId" which is a foreign key to an Account Class.

 

Therefore I have a 

 

<field-descriptor id="7" name="fromAccountId" column="FROM_ACCOUNT_ID"
jdbc-type="DECIMAL"/>

 

and 

 

<reference-descriptor name="account" class-ref="com.blah.blah.Account"
auto-retrieve="true">

   <foreignkey field-ref="fromAccountId"/>

</reference-descriptor>    

 

which retrieves relevant information from the Account table for each
Payment.

 

However I have not been able to store (persist) the Payment since adding
the reference. I receive the following error

cannot insert NULL into ("PAYMENT "."FROM_ACCOUNT_ID"). // fromAccountId
is not null.

 

If I remove the reference-descriptor the Payment will insert - no
problem.

 

Thanks for your help

 

Joe


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

Reply via email to