I have two objects that are cached by hibernate and related with a ManyToOne relationship : Company that have a list of Treatment.
When I save a new Treatment in my database related to a company it doesn't update the company list of treatment : when I try to get my company later it doesn't contain the new treatment saved in the database.
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Treatment implements Serializable {
@ManyToOne(optional = false)
@NotNull
@JsonIgnoreProperties("treatments")
private Company company;
...
}
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Company implements Serializable {
@OneToMany(mappedBy = "company", fetch = FetchType.EAGER)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Treatment> treatments = new HashSet<>();
...
}