Câu hỏi: HSF302 Làm việc với Spring Framework – Bộ ôn tập thi lại số 2
50 câu trắc nghiệm kèm lời giải của môn HSF302 - Làm việc với Spring Framework, xếp đúng thứ tự trong đề. Trang 2/3 — câu 21–40.
Danh sách câu hỏi
class TestController {
@GetMapping("/hello")
public String hello() { return "Hi"; }
}What is the response of GET /hello request?
DispatcherServletEntityManagerJdbcTemplateApplicationContext<span th:if="${user.loggedIn}">Welcome!</span>save()insert()persist()store()em.detach(entity)em.persist(entity)em.clear()em.flush()em.persist(entity);em.remove(entity);em.find(Entity.class, id);em.merge(entity);Đáp án đúng: "em.find(Entity.class, id); ". Phương thức find của EntityManager tìm thực thể theo khoá chính: trước hết nó tra trong persistence context, nếu chưa có thì phát câu SELECT, rồi trả về đối tượng đã được quản lý hoặc null nếu không tồn tại; đây là thao tác đọc (Read) trong CRUD. "em.persist(entity); " đưa một thực thể mới vào trạng thái được quản lý để INSERT khi flush, tức thao tác tạo. "em.remove(entity); " đánh dấu thực thể đang được quản lý để xoá, sinh DELETE khi flush. "em.merge(entity);"chép trạng thái của một thực thể tách rời (detached) vào bản được quản lý và trả về bản đó, dùng để cập nhật chứ không phải đọc.
Button btn = new Button("Click");
btn.setOnAction(e -> System.out.println("Pressed"));What happens when user clicks the button?
React.jsAngular.jsThymeleafNode.js