Skip to content

Commit

Permalink
fix(taskframework): fix refresh entity replaced by native sql (#2145)
Browse files Browse the repository at this point in the history
* add findByIdNative

* remove unnecessay code
  • Loading branch information
krihy authored Apr 2, 2024
1 parent 884e60b commit a0b4518
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.oceanbase.odc.metadb.task;

import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
Expand Down Expand Up @@ -60,4 +62,6 @@ public interface JobRepository extends JpaRepository<JobEntity, Long>,
@Modifying
int updateJobStatusAndExecutionTimesById(@Param("param") JobEntity entity);

@Query(value = "SELECT * FROM job_job WHERE id = ?1", nativeQuery = true)
Optional<JobEntity> findByIdNative(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ public class StdTaskFrameworkService implements TaskFrameworkService {

@Override
public JobEntity find(Long id) {
JobEntity jobEntity = jobRepository.findById(id)
return jobRepository.findByIdNative(id)
.orElseThrow(() -> new NotFoundException(ResourceType.ODC_TASK, "id", id));
entityManager.refresh(jobEntity);
return jobEntity;
}

@Override
Expand Down

0 comments on commit a0b4518

Please sign in to comment.