cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Razumovsky Andrey <hm...@hotmail.ru>
Subject Re[2]: Child context for Web App
Date Sat, 22 Mar 2008 05:18:38 GMT
Hi Pierre,

I haven't actually ever used the 'localObject' method. I mean you can work with nested context
the same way as with parent (global) one, i.e:

DataContext context = DataContext.createDataContext();

DataContext nested = context.createChildDataContext();
Dicrow d = (Dicrow)nested.newObject(Dicrow.class);
d.setDicrowname("ABC");
		
//context.commitChanges(); //does nothing since child context isn't commited
nested.commitChanges(); //creates new record in DB

alternalively:
nested.commitChangesToParent();
context.commitChanges();

Works fine for me, nested contexts won't work through ROP though, but it seems that's not
your case.
If this doesn't help, please describe your application in more detail.

Andrey

Сб, 22.03.2008 10:59:27 you wrote:
>
PG> 
PG> Thanks Andrey,
PG> 
PG> 
PG> 
PG> I am using what you propose for getting child context at session level
PG> chidContext= globalContext.createChildDataContext();. But I dont understand your sentence
:
PG> >> it  collapses to just calling one method.
PG> 
PG> Do you mean using localObject to get object in globalContext ?
PG> 
PG> objectInGlobalContext = (XXX) globalContext.localObject(myObjectInLocalContext.getObjectId(),myObjectInLocalContext);
PG> 
PG> 
PG> Thanks again for your help
PG> 
PG> 
PG> 
PG> Pierre
PG> 

Mime
View raw message