0

i try too save Provider, which have a Set of Address, but it return Server Error.

i try too save Provider, which have a Set of Address, but it return Server Error. enter image description here enter image description here

enter image description here

Aref
  • 1
  • 2

2 Answers2

0

If the server error looks like this: object references an unsaved transient instance - save the transient instance before flushing

You should have something like this in the Address class:

@OneToMany(
mappedBy = "provider", 
orphanRemoval = true,
cascade = CascadeType.ALL)
private Set<Address> addresses = new HashSet<>();

This may help: https://stackoverflow.com/a/2302814/5902295

If it's not that error, you could edit your post and add a screenshot.

LDroid
  • 41
  • 4
  • is not the Error error look like Unable to find com.example.eshop_backend.model.Address with id ab31fecf-40a6-4052-8995-91a614320e18 – Aref Apr 05 '23 at 11:58
0

I think while saving provider you are not getting address that's why it's showing EntityNotFoundException.

You can try with fetch = FetchType.EAGER in your address mapping so it will fetch addresses immediately.

Mayuri
  • 101
  • 1