em chào anh, em biết MyBatis phải tự handle SQL trong khi JPA có thể tự mapping bằng ORM, có khi không cần viết SQL. Vậy có phải JPA luôn tốt hơn MyBatis mọi bài toán, MyBatis hơn JPA điểm gì, khi nào nên chọn JPA, khi nào chọn MyBatis
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. MyBatis và JPA đều là các thư viện hỗ trợ việc mapping các đối tượng java với dữ liệu trong DB, tuy nhiên mỗi thư viện lại có cách làm khác nhau, trong khi JPA thiên về sử dụng annotation thì MyBatis lại có vẻ thích cấu hình qua xml hơn.
2. Việc tốt hơn hay không tốt hơn phụ thuộc vào quan điểm của mỗi người, nhưng với anh thì anh thích jpa hơn, anh cảm thấy việc dùng annotation đơn giản hơn nhiều.
3. Em có thể lựa chọn cái nào cũng được, tuy nhiên theo cá nhân anh, đối với các dự án dùng spring hay ezyfox thì em nên chọn JPA vì nó hỗ trợ cấu hình và sử dụng JPA đơn giản hơn