I’m trying to remove a version from the version history and I’m getting javax.jcr.ReferentialIntegrityException: Unable to remove version. At least once referenced.
When I try to remove all references to the version it seems like there aren’t any and still does not allow me to remove the version.
I am sure that this is not the root version and I’m also sure its not the first after the root.
This is my code:
Version ver = manager.checkin(parentNodePath);
VersionHistory versionHistory = manager.getVersionHistory(parentNodePath);
PropertyIterator versionReverences = ver.getReferences();
for (Property verRef = versionReverences.nextProperty(); versionReverences.hasNext();) {
verRef.remove();
}
session.save();
versionHistory.removeVersion(ver.getName());
Any help is greatly appreciated, thanks.
The
checkin()call that creates your version on the first line of your example sets thejcr:baseVersionreference from the versionable node to the version you just created. TheverRef.remove()statement can’t remove this reference, as the jcr:baseVersion property is protected.You need to either remove the content node or use methods like
checkin()orupdate()to make thejcr:baseVersionreference to point to another version before you can remove this version.