1

I use SpringJPA with Hibernate. I have a cached bList. When I create a new B entity(entity B has a reference to A) with CrudRepository's save method the bList remain empty. When I restart the application bList is updated with the new element. How to update automaticly the cached bList after creating a B entity?

@Entity
@Table(name = "A")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class A extends AbstractAuditingEntity  implements Serializable {

...

 @OneToMany(mappedBy = "a",fetch = FetchType.EAGER)
    @JsonIgnore
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    private Set<B> bList = new HashSet<>();

... 


@Entity
@Table(name = "B")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class B  extends AbstractAuditingEntity implements Serializable {    

...

 @ManyToOne
    private A a;
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
Sisak
  • 559
  • 1
  • 4
  • 14

0 Answers0