Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java-刷新数据库_Java_Spring_Hibernate_Spring Data Jpa - Fatal编程技术网

Java-刷新数据库

Java-刷新数据库,java,spring,hibernate,spring-data-jpa,Java,Spring,Hibernate,Spring Data Jpa,我正在使用SpringBootMVC和Java 我有一个终点: @GetMapping("/validate/{idIntRaptMec}") public ResponseEntity<?> validate(@PathVariable(value="idIntRaptMec") Long idIntRaptMec ){ //Get the appointment from the table IntRaptMec appointment = in

我正在使用SpringBootMVC和Java

我有一个终点:

@GetMapping("/validate/{idIntRaptMec}")
public ResponseEntity<?> validate(@PathVariable(value="idIntRaptMec") Long idIntRaptMec ){

      //Get the appointment from the table    
      IntRaptMec appointment = intRaptMecService.getPointment(idIntRaptMec);
      (...)
}
我不是在处理交易。与数据库的连接是正确的,因为我可以毫无问题地获取其他对象(来自其他模型)。我正在使用Oracle数据库

这是IntraTMecService类:

@Service
public class IntRaptMecService {

    @Autowired
    IntRaptMecRepository intRaptMecRepository; 

    public IntRaptMec getPointment(Long id) {

            Optional<IntRaptMec> obj = intRaptMecRepository.findById(id);
            return obj.get();

    }
}
@服务
公共类内部TMECService{
@自动连线
内隐匿性内隐匿性;
公共内部TMEC获取点(长id){
可选obj=intratmecrepository.findById(id);
返回obj.get();
}
}
这是内部存储类:

@Repository    
public interface IntRaptMecRepository extends JpaRepository<IntRaptMec, Long>{

}
@存储库
公共接口内部存储扩展了JPA存储{
}
解决方案是:

如果您使用的是Oracle数据库,则在对数据库表执行任何更新后,必须使用
COMMIT语句以保存所做的更改


使用提交后,对象正确返回。

您使用的JPA提供了什么?您是否在浏览器中看到过时的对象或在IDE中使用断点?是否延迟加载空属性?请显示您的持久类和映射。我必须使用某种类型的“RefreshDatabase”方法:否。Spring Boot它使用的是“缓存数据库”。这是真的吗?没有。有办法解决这个问题吗?:是的,可能是通过修复您没有向我们展示的代码。或者通过连接到正确的数据库。或者通过提交您对数据库所做的更改。@Ivan我在IDE中使用断点看到过时的对象。您是否提交了对数据库所做的更改?这应该是hibernate为您处理的事情。。如果您使用它来保存数据。您需要将数据提交到任何数据库(使用MyISAM表时可能除了MySQL)。@XtremeBiker我猜这些更改是在外部进行的,例如使用SQL Developer或其他查询工具。而不是通过基于Hibernate的应用程序。我使用SQLDeveloper进行更新。这就是为什么我有这种不一致性。
@Repository    
public interface IntRaptMecRepository extends JpaRepository<IntRaptMec, Long>{

}