cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Miller" <philip.mil...@bbc.co.uk>
Subject RE: Selective commit
Date Mon, 07 Jan 2008 15:10:10 GMT
That nudge should have been for rollbackChangesLocally() - CAY-716. Sorry Andrus. 

> -----Original Message-----
> From: Philip Miller [mailto:philip.miller@bbc.co.uk] 
> Sent: 07 January 2008 14:29
> To: user@cayenne.apache.org
> Subject: RE: Selective commit
> 
> Nested data contexts may also help you to isolate atomic 
> changes to the object graph. Especially when the 
> commitChangesLocally() method is implemented (nudge ;). Check 
> out DataContext.createChildDataContext().
> 
>  
> 
> > -----Original Message-----
> > From: Andrus Adamchik [mailto:andrus@objectstyle.org]
> > Sent: 07 January 2008 13:32
> > To: user@cayenne.apache.org
> > Subject: Re: Selective commit
> > 
> > Hi Álvaro,
> > 
> > It is hard to give a precise advice on multithreading 
> without knowing 
> > the nature of your application. So here is a few general notes:
> > 
> > * DataContext instance is your isolated area for making in-memory 
> > changes to objects that will all be committed at once. So consider 
> > using multiple contexts as appropriate.
> > Cayenne docs recommend various common patterns, such as DataContext 
> > per session (i.e. each user has a dedicated context), 
> DataContext per 
> > request, or DataContext per application (in a read-only 
> app). You can 
> > also devise your own approach, if none of the above fit your needs. 
> > All you need to know here is that multiple threads *reading* from a 
> > shared DataContext is ok, but multiple threads *writing* to 
> a shared 
> > DataContext is not ok.
> > 
> > * In a rare case if you really need multiple threads to work off of 
> > the same context, consider using a dedicated nested DataContext for 
> > each atomic object modifications.
> > 
> > Andrus
> > 
> > 
> > On Jan 7, 2008, at 2:44 PM, Álvaro Martínez wrote:
> > >
> > > Hi, I've been working for a while with Cayenne but never 
> realized I 
> > > had a problem... until I got a weird exception.
> > >
> > > The fact is that I had been using context.newObject() and
> > > context.commitChanges() to create new rows in the 
> database. But my 
> > > application works with many threads, so global commits 
> can (and in 
> > > fact do) interrupt normal creation of objects. Thread A and
> > Thread B
> > > are creating objects and filling their fields, but then B
> > commits all
> > > and A throws a validation exception because mandatory fields are 
> > > missing.
> > >
> > > How could I commit only one object?
> > >
> > > Thanks,
> > >
> > > Álvaro from Spain (Push the button Inc.)
> > >
> > >
> > >
> > 
> > 
> 
> http://www.bbc.co.uk/
> This e-mail (and any attachments) is confidential and may 
> contain personal views which are not the views of the BBC 
> unless specifically stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor 
> act in reliance on it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
> 					
> 

http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are
not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify
the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
					

Mime
View raw message