Last active
August 9, 2018 21:29
-
-
Save renanpalmeira/706aa430789c288c7b1ac5d676cce5c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model model = repo.findById(22L); | |
ModelAddress modelAddress = new ModelAddress(); | |
modelAddress.setIdModel(model.setIdModel()); | |
Optional<InstitutionAccountDocument> addressResponse = repoAddress.save(modelAddress); | |
// normal here | |
addressResponse.ifPresent(modelAddressResponse -> model.setModelAddress(singleList(modelAddressResponse))); | |
ModelEmail modelEmail = new ModelEmail(); | |
modelEmail.setIdModel(model.setIdModel()); | |
Optional<InstitutionAccountDocument> emailResponse = repoEmail.save(modelEmail); // here is a evil/error | |
emailResponse.ifPresent(modelEmailResponse -> model.setModelEmail(singleList(modelEmailResponse))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model { | |
@OneToMany | |
@NotFound(action = NotFoundAction.IGNORE) | |
@JoinTable( | |
name = "model_address", | |
joinColumns = @JoinColumn(name = "idModel"), | |
inverseJoinColumns = @JoinColumn(name = "idModelAddress") | |
) | |
private List<ModelAddress> modelAddress; | |
@OneToMany | |
@NotFound(action = NotFoundAction.IGNORE) | |
@JoinTable( | |
name = "model_email", | |
joinColumns = @JoinColumn(name = "idModel"), | |
inverseJoinColumns = @JoinColumn(name = "idModelEmail") | |
) | |
private List<ModelEmail> modelEmail; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment