We have an existent (not stale) object in an audit view and want to bind this object to a transaction in PROXY mode. Unluckly, bind method always throws ObjectNotFound exception instead of a proxy object to check CDOUtil.isStaleObject(object).

In fact, this is an possible error to a big unimplement thing:
I have an object in audit view and I do a copy of it that I want to save in db. I bind this new copy object to transaction but at committing all eReference return an "object is from different view" exception. So I have to do a recursive bind of all eReference inner elements and replace them. When I find a stale reference object in the recursive bind, bind methods throws the exception refers in this topic.]]>Paco Blanco2012-12-05T08:50:28-00:00Re: [CDO] CDOStaleReferencePolicy.PROXY vs bind methodhttps://www.eclipse.org/forums/index.php/mv/msg/441108/989411/#msg_989411
> We set stale reference policy of an transaction to PROXY mode:
>
> cdoTransaction.options().setStaleReferencePolicy(CDOStaleReferencePolicy.PROXY)
>
>
> We have an existent (not stale) object in an audit view and want to bind
What is "bind"?

Perhaps you're referring to what we call "contextify" in this CDOView method:

/**
* Takes an object from a (possibly) different view and <em>contextifies</em> it for the usage with this view.
* <ul>
* <li>If the given object is contained in this view it is returned unmodified.
* <li>If the given object can not be cast to {@link CDOObject} it is returned unmodified.
* <li>If the view of the given object is contained in a different session an <code>IllegalArgumentException</code> is
* thrown.
* <li>If <code>null</code> is passed <code>null</code> is returned.
* </ul>
*/
public <T extends EObject> T getObject(T objectFromDifferentView);

> this object to a transaction in PROXY mode. Unluckly, bind method always throws ObjectNotFound exception instead of a
> proxy object to check CDOUtil.isStaleObject(object).
The difference is a little subtle and the confusion may be caused by the term "StaleObject". The underlying concept is a
stale *reference* which always has a declared type even if the target object has been deleted. That's why we can
(optionally) create a Java dynamic proxy for it. CDOUtil.isStaleObject() just tests if that's the case for a given object.

In cases where you try to load an object directly through CDOView.getObject() there is no such persistent reference that
could be stale.

Irrespective of this subtle difference it seems that your object has been deleted between the timestamp of your audit
view and "now". You should catch the ObjectNotFoundException where you CDOView.call getObject().

>
> In fact, this is an possible error to a big unimplement thing:
I'm not sure how to read this statement.

> I have an object in audit view and I do a copy of it that I want to save in db. I bind this new copy object to
> transaction but at committing all eReference return an "object is from different view" exception. So I have to do a
> recursive bind of all eReference inner elements.
Correct.

> When I find a stale reference object in the recursive bind, bind methods throws the exception refers in this topic.
It's not a "stale reference object". It's an object that's not found (because it doesnot exist (anymore?)) where you're
trying to find it.

- is there some way to restore a deleted Object (to keep the same CDOId)?]]>Paco Blanco2012-12-10T07:49:22-00:00Re: [CDO] CDOStaleReferencePolicy.PROXY vs bind methodhttps://www.eclipse.org/forums/index.php/mv/msg/441108/989959/#msg_989959
> bind = contextify yes, sorry
>
> So two questions:
> - is there some way to check if an object exists in a view (from specified timestamp or transaction at current time)?
CDOView.isObjectRegistered(id) tells you whether the object with that ID is currently loaded/cached in that view.
CDOView.getObject(...) throws an ObjectNotFoundException which you can catch to tell whether the object exists remotely.

> - is there some way to restore a deleted Object (to keep the same CDOId)?
AFAIK that's only possible in branching mode when you merge back a deleted object from a branch where it isn't deleted.