title: querydsl can't get data immediately after Jpa Insert
body: <p>I have a java method with insert and select like that:</p>
  <pre class="lang-java prettyprint-override"><code>    @Override
      public Page&lt;ApprovalProcessEntity&gt; getApprovalProcess(int page, int size, String approvalNum, String approvalType, int approvalStatus, Date start, Date end) {
          //jpa inseart
          checkAndInsertApprovalProcess();
          //querydsl select
          return getApprovalProcess2(page, size, approvalNum, approvalType, approvalStatus, start, end);
      }
  
      @Override
      @Transactional(rollbackFor = Exception.class)
      public void checkAndInsertApprovalProcess() {
          List&lt;Task&gt; list = taskService.createTaskQuery().taskCandidateOrAssigned(curUserId()).list();
          String confirmVar = &quot;IS_CONFIRM&quot;;
          List&lt;ApprovalProcessEntity&gt; entities = new ArrayList&lt;&gt;();
          Set&lt;String&gt; processInstanceIds = new HashSet&lt;&gt;();
          for (Task task : list) {
              processInstanceIds.add(task.getProcessInstanceId());
          }
          Map&lt;String, ApprovalApplyEntity&gt; map = approvalApplyDao.findAllByProcessInstanceIdIn(processInstanceIds).stream().collect(Collectors.toMap(ApprovalApplyEntity::getProcessInstanceId, k -&gt; k));
          for (Task task : list) {
              Object confirm = taskService.getVariable(task.getId(), confirmVar);
              if (confirm != null) {
                  continue;
              }
              taskService.setVariable(task.getId(), confirmVar, true);
              ApprovalProcessEntity entity = new ApprovalProcessEntity();
              String processInstanceId = task.getProcessInstanceId();
              ApprovalApplyEntity apply = map.get(processInstanceId);
              entity.setApprovalStatus(1);
              entity.setCurNode(task.getName());
              entities.add(entity);
          }
          approvalProcessDao.saveAll(entities);
      }
      Page&lt;ApprovalProcessEntity&gt; getApprovalProcess2(int page, int size, String approvalNum, String approvalType, int approvalStatus, Date start, Date end) {
          String userId = curUserId();
          QApprovalProcessEntity qEntity = QApprovalProcessEntity.approvalProcessEntity;
          JPAQuery&lt;ApprovalProcessEntity&gt; jpaQuery = queryFactory
                  .selectFrom(qEntity)
                  .where(qEntity.createTime.between(start, end))
                  .where(qEntity.createPerson.eq(userId));
          if (StrUtil.isNotBlank(approvalNum)) {
              jpaQuery = jpaQuery.where(qEntity.approvalNum.eq(approvalNum));
          }
          if (StrUtil.isNotBlank(approvalType)) {
              jpaQuery = jpaQuery.where(qEntity.approvalType.eq(approvalType));
          }
          if (approvalStatus != -1) {
              jpaQuery = jpaQuery.where(qEntity.approvalStatus.eq(approvalStatus));
          }
          PageRequest pr = PageRequest.of(page, size);
          List&lt;ApprovalProcessEntity&gt; entities = jpaQuery.offset(pr.getOffset()).limit(pr.getPageSize()).fetch();
          return new PageImpl&lt;&gt;(entities, pr, jpaQuery.fetchCount());
      }
  </code></pre>
  <p>if some task haven't be confirmed,insert a new entity in to table;</p>
  <p>then select data from this table;
  if I use the following code,
  when I had a new task, it can insert successfully,
  but can't select data immediately,</p>
  <p>if call <strong>getApprovalProcess()</strong> again, <strong>getApprovalProcess2()</strong> method work well,
  so how can I select data  immediately after insert;
  meanwhile, if i change <strong>getApprovalProcess2()</strong> like：</p>
  <pre class="lang-java prettyprint-override"><code>    Page&lt;ApprovalProcessEntity&gt; getApprovalProcess2(int page, int size, String approvalNum, String approvalType, int approvalStatus, Date start, Date end) {
          return approvalProcessDao.findAll(PageRequest.of(page, size));
      }
  </code></pre>
  <p>then create a new task and call <strong>getApprovalProcess()</strong> method again()
  it can select data immediately, work well
  but actually what I want is Previous Impl,so what should I do that can make it work;</p>