Fiona, a couple of questions/issues...

1) Iin your repository.xml, have you declared the <sequence-manager> as SequenceManagerNativeImpl? Let me know if you need the syntax....
2) I think you need also "autoincrement="true"" in the <field_descriptor> for PaymentID in the Payments table




From: "Fiona Magner" <[EMAIL PROTECTED]>
Reply-To: "OJB Users List" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: Inserting 1:1 mapping
Date: Thu, 27 May 2004 17:23:15 +0100

Hi there:

I am just learning OJB and so far I think its great! I am having some problems inserting 1:1 records that I was hoping someone could help me with. I have a table Transactions that has a reference (1:1) to a table Payments:

Transactions
transactionid (pk)
paymentid (fk)

Payments
paymentid (pk)

These therefore correspond to my entity classes like so:

Transactions
long transactionid;
long paymentid;
Payments thePayment;

Payments
long paymentid;

In my repository_user file  have the following:

<class-descriptor class="Transactions" table="Transactions">
<field-descriptor id="0" name="transactionid" column="TransactionID" jdbc-type="INTEGER" primarykey="true" access="readonly"/>
......
<field-descriptor id="17" name="paymentid" column="PaymentID" jdbc-type="INTEGER" />
<reference-descriptor name="thePayment" class-ref="Payments" auto-update="false">
<foreignkey field-ref="paymentid"/>
</reference-descriptor>
</class-descriptor>
and


<class-descriptor class="Payments" table="Payments">
<field-descriptor id="0" name="paymentid" column="PaymentID" jdbc-type="INTEGER" primarykey="true" access="readonly" />
.....
</class-descriptor>


The access=readonly is because I am using MSSQL and need to use the autoincrement for the primary key field used by the database (as I also have legacy systems working from the same database). When I try to do an insert on the 1:1 mapping above I get a payment record created and a transaction record created successfully but the paymentid in the transaction record is 0. Can anyone see why this would happen. I have gone through all my mappings with a fine tooth comb and also checked to see if any others are having the same problem. I am using ODMG (therefore I have set the auto-update=false in the reference desciptor as recommended). I would appreciate any help anyone has on this!

Thanks
Fiona

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar � get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/



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



Reply via email to