Hi Richard, When to commit is really dependent upon the application, but a general guide would be whenever your object graph is in a state that you want to commit the changes. Cayenne's DataContext (and supporting stack) is thread-safe in that an application can have numerous DataContexts doing queries and commits, but you shouldn't have multiple threads sharing a DataContext without some kind of thread-safe controls over it.
It sounds like your crawler needs to commit the URLs every time it adds one, but even then I could see a situation where multiple threads could insert the same URL. Creating a thread-safe singleton that used a single DataContext might be the best approach for you. The singleton would have addURL() type methods and those would manipulate the DataContext in a thread-safe way and ensure no duplicates. mrg On Wed, Nov 16, 2011 at 6:00 PM, Richard Frovarp <[email protected]> wrote: > What's the best strategy for doing frequent updates to the database with > multiple threads?
