Skip to content

Commit

Permalink
#7263 fix cascade deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Nov 20, 2020
1 parent 3027e0b commit 7809c50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/BannerMessage.java
Expand Up @@ -29,6 +29,9 @@ public class BannerMessage implements Serializable {

@OneToMany(mappedBy = "bannerMessage", cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
private Collection<BannerMessageText> bannerMessageTexts;

@OneToMany(mappedBy = "bannerMessage", cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
private Collection<UserBannerMessage> userBannerMessages;

public Collection<BannerMessageText> getBannerMessageTexts() {
return this.bannerMessageTexts;
Expand Down
Expand Up @@ -496,7 +496,8 @@ public void removeAuthentictedUserItems(AuthenticatedUser au){

deletePendingAccessRequests(au);


deleteBannerMessages(au);

if (!explicitGroupService.findGroups(au).isEmpty()) {
for(ExplicitGroup explicitGroup: explicitGroupService.findGroups(au)){
explicitGroup.removeByRoleAssgineeIdentifier(au.getIdentifier());
Expand All @@ -505,6 +506,12 @@ public void removeAuthentictedUserItems(AuthenticatedUser au){

}

private void deleteBannerMessages(AuthenticatedUser au){

em.createNativeQuery("delete from userbannermessage where user_id = "+au.getId()).executeUpdate();

}

private void deletePendingAccessRequests(AuthenticatedUser au){

em.createNativeQuery("delete from fileaccessrequests where authenticated_user_id = "+au.getId()).executeUpdate();
Expand Down

0 comments on commit 7809c50

Please sign in to comment.