2017-12-07 10 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. 
関連する問題