0
(EHCache에 의해) 캐싱하는 Hibernate 콜렉션에 문제가있다.Hibernate : 콜렉션 캐시가 축출되지 않았다.
그래서,이 컬렉션 소유하는 엔티티입니다 :
@Entity(name = "Event")
@Table(name = "t_event")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class Event implements Comparable<Event>, Comparator<Event> {
@Id
@Column(name = "event_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "event_message_id", referencedColumnName = "message_id")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
private Message message;
// ...
}
문제 : 다른 엔티티에, 그리고
@Entity(name = "Message")
@Table(name = "t_message")
public class Message implements Comparable<Message>{
@Id
@Column(name = "message_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "message")
@Sort(type = SortType.NATURAL)
@JsonIgnore
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
private SortedSet<Event> events = new TreeSet<>();
// ...
}
이 메시지에 symetrical가 때 "이벤트"필드 인 이벤트를 추가하면 캐시가 제거되지 않습니다. 이 필드 아래에 @Cache anotation을 제거하면 캐시가 작동하지만 물론 작동하지 않습니다.
<property name="hibernate.cache.auto_evict_collection_cache">true</property>
:
나는이 (엔티티 조작에 의한) 새로운 이벤트를 삽입 할 때, 우리는 이벤트 측에서 메시지에 연결 그래서 최대 절전 모드 설정 파일에이 줄을 추가 한 사실과 연결되어야한다 생각
하지만 문제가 해결되지 않았습니다.
추가 정보 :
- 다른 ManyToOne 컬렉션 캐싱이 프로젝트에 완벽하게 작동합니다.
- 프로젝트에는 네이티브 쿼리가없고 HQL 및 엔티티 조작 만 가능합니다.
- 나는 최대 절전 모드 4.3.2와 EHCache 2.10.4를 사용하고있다.
귀하의 조언에 감사드립니다.