getOne() |
findById() |
Lazily loaded reference to target entity |
Actually loads the entity for the given id |
Useful only when access to properties of object is not required |
Object is eagerly loaded so all attributes can be accessed |
Throws EntityNotFoundException if actual object does not exist at the time of access invocation |
Returns null if actual object corresponding to given Id does not exist |
Better performance |
An additional round-trip to database is required |
鏈接:https://www.javacodemonk.com/difference-between-getone-and-findbyid-in-spring-data-jpa-3a96c3ff