Hi Michael, I checked the stacktrace again, it's my fault, the expensive operation was the reflection on the getter and setter :-/ The coding was pretty old, so I don't need reflection in my case ;-)
Here the old approach Object value = Reflect.on(source).call("get" + StringUtils.capitalize(objAttribute.getName())).get(); Reflect.on(target).call("set" + StringUtils.capitalize(objAttribute.getName()), value); Now I switch to Object value = source.readPropertyDirectly(objAttribute.getName()); target.writePropertyDirectly(objAttribute.getName(), value); I think this will give my application a real kick :-) br Markus Michael Gentry <blackn...@gmail.com> schrieb am Do., 20. Apr. 2017 um 13:28 Uhr: > Hi Markus, > > As you have discovered, Cayenne objects need to be in a context when > relationships are involved. I'm curious why you think creating a context > is very expensive, though? It should actually be pretty cheap > memory/cpu-wise. > > As for copying objects, are you copying committed objects or copying > new/modified objects and you need the new values? > > mrg > > > On Thu, Apr 20, 2017 at 7:12 AM, Markus Reich <markus.re...@markusreich.at > > > wrote: > > > Hi, > > > > I have a very special problem :-/ > > We want to use a cayenne object as detached object, for a simple object > > this works fine, as the attribute values are hosted in a value map, but > we > > need a context when we want to use the relations too :-/ > > > > What would be the best approach? > > At the moment we create the object in a second context and copy the > > attributes / relations with reflection (deep copy) as we have a lot of > this > > objects, creating context is very expensive and we want to reduce costs > :-) > > > > br > > Markus > > >