}
@Override
public void setObject(String url) {
if (url != null && wrappedModel.getObject() == null) {
wrappedModel.setObject(new ExternalLinkWrapper(url));
} else if (url != null) {
wrappedModel.getObject().setUrl(url);
} else {
// NOTE: This is a workaround to the orphanRemoval bug on one-to-one relationship
// https://hibernate.atlassian.net/browse/HHH-5559
// https://hibernate.atlassian.net/browse/HHH-6484
ExternalLinkWrapper link = wrappedModel.getObject();
wrappedModel.setObject(null);
if (link != null) {
try {
externalLinkWrapperService.delete(link);
} catch (Exception e) {
LOGGER.error("An error occurred while deleting the link " + link.getUrl());
}
}
}
}