On Jul 2, 4:08 pm, John Watson <wizpu...@gmail.com> wrote: > (Simplified) I have: > <object name="invoice" table="tblInvoices"> > <id name="invoiceId" type="numeric" /> > <property name="invoiceDate" type="date" /> > </object> > > <object name="invoiceItem" table="tblInvoiceItems"> > <id name="invoiceItemId" type="numeric" /> > <property name="itemDesc" type="string" /> > <property name="itemCost" type="numeric" /> > <manytoone name="invoice"> > <link to="invoice" column="fkInvoiceId" /> > </manytoone> > <property name="fkInvoiceId" type="numeric" ignore-insert="true" > ignore-update="true" /> > </object> > > For performance reasons I can not have a onetomany relationship in > invoice (which was a solution Mark gave on a blog somewhere, sorry I > do not have a link). It takes >600 seconds to insert 400 invoiceItems; > that bottleneck is at transfer.save(invoiceItem). > > I want to be able to retrieve all invoiceItems for the invoice. right > now I just do: > transfer.listByProperty > ("invoiceItem","fdInvoiceId",invoice.getInvoiceId()) > > Am I approaching this from the wrong way? Is my DB design flawed? Is > my object design flawed?
Usually you'd want to use TQL for this or use regular SQL. The way you're doing it means you have the foreign key in there twice? That's not usually allowed, though you can hack it with the ignore-* properties. I usually expose this kind of thing through a relationship method on the objects themselves. So I'd have: invoice.listInvoiceItems() and internally that would run a TQL query: <t:query name="result" transfer="#getTransfer()#"> select * from InvoiceItem join Invoice where Invoice.invoiceId = <t:queryparam value="#getId()#"> </t:query> That gets you a fairly transparent API that doesn't require bleeding Transfer all over and means that if you have an Invoice, you always have it's related objects just one method call away. --~--~---------~--~----~------------~-------~--~----~ Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer You received this message because you are subscribed to the Google Groups "transfer-dev" group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en -~----------~----~----~----~------~----~------~--~---