Guest User

Untitled

a guest
Sep 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public class User implements Serializable {
  2. ..
  3. @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,mappedBy = "user")
  4. @JsonIgnore
  5. private List<Wallet> wallets = new ArrayList<Wallet>();
  6. ..
  7. }
  8.  
  9. @OneToMany(mappedBy = "wallet",
  10. cascade = CascadeType.ALL,
  11. orphanRemoval = true, fetch = FetchType.LAZY)
  12. @JsonIgnore
  13. private Set<Purchase> purchase = new HashSet<>();
  14. ...
  15.  
  16. Purchase purchase = new Purchase(wallet);
  17. wallet.getPurchases().add(purchase);
  18. wallet.setUser(user);
  19. user.getWallets().add(wallet);
  20. userService.save(user);
Add Comment
Please, Sign In to add comment