jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@gmail.com>
Subject Re: ReferentialIntegrityException not being recoverable
Date Thu, 20 Mar 2008 15:06:56 GMT
hi matje

On Tue, Mar 18, 2008 at 7:09 PM, Matej Knopp <matej.knopp@gmail.com> 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
>

Mime
View raw message