Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class User implements Serializable {
- ..
- @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,mappedBy = "user")
- @JsonIgnore
- private List<Wallet> wallets = new ArrayList<Wallet>();
- ..
- }
- @OneToMany(mappedBy = "wallet",
- cascade = CascadeType.ALL,
- orphanRemoval = true, fetch = FetchType.LAZY)
- @JsonIgnore
- private Set<Purchase> purchase = new HashSet<>();
- ...
- Purchase purchase = new Purchase(wallet);
- wallet.getPurchases().add(purchase);
- wallet.setUser(user);
- user.getWallets().add(wallet);
- userService.save(user);
Add Comment
Please, Sign In to add comment