mirror of
https://github.com/drtrang/druid-spring-boot.git
synced 2026-10-30 21:37:31 +00:00
jpa
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ public class CityController {
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
public City get(@PathVariable Long id) {
|
||||
return cityRepository.getOne(id);
|
||||
return cityRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-2
@@ -5,7 +5,6 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* MyBatis 测试
|
||||
@@ -16,7 +15,7 @@ public class JpaTests extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testOne() {
|
||||
Optional.ofNullable(cityRepository.getOne(1L))
|
||||
cityRepository.findById(1L)
|
||||
.ifPresent(gson::toJson);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user