Search code examples
transactionsspring-dataspring-data-gemfire

Get queries work only on Id column inside same transaction


Consider a class Person which has 3 attributes { id ,name ,age } The id is formed as name||age. A get query is working only by Id (in the same transaction the record was created)

 @Transactional
public void test(String id,String id2 ) {
 personService.save(new Person("abc","123"));
 Person person = repository.findByNameAndAge("abc", "23"); //doesn't work in same transaction
    //however find by Id column works in same transaction works
    repository.findOne("abc||23") 
    }

From another transaction call repository.findByNameAndAge("abc", "23") returns result but in the same transaction in which that record is being created it doesn't return any result.

Here the repository is

 public interface PersonRepository extends GemfireRepository<RecordRevision, String> {
           List<Person> findByNameAndAge(String name, String age);

The regions are REPLICATE_PERSISTENT and I am using PDX serialization The call should work even in the same transaction,Is this any known issue?


Solution

  • This is a known limitation in GemFire [[1]]. The Query engine does not see the transaction state. A lookup by id is converted into a GemFire region.get() which is able to see the transactional state.

    [1] http://gemfire.docs.pivotal.io/docs-gemfire/latest/developing/transactions/working_with_transactions.html#concept_ty1_vnt_vk