Skip to content

Commit

Permalink
refetch entity after content modification operations when entity is @…
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Warren committed Sep 13, 2018
1 parent af4f5e0 commit ef1f6c8
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Version;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -178,6 +179,11 @@ public void putContent(HttpServletRequest request, HttpServletResponse response,

info.getImpementation().setContent(domainObj, request.getInputStream());

// re-fetch to make sure we have the latest
if (BeanUtils.hasFieldWithAnnotation(domainObj, Version.class)) {
domainObj = findOne(repositories, info.getDomainObjectClass(), id);
}

save(repositories, domainObj);

if (isNew) {
Expand Down Expand Up @@ -232,6 +238,11 @@ public void deleteContent(HttpServletResponse response, @PathVariable String sto

info.getImpementation().unsetContent(domainObj);

// re-fetch to make sure we have the latest
if (BeanUtils.hasFieldWithAnnotation(domainObj, Version.class)) {
domainObj = findOne(repositories, info.getDomainObjectClass(), id);
}

if (BeanUtils.hasFieldWithAnnotation(domainObj, MimeType.class)) {
BeanUtils.setFieldWithAnnotation(domainObj, MimeType.class, null);
}
Expand Down

0 comments on commit ef1f6c8

Please sign in to comment.