Hi Glenn, Yes I had to insert the <sequence-manager> into my repository_database and also insert the autoincrement=true into my class descriptor. I guess I didn't play around with enough combinations!
As for the Stored Proc problem, this is now no longer a problem with primary keys :). I know I will have to get the primary key of the Payments within my SP to pass to my Transactions insert but my problem is this. I have two class descriptors that are linked through a foreign key. I want to be able to insert a record for each using only one stored procedure (ie within a database transaction). I can use a SP to map attributes from one class descriptor to the runtime arguments for the SP but cannot map arguments from the foreign class descriptor in the same <insert-procedure> tag. I hope I am making sense. Anyway I appreciate any input. I will keep plugging away at it to see if I can get any joy.... Thanks! Fiona ----- Original Message ----- From: "Glenn Barnard" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, May 28, 2004 5:27 PM Subject: Re: Inserting 1:1 mapping > Fiona, glad it worked for. Was that with or without the > autoincrement="true"??? > > As per your stored procedures....This is a guess only. Since OJB won't know > what's returned from the stored procedure, I'd have to say you have to take > full control and insert the Payment first, get the PK from the stored > procedure and then insert the Transaction. Hopefully, someone else with more > experience with stored procedure can help you. > > > >From: "Fiona Magner" <[EMAIL PROTECTED]> > >Reply-To: "OJB Users List" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >Subject: Re: Inserting 1:1 mapping > >Date: Fri, 28 May 2004 15:19:23 +0100 > > > >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] > > > > _________________________________________________________________ > Learn to simplify your finances and your life in Streamline Your Life from > MSN Money. http://special.msn.com/money/0405streamline.armx > > > --------------------------------------------------------------------- > 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]
