Hi there,

Yes that was the problem alright! I was under the impression that if you
increment the id field at the database level that you didn't need to specify
a SequenceManager - thanks!  Its working fine for me now when I do a
straighforward insert i.e. I am getting the payment inserted and the
transaction inserted with the correct payment id. However now I am trying to
get the insert to work using a stored procedure.  I can get the transaction
to get inserted when I use the <insert-procedure> for the transactions class
descriptor. However I am not able to get it working to insert two entities
together (my Transactions and Payments record). Does anyone know if its
possible to use stored procedures to insert two separate class decriptors
that are linked by a foreign key. To reiterate:

Transactions            -----> class descriptor specifies all transactions
transactionid (pk)                entity attributes to send to SP (using
<insert-procedure>)
paymentid (fk)

Payments                -----> nothing in this class descriptor for SP
insert
paymentid (pk)

The problem is that I cannot refer to values of the Payments attributes in
the <insert-procedure> of the transactions class. Would it be necessary to
create a class that 'joins' Payments and Transactions together (eg in a new
Deposits entity) and then map that to a class descriptor which would have a
<insert-procedure> that could access all the attributes of both classes?

Thanks again for all your help!

Fiona



----- Original Message ----- 
From: "Glenn Barnard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 28, 2004 2:08 PM
Subject: RE: Inserting 1:1 mapping


> 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]
>
>

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

Reply via email to