Hi Michael,
sorry for delay, I was kind of busy during weekend,
I played around a little bit and the newObject() approach seems to be
fine and is easily debuggable.
Thanks for sharing ideas, regards
-- Marek ŠaboOn 05/08/2010 03:03 PM, Michael Gentry wrote: > Hi Marek, > > I kind of lost track of this e-mail. Sorry for the delay. > > I think the way you are doing it is fine -- especially since you are > needing to set values. A couple of optimizations you could make are > to use a brand new DataContext for the batch inserrs and also break it > into smaller chunks (like 100 or so) to keep the memory footprint > leaner. > > However, your original question was about batch inserts. You could look into: > > http://cayenne.apache.org/doc/api/index.html?org/apache/cayenne/query/InsertBatchQuery.html > > Personally, though, I'd just use the normal dataContext.newObject() approach. > > mrg > > > On Wed, May 5, 2010 at 7:26 PM, Marek Šabo <msab..uk.cvut.cz> wrote: > >> Hi Michael, >> >> thanks, I do it this way as well and it's ok (~ 10k), but I was >> wondering if there was a batch-insert. Just a thought - let's say: >> >> instead of: >> >> SelectQuery sel2 = new SelectQuery(OrgIncome.class); >> List<OrgIncome> incomes = ctx.performQuery(sel2); >> for (OrgIncome oi : incomes) { >> Payment p = ctx.newObject(Payment.class); >> p.setAmount(oi.getAmount().doubleValue()); >> p.setDate(oi.getDate()); >> p.setNote(oi.getInfo()); >> p.setVariableSymbol("" + oi.getVs()); >> } >> ctx.commitChanges(); >> >> you would use something like: >> >> SelectQuery sel2 = new SelectQuery(OrgIncome.class); >> List<OrgIncome> incomes = ctx.performQuery(sel2); >> BatchInsertWrapper<OrgIncome> biw = new >> BatchInsertWrapper<>(incomes); >> biw.commitTo(ctx); >> >> with some optimizations for mass inserts inside. >> >> Regards, >> >> On 05/05/2010 10:58 PM, Michael Gentry wrote: >> >>> Hi Marek, >>> >>> I don't know how many objects you are talking about inserting, but >>> I've done mass inserts (tens to thousands of objects) just using >>> dataContext.commitChanges(). >>> >>> mrg >>> >>> >>> On Wed, May 5, 2010 at 4:55 PM, Marek Šabo <msab..uk.cvut.cz> wrote: >>> >>> >>>> I've been searching for a method to persist list of DataObjects aka >>>> batch insert or mass insert. Haven't found anything relevant so far. Is >>>> there a support for this in cayenne or some optimized way to this? >>>> (faster than iterating and single inserting) >>>> >>>> >>>> >>> >> >> -- >> Marek Šabo >> Server Manager >> Club SU CVUT Buben >> Bubenečská Kolej (421) >> XMPP: zeratul02..mail.com >> >> >> >
This archive was generated by hypermail 2.0.0 : Mon May 10 2010 - 19:39:03 UTC