I’m trying to upload a new version of an attachment but currently it fails with the following error message:
javax.persistence.PersistenceException: org.hibernate.HibernateException: identifier of an instance of com.atlassian.confluence.pages.Attachment was altered from 425066907 to 0
The code is as follow:
Attachment createAttachment(Attachment sourceAttachment, Page targetNodePage, Attachment targetAttachment) {
Attachment createdAttachment = new Attachment()
createdAttachment.setContentType(sourceAttachment.getContentType())
createdAttachment.setFileName(targetAttachment.getFileName())
createdAttachment.setComments(sourceAttachment.getComments())
createdAttachment.setFileSize(sourceAttachment.getFileSize())
createdAttachment.setContainer(targetNodePage)
attachmentManager.saveAttachment(createdAttachment, targetAttachment, sourceAttachment.getContentsAsStream())
return createdAttachment
}