Re: [Modeling-users] Some more questions
Status: Abandoned
Brought to you by:
sbigaret
From: Jerome K. <Jer...@fi...> - 2003-09-17 11:25:00
|
Ernesto Revilla wrote: >Hi again, > >Queries with large resultsets: >I remember I read about this but I don't see where. What is returned for a fetch with a result set of, say, 10000 rows? A list? Or an iterator? Is there a concept like database cursors, which iterate over objects (wherever they are stored), instead of database rows? > > You can use both . either fetch using Ec ( via relationships..) so you will get a list of object or using fetchRow and you will get a dict per row ( which isn't exactly why the Modeling is done for ) >Multi-user environment: >I read the deployment instructions of the user doc. Under SQLite, when two separe editing context (either different applications or one application but different editing context) save changes to the same object, the latter one overwrites silently the earlier ones, which is not that nice. Does this behave the same way with Postgres? And with mySQL? > > 2 things : - SQLite isn't a multiuser DB. you can't open the db twice. so in Modeling open / fetch / close is the circle i think . that's why you get this . - MySQL / Postgres and others can handle this smoothly. but again take care that Modeling have some caching functions (on fetch) that can drive you in the wall if you doesn't take care about that. here a sample authors = ec.fetchWith(....) will retrieve the authors from the DB .. and build Authors object w/ now do authors[0].setName('Jean Pascal') ec.saveChanges() This will change the right row .. etc . but if on another host (or even another program ) you do the same thing as the same time, you won't get the right result cause authors is in the cache . so the second program won't see the changes until the first one call ec.saveChanges() . and worst case happen . since authors is in cache so won't be retrieve at second call .. This really can be a severe issue, you can avoid this by using Nested EC .. or doing some ec.dispose ( with all the drawback this generate ) >Grand Totals, Counters, etc. >Say I have a heavily accesed table and I want to have grand totals per month. What is the best way to accomplish this? (The problem is that if I do this within the domain class, it has to read and update the total with added/updated/deleted data, but during these operations other people may also hace to need to update the same field, causing collisions or overwriting. If there was a 'add' operation which would be translated to SQL (field=fiel+increment), this problem would disappear, as it would be executed inside a transaction. Also, the grand total should perhaps be a volatile field and no cached, that is, whenever we access entity.getGrandTotal() it would be read from the database.) In databases with triggers, this is easily resolved inside the DB, but we still need volatile attributes. > > Last time i work w/ the Modeling i got this kind of trouble. We use a manual SQL lock on a db table to ensure that other EC ( running on other hosts) won't try to access the DB at the same time. Pay caution that you CAN'T lock a Modeling table as you don't know when modeling will access this (when fetch occur) so we used a empty table for locking only. for example we work on a table STATS we got a STATS_LOCK table which is SQL manually lock/unlock between statistics update. >Simple question: >can an editingContext access (fetch and update) classes of different models at the same time? >(I think this is true, but still haven't tried it. It can also treat heterogenous data sources, although there may be no relations between different models, right?) > > It should yes.. but haven't tested . Sebastien should know that. >Would it be possible to create a Wiki? Wouldn't it be the right place to put questions like these? > > Sebastien try to keep the documentation as simple / explicit as he can, i think. and he usually do some great job about this. now it's clear that he seems to have a lot of work right now, and miss some mails . Bye Bye .. |