有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java使用接口获取Todo id或JPA getOne方法速度更快

我正在试图了解实现Todo实例或id更快的最佳方法

 @Repository
    public interface TodoDao extends JpaRepository<Todo, Long> {
    TodoInterface getASingleApplication(Long id);
    }
    
    
    //inside the controller
    
    Todo todo = todoDao.getOne(id); //this gets an object including all the relationships of Todo class using jpa crud repository

从上面看,我可以做到

print out >>> todo.getId(); //returns from jpa
    TodoInterface todoInterface = todoDao.getASingleApplication(id); //this returns just the id of Todo
    print out  >>>> todoInterface.getId();

请问哪种做法最好


共 (0) 个答案