2012-12-28 1 views
0

EclipseLink에서 고립 된 캐시 (L1 캐시)에 어떤 오브젝트가 저장되어 있는지보고 싶습니다. 저에게 그렇게 할 수있는 API가 있습니까? 내가 구글을 시도했지만 아무것도 찾을 수 없습니다.EclipseLink에서 격리 된 캐시에 저장된 객체를 인쇄하는 방법은 무엇입니까?

왜 내가 persistence 컨텍스트의 일부 개체를로드 한 후에 쿼리를 실행하면 트랜잭션이 시작될 때 100 밀리 초가 걸린 쿼리가 느려지는지 알게되었으므로 여기에 관심이있는 경우 다른 작업이 이미 발생한 후에 트랜잭션 중간에 실행됩니다. 쿼리를 실행하기 전에 entityManager.clear()을 수행하면 쿼리가 다시 한번 100ms 걸립니다. 필자는 Persistence Context에로드 된 많은 객체가 EclipseLink 성능에 영향을 미치기 때문에 이러한 현상이 발생한다고 생각합니다. 그래서 나는 어떤 객체가 영속 컨텍스트에 있는지 확인하고자합니다.

답변

0

EclipseLink 소스 코드를 살펴본 결과, 퍼시스턴스 컨텍스트 (격리 된 캐시)에 저장된 객체가 각 엔티티 클래스의 identityMaps라는 맵에 있으며 해당 유형의 모든 객체를 저장하는 맵이 있다는 것을 알게되었습니다.

다음과 같은 방법을 사용하여지도의 내용을 인쇄 할 수 있습니다

public interface IdentityMapAccessor { 
    /** 
    * PUBLIC: 
    * Used to print all the Objects in the identity map of the given Class type. 
    * The output of this method will be logged to this session's SessionLog at SEVERE level. 
    */ 
    public void printIdentityMap(Class theClass); 

    /** 
    * PUBLIC: 
    * Used to print all the Objects in every identity map in this session. 
    * The output of this method will be logged to this session's SessionLog at SEVERE level. 
    */ 
    public void printIdentityMaps(); 
} 

예 :

((JpaEntityManager) entityManager.getDelegate()) 
      .getActiveSession() 
      .getIdentityMapAccessor() 
      .printIdentityMaps(); 
((JpaEntityManager) entityManager.getDelegate()) 
      .getActiveSession() 
      .getIdentityMapAccessor() 
      .printIdentityMap(MyClass.class); 
관련 문제