Exception/rollback behavior question

2011-04-27 Thread Dave Lamy
In a clustered project of ours we are sometimes seeing Postgres throw a deadlock exception, most likely because two concurrent updates are trying to update related rows in different orders. According to the Postgres docs, the "easy" thing to do in this case is to retry the transaction that threw t

Re: commit all objects, temporary objects, POJO's, DTO

2011-04-27 Thread Michael Gentry
Hi Felix, I use DataContexts to group related changes. If I need to do an unrelated change, I create a new (or child) DataContext, do my change in it, and commit it. You don't have to stick to just one DataContext. Create as many as you need. mrg On Wed, Apr 27, 2011 at 8:36 AM, felix wrote

Re: commit all objects, temporary objects, POJO's, DTO

2011-04-27 Thread Mike Kienenberger
You're going to have to give us more information before we can speculate on what's the best choice. It may be that a combination of several approaches make sense for your current project. I've used a number of approaches in the past. For example. On one struts project, I created a per-ses

Re: commit all objects, temporary objects, POJO's, DTO

2011-04-27 Thread felix
Thanks for your quick response. It seems like we have two options: - Create a context per writeable action (otherwise we could not retrieve an object, updated and save exactly when we want, in other words, when the obj is in a consistent state) - Create a DTO layer and have for instance one conte

Re: commit all objects, temporary objects, POJO's, DTO

2011-04-27 Thread Mike Kienenberger
The thing to remember is that Cayenne DataContexts are completely under your control. There are convenience classes to automatically make one data context managed per session, but that's only one of many ways, not only way or even the recommended way. It's hard to help without more specific info

Re: Easy way to update objects

2011-04-27 Thread Mike Kienenberger
If what you want to do is copy your detached objects values into a non-detached object in the database You could use the metadata in the Cayenne model to iterate over the attributes and relationships of the detached object and set them on the matching object from the database.I have done t

commit all objects, temporary objects, POJO's, DTO

2011-04-27 Thread felix
I am using Cayenne with Wicket, and am using the servlet filter described here http://cayenne.apache.org/doc30/web-applications.html to bind a DataContext to requests. I understand this occurs per session, so subsequent requests within the session are associated to the same DataContext, which is

Re: Easy way to update objects

2011-04-27 Thread Andrus Adamchik
"Attach" operation is a bit alien to Cayenne. We have a TODO somewhere in Jira, but I guess nobody wanted it badly enough to implement. The closest thing to it is this: MyObject detached = ; ObjectId id = new ObjectId(..); // create it based on PK values... or maybe your object already has an O