hi matje
On Tue, Mar 18, 2008 at 7:09 PM, Matej Knopp <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a problem with referential integrity. When attempting to remove
> node that is referenced by other nodes I get a
> ReferentialIntegrityException. So far so good. But when I catch the
> exception and want to work with the node, i get
> javax.jcr.InvalidItemStateException:
> c47e08bd-ac12-4565-8b32-347062c780ed: the item does not exist anymore.
>
> Looks like the item is still marked as removed within the session.
> That would make sense to me if I could revert the deletion by calling
> .refresh(false). However refresh(false) called on node, parent or
> session after the ReferentialIntegrityException doesn't help.
the Node instance has been discarded through the Item.remove() call.
calling refresh currently doesn't resurrect previously discarded Item instances.
i am not sure whether that's a bug according to the spec, i'll have to check
the spec.
anyway, retrieving a fresh Node instance should solve your problem, e.g.
String s = target.getPath();
target.remove();
try {
session.save();
} catch (ReferentialIntegrityException rie) {
session.refresh(false);
}
target = (Node) session.getItem(s);
BTW: if you think that the current behaviour is actually a bug please feel free
to file a jira issue.
happy easter!
stefan
>
> I'm using latest trunk.
>
> Thanks.
>
> Matej
>