2017-12-07 12 views
0

안녕하세요, 동일한 트랜잭션 내에서 OQL (SELECT * FROM/some_region_name)을 쿼리하여 지역에 새 항목을 넣었습니다. 항목이 OQL 결과에 반환되지 않았습니다. 아무도 그걸로 무슨 일이 있었는지 알지? 여기Geode/Gemfire OQL의 반환 데이터가 트랜잭션보기에서 올바르지 않습니다.

내 테스트 코드입니다 :

Transaction begin. 
checking username[forrest] before added. 
rUserEntity NOT found 
checking username[forrest] after added. 
**rUserEntity found** 
Transaction end. 
checking username[forrest] after transaction. 
rUserEntity found 

그러나 불행하게도 나는이 결과를 가지고 :

Transaction begin. 
checking username[forrest] before added. 
rUserEntity NOT found 
checking username[forrest] after added. 
**rUserEntity NOT found** 
Transaction end. 
checking username[forrest] after transaction. 
rUserEntity found 

답변

1

이이 알려져있다을 나는 결과를 기대

ClientCache cache = (ClientCache) EcnSpringContext.getBean("gemfireCache"); 

    Region<String, RUserEntity> userRegion = (Region<String, RUserEntity>) EcnSpringContext.getBean("r_user"); 

    CacheTransactionManager txmgr = cache.getCacheTransactionManager(); 
    EcnGeodeTemplate ecnGeodeTemplate = (EcnGeodeTemplate) EcnSpringContext.getBean("rUserTemplate"); 

    String username = "forrest"; 
    System.out.println("Transaction begin."); 
    txmgr.begin(); 

    System.out.println("checking username[" + username + "] before added."); 
    RUserEntity found = (RUserEntity) userRegion.selectValue("SELECT * FROM /r_user WHERE username = '" + username + "'"); 
    if (found == null) 
     System.out.println("rUserEntity NOT found"); 
    else 
     System.out.println("rUserEntity found"); 


    RUserEntity rUserEntity = new RUserEntity(); 
    rUserEntity.setUsername("forrest"); 
    rUserEntity.setId(username); 
    userRegion.put(username, rUserEntity); 

    System.out.println("checking username[" + username + "] after added."); 
    found = (RUserEntity) userRegion.selectValue("SELECT * FROM /r_user WHERE username = '" + username + "'"); 
    if (found == null) 
     System.out.println("rUserEntity NOT found"); 
    else 
     System.out.println("rUserEntity found"); 


    txmgr.commit(); 
    System.out.println("Transaction end."); 

    System.out.println("checking username[" + username + "] after transaction."); 
    found = (RUserEntity) userRegion.selectValue("SELECT * FROM /r_user WHERE username = '" + username + "'"); 
    if (found == null) 
     System.out.println("rUserEntity NOT found"); 
    else 
     System.out.println("rUserEntity found"); 

한정. From the docs :

Queries and indexes reflect the cache contents and ignore the changes 
made by ongoing transactions. If you do a query from inside a transaction, 
the query does not reflect the changes made inside that transaction.