Trouble with Proxy Resolution [message #423581] |
Thu, 02 October 2008 10:55  |
Eclipse User |
|
|
|
I am having trouble with proxy resolution. My model doesn't use
containment relationships, they are all references.
A hasManyBs
B hasManyCs
An instance of A is created during resource load and added to the resource
contents.
When I do "a.hasManyBs.toArray()" the Bs resolve but are not contained in
the resource.
If I then try to do "b.hasManyCs.toArray()", the proxy resolution seems to
fail because B does not belong to a resource.
I have tried to add each object to the resource as they are loaded but I
get exceptions when doing that. I am not sure if this is the correct
approach or not anyway.
What approach should I use to make this model behave as expected in EMF?
|
|
|
|
|
|
|
|
|
|
Re: Trouble with Proxy Resolution [message #423608 is a reply to message #423602] |
Thu, 02 October 2008 16:26   |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
Hi, Greg,
Your TransactionalEditingDomain will consider this addition of the
object to a resource as a model change, which requires a read/write
transaction. Ordinary proxy resolution is compatible with a read-only
context because it doesn't actually change the "abstract state" of any
EObjects or Resources.
You will need to do one of:
- execute a command with the Transaction.UNPROTECTED option to
add the object to the resource. This option is required in
case the current thread has a read-only transaction in progress,
which is probably likely. Also, you probably don't want this
change to be undoable
- toggle the eDeliver() state of the resource off and on around
the insertion of the object, so that the editing domain doesn't
hear about the change
HTH,
Christian
Greg Fox wrote:
> I tracked it down to the TransactionChangeListener.
>
> IllegalStateException ise = new
> IllegalStateException(Messages.noWriteTx);
>
>
> Here is my method from my ResourceImpl :
> protected EObject getEObjectByID(String id) {
> EObject result = null;
> MMObj obj = MMObj.getInstance(getModelSource().getModel(), ObjId
> .getInstance(Long.valueOf(id)));
>
> // If the MMObj is in a deleted status, then do not continue
> if (obj.getChgStatus() == ChgStatus.DELETED_ITEM) {
> return null;
> } else {
> MetaModelResourceSync synch = ResourceSyncFactory
> .getResourceSyncByOTC(obj.getObjTypeCode());
> if (synch != null) {
> result = (EObject) synch.load(this, obj.getId().getValue());
> this.contents.add(result);
> }
> }
> return result;
> }
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03972 seconds