Given example from Hibernate docs and modifying it so that root level entity (Customer) is read-only while one of its collections (tickets) is read-write:
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class Customer {
...
@OneToMany(...)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public SortedSet<Ticket> getTickets() {
return tickets;
}
...
}
Would collection of tickets get refreshed when accessing customer from cache?
If you modify one of the
ticketsof a givenCustomersomewhere else, yes. Why don’t you test this? Let’s assumeCutomer#1hasTicket#1andTicket#2in itsticketscollection. I ran this code:Which shows the collection of tickets gets “refreshed”.